var Xt=Object.defineProperty;var Jt=(c,e,n)=>e in c?Xt(c,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):c[e]=n;var rt=(c,e,n)=>(Jt(c,typeof e!="symbol"?e+"":e,n),n);import{s as safe_not_equal,e as element,a as space,t as text,c as claim_element,b as children,f as detach,g as claim_space,d as claim_text,l as get_svelte_dataset,m as attr,i as insert_hydration,h as append_hydration,o as listen,j as set_data,n as noop,p as createEventDispatcher,a9 as select_value,T as add_render_callback,aa as select_option,y as destroy_each,a5 as set_input_value,x as empty,L as compute_rest_props,k as component_subscribe,G as assign,M as exclude_internal_props,F as create_slot,a8 as set_attributes,a7 as action_destroyer,I as update_slot_base,J as get_all_dirty_from_scope,K as get_slot_changes,r as run_all,P as bubble,C as binding_callbacks,O as add_flush_callback,ab as set_store_value,ac as set_data_maybe_contenteditable,A as onMount,E as tick,q as svg_element,u as claim_svg_element,ad as setContext,ae as getContext,N as onDestroy,z as afterUpdate,B as set_style,af as prevent_default}from"../chunks/scheduler.FfJvB2D8.js";import{S as SvelteComponent,i as init,g as group_outros,t as transition_out,c as check_outros,a as transition_in,h as create_out_transition,j as create_in_transition,k as create_bidirectional_transition,b as create_component,d as claim_component,m as mount_component,e as destroy_component,f as bind}from"../chunks/index.TsXAreqO.js";import{p as page}from"../chunks/stores.n5u5L3is.js";import{c as cn,f as flyAndScale,e as getItemEmbeddings,h as getDatasetItem,p as postDatasetItem}from"../chunks/styleUtils.Gvmy_mco.js";import{o as ordinal,d as setCtx,f as getAttrs,h as getCtx,i as setCtx$1,j as getCtx$1,k as getAttrs$1,l as setCtx$2,m as getAttrs$2,n as getCtx$2,p as createCommand,q as createGroup,r as getCtx$3,t as getState,u as generateId,V as VALUE_ATTR,w as getGroup,x as isUndefined,y as commonjsGlobal,g as getDefaultExportFromCjs}from"../chunks/command.WBSTFUXj.js";import{c as createDispatcher,B as Button,T as TooltipIconButton,P as PrimaryButton}from"../chunks/PrimaryButton.uzPVdd89.js";import{d as derived,w as writable,g as goto}from"../chunks/entry.-xvSyRdo.js";import{g as get_spread_update,a as get_spread_object,I as Icon,L as Loader_2}from"../chunks/loader-2.tSmSib2i.js";import{e as ensure_array_like,m as modelsStore$1,s as saveCurrentItemStore,d as datasetsStore,i as isLoadingNewItemStore}from"../chunks/datasetStores.uB4k3o9T.js";import{W as WarningModal}from"../chunks/WarningModal.eUdlsjrb.js";function colors(c){for(var e=c.length/6|0,n=new Array(e),r=0;r<e;)n[r]="#"+c.slice(r*6,++r*6);return n}const schemeSet3=colors("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f");/**
 * @copyright CEA
 * @author CEA
 * @license CECILL
 *
 * This software is a collaborative computer program whose purpose is to
 * generate and explore labeled data for computer vision applications.
 * This software is governed by the CeCILL-C license under French law and
 * abiding by the rules of distribution of free software. You can use,
 * modify and/ or redistribute the software under the terms of the CeCILL-C
 * license as circulated by CEA, CNRS and INRIA at the following URL
 *
 * http://www.cecill.info
 */function ordinalColorScale(c){return ordinal(schemeSet3).domain(c)}function get_each_context$7(c,e,n){const r=c.slice();return r[7]=e[n],r}function create_else_block$e(c){let e,n;return{c(){e=element("p"),n=text(c[2]),this.h()},l(r){e=claim_element(r,"P",{class:!0});var i=children(e);n=claim_text(i,c[2]),i.forEach(detach),this.h()},h(){attr(e,"class","pb-1 italic")},m(r,i){insert_hydration(r,e,i),append_hydration(e,n)},p(r,i){i&4&&set_data(n,r[2])},d(r){r&&detach(e)}}}function create_if_block$s(c){let e,n,r,i=ensure_array_like(c[3]),o=[];for(let a=0;a<i.length;a+=1)o[a]=create_each_block$7(get_each_context$7(c,i,a));return{c(){e=element("select");for(let a=0;a<o.length;a+=1)o[a].c();this.h()},l(a){e=claim_element(a,"SELECT",{class:!0});var d=children(e);for(let f=0;f<o.length;f+=1)o[f].l(d);d.forEach(detach),this.h()},h(){attr(e,"class","py-1 px-2 border rounded focus:outline-none bg-slate-100 border-slate-300 focus:border-main"),c[0]===void 0&&add_render_callback(()=>c[5].call(e))},m(a,d){insert_hydration(a,e,d);for(let f=0;f<o.length;f+=1)o[f]&&o[f].m(e,null);select_option(e,c[0],!0),n||(r=listen(e,"change",c[5]),n=!0)},p(a,d){if(d&8){i=ensure_array_like(a[3]);let f;for(f=0;f<i.length;f+=1){const h=get_each_context$7(a,i,f);o[f]?o[f].p(h,d):(o[f]=create_each_block$7(h),o[f].c(),o[f].m(e,null))}for(;f<o.length;f+=1)o[f].d(1);o.length=i.length}d&9&&select_option(e,a[0])},d(a){a&&detach(e),destroy_each(o,a),n=!1,r()}}}function create_each_block$7(c){let e,n=c[7]+"",r,i,o;return{c(){e=element("option"),r=text(n),i=space(),this.h()},l(a){e=claim_element(a,"OPTION",{});var d=children(e);r=claim_text(d,n),i=claim_space(d),d.forEach(detach),this.h()},h(){e.__value=o=c[7],set_input_value(e,e.__value)},m(a,d){insert_hydration(a,e,d),append_hydration(e,r),append_hydration(e,i)},p(a,d){d&8&&n!==(n=a[7]+"")&&set_data(r,n),d&8&&o!==(o=a[7])&&(e.__value=o,set_input_value(e,e.__value))},d(a){a&&detach(e)}}}function create_fragment$X(c){let e,n,r,i,o,a,d,f,h,p,s="Ok",t,l;function u(_,b){return _[3]?create_if_block$s:create_else_block$e}let g=u(c),m=g(c);return{c(){e=element("div"),n=element("div"),r=space(),i=element("div"),o=element("div"),a=element("p"),d=text(c[1]),f=space(),m.c(),h=space(),p=element("button"),p.textContent=s,this.h()},l(_){e=claim_element(_,"DIV",{class:!0});var b=children(e);n=claim_element(b,"DIV",{class:!0}),children(n).forEach(detach),r=claim_space(b),i=claim_element(b,"DIV",{class:!0});var y=children(i);o=claim_element(y,"DIV",{class:!0});var v=children(o);a=claim_element(v,"P",{class:!0});var T=children(a);d=claim_text(T,c[1]),T.forEach(detach),f=claim_space(v),m.l(v),h=claim_space(v),p=claim_element(v,"BUTTON",{type:!0,class:!0,"data-svelte-h":!0}),get_svelte_dataset(p)!=="svelte-fnm6uk"&&(p.textContent=s),v.forEach(detach),y.forEach(detach),b.forEach(detach),this.h()},h(){attr(n,"class","fixed inset-0 bg-black bg-opacity-50 transition-opacity"),attr(a,"class","pb-1"),attr(p,"type","button"),attr(p,"class","rounded border border-transparent text-slate-50 mt-3 mx-1 py-1 px-3 bg-primary transition-colors hover:bg-primary-foreground"),attr(o,"class","relative transform overflow-hidden rounded-lg p-6 max-w-2xl bg-slate-50 text-slate-800"),attr(i,"class","flex min-h-full justify-center text-center items-center"),attr(e,"class","fixed inset-0 z-50 overflow-y-auto")},m(_,b){insert_hydration(_,e,b),append_hydration(e,n),append_hydration(e,r),append_hydration(e,i),append_hydration(i,o),append_hydration(o,a),append_hydration(a,d),append_hydration(o,f),m.m(o,null),append_hydration(o,h),append_hydration(o,p),t||(l=listen(p,"click",c[4]),t=!0)},p(_,[b]){b&2&&set_data(d,_[1]),g===(g=u(_))&&m?m.p(_,b):(m.d(1),m=g(_),m&&(m.c(),m.m(o,h)))},i:noop,o:noop,d(_){_&&detach(e),m.d(),t=!1,l()}}}function instance$_(c,e,n){let{message:r}=e,{ifNoChoices:i}=e,{choices:o}=e,{selected:a}=e;const d=createEventDispatcher();function f(){d("confirm")}function h(){a=select_value(this),n(0,a),n(3,o)}return c.$$set=p=>{"message"in p&&n(1,r=p.message),"ifNoChoices"in p&&n(2,i=p.ifNoChoices),"choices"in p&&n(3,o=p.choices),"selected"in p&&n(0,a=p.selected)},[a,r,i,o,f,h]}class SelectModal extends SvelteComponent{constructor(e){super(),init(this,e,instance$_,create_fragment$X,safe_not_equal,{message:1,ifNoChoices:2,choices:3,selected:0})}}const get_default_slot_changes_1$9=c=>({builder:c&4}),get_default_slot_context_1$9=c=>({builder:c[2],attrs:c[5]}),get_default_slot_changes$b=c=>({builder:c&4}),get_default_slot_context$b=c=>({builder:c[2],attrs:c[5]});function create_else_block$d(c){let e,n,r,i,o;const a=c[14].default,d=create_slot(a,c,c[13],get_default_slot_context_1$9);let f=[c[2],{type:"button"},c[6],c[5],{disabled:n=c[0]?!0:void 0}],h={};for(let p=0;p<f.length;p+=1)h=assign(h,f[p]);return{c(){e=element("button"),d&&d.c(),this.h()},l(p){e=claim_element(p,"BUTTON",{type:!0});var s=children(e);d&&d.l(s),s.forEach(detach),this.h()},h(){set_attributes(e,h)},m(p,s){insert_hydration(p,e,s),d&&d.m(e,null),e.autofocus&&e.focus(),r=!0,i||(o=[action_destroyer(c[2].action(e)),listen(e,"m-click",c[4]),listen(e,"m-keydown",c[4])],i=!0)},p(p,s){d&&d.p&&(!r||s&8196)&&update_slot_base(d,a,p,p[13],r?get_slot_changes(a,p[13],s,get_default_slot_changes_1$9):get_all_dirty_from_scope(p[13]),get_default_slot_context_1$9),set_attributes(e,h=get_spread_update(f,[s&4&&p[2],{type:"button"},s&64&&p[6],p[5],(!r||s&1&&n!==(n=p[0]?!0:void 0))&&{disabled:n}]))},i(p){r||(transition_in(d,p),r=!0)},o(p){transition_out(d,p),r=!1},d(p){p&&detach(e),d&&d.d(p),i=!1,run_all(o)}}}function create_if_block$r(c){let e;const n=c[14].default,r=create_slot(n,c,c[13],get_default_slot_context$b);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8196)&&update_slot_base(r,n,i,i[13],e?get_slot_changes(n,i[13],o,get_default_slot_changes$b):get_all_dirty_from_scope(i[13]),get_default_slot_context$b)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$W(c){let e,n,r,i;const o=[create_if_block$r,create_else_block$d],a=[];function d(f,h){return f[1]?0:1}return e=d(c),n=a[e]=o[e](c),{c(){n.c(),r=empty()},l(f){n.l(f),r=empty()},m(f,h){a[e].m(f,h),insert_hydration(f,r,h),i=!0},p(f,[h]){let p=e;e=d(f),e===p?a[e].p(f,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),n=a[e],n?n.p(f,h):(n=a[e]=o[e](f),n.c()),transition_in(n,1),n.m(r.parentNode,r))},i(f){i||(transition_in(n),i=!0)},o(f){transition_out(n),i=!1},d(f){f&&detach(r),a[e].d(f)}}}function instance$Z(c,e,n){let r;const i=["checked","disabled","name","required","value","onCheckedChange","asChild"];let o=compute_rest_props(e,i),a,{$$slots:d={},$$scope:f}=e,{checked:h=!1}=e,{disabled:p=void 0}=e,{name:s=void 0}=e,{required:t=void 0}=e,{value:l=void 0}=e,{onCheckedChange:u=void 0}=e,{asChild:g=!1}=e;const{elements:{root:m},states:{checked:_},updateOption:b}=setCtx({defaultChecked:h,disabled:p,name:s,required:t,value:l,onCheckedChange:({next:T})=>(h!==T&&(u==null||u(T),n(7,h=T)),T)});component_subscribe(c,m,T=>n(12,a=T));const y=createDispatcher(),v=getAttrs("root");return c.$$set=T=>{e=assign(assign({},e),exclude_internal_props(T)),n(6,o=compute_rest_props(e,i)),"checked"in T&&n(7,h=T.checked),"disabled"in T&&n(0,p=T.disabled),"name"in T&&n(8,s=T.name),"required"in T&&n(9,t=T.required),"value"in T&&n(10,l=T.value),"onCheckedChange"in T&&n(11,u=T.onCheckedChange),"asChild"in T&&n(1,g=T.asChild),"$$scope"in T&&n(13,f=T.$$scope)},c.$$.update=()=>{c.$$.dirty&128&&h!==void 0&&_.set(h),c.$$.dirty&1&&b("disabled",p),c.$$.dirty&256&&b("name",s),c.$$.dirty&512&&b("required",t),c.$$.dirty&1024&&b("value",l),c.$$.dirty&4096&&n(2,r=a)},[p,g,r,m,y,v,o,h,s,t,l,u,a,f,d]}let Checkbox$1=class extends SvelteComponent{constructor(e){super(),init(this,e,instance$Z,create_fragment$W,safe_not_equal,{checked:7,disabled:0,name:8,required:9,value:10,onCheckedChange:11,asChild:1})}};const get_default_slot_changes$a=c=>({isChecked:c&1,isIndeterminate:c&2}),get_default_slot_context$a=c=>({isChecked:c[0],isIndeterminate:c[1]});function create_fragment$V(c){let e,n;const r=c[7].default,i=create_slot(r,c,c[6],get_default_slot_context$a);let o=[c[5],c[4]],a={};for(let d=0;d<o.length;d+=1)a=assign(a,o[d]);return{c(){e=element("div"),i&&i.c(),this.h()},l(d){e=claim_element(d,"DIV",{});var f=children(e);i&&i.l(f),f.forEach(detach),this.h()},h(){set_attributes(e,a)},m(d,f){insert_hydration(d,e,f),i&&i.m(e,null),n=!0},p(d,[f]){i&&i.p&&(!n||f&67)&&update_slot_base(i,r,d,d[6],n?get_slot_changes(r,d[6],f,get_default_slot_changes$a):get_all_dirty_from_scope(d[6]),get_default_slot_context$a),set_attributes(e,a=get_spread_update(o,[f&32&&d[5],d[4]]))},i(d){n||(transition_in(i,d),n=!0)},o(d){transition_out(i,d),n=!1},d(d){d&&detach(e),i&&i.d(d)}}}function instance$Y(c,e,n){const r=[];let i=compute_rest_props(e,r),o,a,{$$slots:d={},$$scope:f}=e;const{helpers:{isChecked:h,isIndeterminate:p}}=getCtx();component_subscribe(c,h,t=>n(0,o=t)),component_subscribe(c,p,t=>n(1,a=t));const s=getAttrs("indicator");return c.$$set=t=>{e=assign(assign({},e),exclude_internal_props(t)),n(5,i=compute_rest_props(e,r)),"$$scope"in t&&n(6,f=t.$$scope)},[o,a,h,p,s,i,f,d]}class CheckboxIndicator extends SvelteComponent{constructor(e){super(),init(this,e,instance$Y,create_fragment$V,safe_not_equal,{})}}const get_default_slot_changes$9=c=>({ids:c&1}),get_default_slot_context$9=c=>({ids:c[0]});function create_fragment$U(c){let e;const n=c[14].default,r=create_slot(n,c,c[13],get_default_slot_context$9);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,[o]){r&&r.p&&(!e||o&8193)&&update_slot_base(r,n,i,i[13],e?get_slot_changes(n,i[13],o,get_default_slot_changes$9):get_all_dirty_from_scope(i[13]),get_default_slot_context$9)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function instance$X(c,e,n){let r,{$$slots:i={},$$scope:o}=e,{positioning:a=void 0}=e,{arrowSize:d=void 0}=e,{disableFocusTrap:f=void 0}=e,{closeOnEscape:h=void 0}=e,{closeOnOutsideClick:p=void 0}=e,{preventScroll:s=void 0}=e,{portal:t=void 0}=e,{open:l=void 0}=e,{onOpenChange:u=void 0}=e,{openFocus:g=void 0}=e,{closeFocus:m=void 0}=e;const{updateOption:_,states:{open:b},ids:y}=setCtx$1({positioning:a,arrowSize:d,disableFocusTrap:f,closeOnEscape:h,closeOnOutsideClick:p,preventScroll:s,portal:t,defaultOpen:l,openFocus:g,closeFocus:m,onOpenChange:({next:T})=>(l!==T&&(u==null||u(T),n(2,l=T)),T)}),v=derived([y.content,y.trigger],([T,w])=>({content:T,trigger:w}));return component_subscribe(c,v,T=>n(0,r=T)),c.$$set=T=>{"positioning"in T&&n(3,a=T.positioning),"arrowSize"in T&&n(4,d=T.arrowSize),"disableFocusTrap"in T&&n(5,f=T.disableFocusTrap),"closeOnEscape"in T&&n(6,h=T.closeOnEscape),"closeOnOutsideClick"in T&&n(7,p=T.closeOnOutsideClick),"preventScroll"in T&&n(8,s=T.preventScroll),"portal"in T&&n(9,t=T.portal),"open"in T&&n(2,l=T.open),"onOpenChange"in T&&n(10,u=T.onOpenChange),"openFocus"in T&&n(11,g=T.openFocus),"closeFocus"in T&&n(12,m=T.closeFocus),"$$scope"in T&&n(13,o=T.$$scope)},c.$$.update=()=>{c.$$.dirty&4&&l!==void 0&&b.set(l),c.$$.dirty&8&&_("positioning",a),c.$$.dirty&16&&_("arrowSize",d),c.$$.dirty&32&&_("disableFocusTrap",f),c.$$.dirty&64&&_("closeOnEscape",h),c.$$.dirty&128&&_("closeOnOutsideClick",p),c.$$.dirty&256&&_("preventScroll",s),c.$$.dirty&512&&_("portal",t),c.$$.dirty&2048&&_("openFocus",g),c.$$.dirty&4096&&_("closeFocus",m)},[r,v,l,a,d,f,h,p,s,t,u,g,m,o,i]}class Popover extends SvelteComponent{constructor(e){super(),init(this,e,instance$X,create_fragment$U,safe_not_equal,{positioning:3,arrowSize:4,disableFocusTrap:5,closeOnEscape:6,closeOnOutsideClick:7,preventScroll:8,portal:9,open:2,onOpenChange:10,openFocus:11,closeFocus:12})}}const get_default_slot_changes_5=c=>({builder:c&128}),get_default_slot_context_5=c=>({builder:c[7],attrs:c[11]}),get_default_slot_changes_4=c=>({builder:c&128}),get_default_slot_context_4=c=>({builder:c[7],attrs:c[11]}),get_default_slot_changes_3=c=>({builder:c&128}),get_default_slot_context_3=c=>({builder:c[7],attrs:c[11]}),get_default_slot_changes_2=c=>({builder:c&128}),get_default_slot_context_2=c=>({builder:c[7],attrs:c[11]}),get_default_slot_changes_1$8=c=>({builder:c&128}),get_default_slot_context_1$8=c=>({builder:c[7],attrs:c[11]}),get_default_slot_changes$8=c=>({builder:c&128}),get_default_slot_context$8=c=>({builder:c[7],attrs:c[11]});function create_if_block_5$1(c){let e,n,r,i;const o=c[16].default,a=create_slot(o,c,c[15],get_default_slot_context_5);let d=[c[7],c[12],c[11]],f={};for(let h=0;h<d.length;h+=1)f=assign(f,d[h]);return{c(){e=element("div"),a&&a.c(),this.h()},l(h){e=claim_element(h,"DIV",{});var p=children(e);a&&a.l(p),p.forEach(detach),this.h()},h(){set_attributes(e,f)},m(h,p){insert_hydration(h,e,p),a&&a.m(e,null),n=!0,r||(i=action_destroyer(c[7].action(e)),r=!0)},p(h,p){a&&a.p&&(!n||p&32896)&&update_slot_base(a,o,h,h[15],n?get_slot_changes(o,h[15],p,get_default_slot_changes_5):get_all_dirty_from_scope(h[15]),get_default_slot_context_5),set_attributes(e,f=get_spread_update(d,[p&128&&h[7],p&4096&&h[12],h[11]]))},i(h){n||(transition_in(a,h),n=!0)},o(h){transition_out(a,h),n=!1},d(h){h&&detach(e),a&&a.d(h),r=!1,i()}}}function create_if_block_4$1(c){let e,n,r,i,o;const a=c[16].default,d=create_slot(a,c,c[15],get_default_slot_context_4);let f=[c[7],c[12],c[11]],h={};for(let p=0;p<f.length;p+=1)h=assign(h,f[p]);return{c(){e=element("div"),d&&d.c(),this.h()},l(p){e=claim_element(p,"DIV",{});var s=children(e);d&&d.l(s),s.forEach(detach),this.h()},h(){set_attributes(e,h)},m(p,s){insert_hydration(p,e,s),d&&d.m(e,null),r=!0,i||(o=action_destroyer(c[7].action(e)),i=!0)},p(p,s){c=p,d&&d.p&&(!r||s&32896)&&update_slot_base(d,a,c,c[15],r?get_slot_changes(a,c[15],s,get_default_slot_changes_4):get_all_dirty_from_scope(c[15]),get_default_slot_context_4),set_attributes(e,h=get_spread_update(f,[s&128&&c[7],s&4096&&c[12],c[11]]))},i(p){r||(transition_in(d,p),n&&n.end(1),r=!0)},o(p){transition_out(d,p),p&&(n=create_out_transition(e,c[4],c[5])),r=!1},d(p){p&&detach(e),d&&d.d(p),p&&n&&n.end(),i=!1,o()}}}function create_if_block_3$3(c){let e,n,r,i,o;const a=c[16].default,d=create_slot(a,c,c[15],get_default_slot_context_3);let f=[c[7],c[12],c[11]],h={};for(let p=0;p<f.length;p+=1)h=assign(h,f[p]);return{c(){e=element("div"),d&&d.c(),this.h()},l(p){e=claim_element(p,"DIV",{});var s=children(e);d&&d.l(s),s.forEach(detach),this.h()},h(){set_attributes(e,h)},m(p,s){insert_hydration(p,e,s),d&&d.m(e,null),r=!0,i||(o=action_destroyer(c[7].action(e)),i=!0)},p(p,s){c=p,d&&d.p&&(!r||s&32896)&&update_slot_base(d,a,c,c[15],r?get_slot_changes(a,c[15],s,get_default_slot_changes_3):get_all_dirty_from_scope(c[15]),get_default_slot_context_3),set_attributes(e,h=get_spread_update(f,[s&128&&c[7],s&4096&&c[12],c[11]]))},i(p){r||(transition_in(d,p),p&&(n||add_render_callback(()=>{n=create_in_transition(e,c[2],c[3]),n.start()})),r=!0)},o(p){transition_out(d,p),r=!1},d(p){p&&detach(e),d&&d.d(p),i=!1,o()}}}function create_if_block_2$7(c){let e,n,r,i,o,a;const d=c[16].default,f=create_slot(d,c,c[15],get_default_slot_context_2);let h=[c[7],c[12],c[11]],p={};for(let s=0;s<h.length;s+=1)p=assign(p,h[s]);return{c(){e=element("div"),f&&f.c(),this.h()},l(s){e=claim_element(s,"DIV",{});var t=children(e);f&&f.l(t),t.forEach(detach),this.h()},h(){set_attributes(e,p)},m(s,t){insert_hydration(s,e,t),f&&f.m(e,null),i=!0,o||(a=action_destroyer(c[7].action(e)),o=!0)},p(s,t){c=s,f&&f.p&&(!i||t&32896)&&update_slot_base(f,d,c,c[15],i?get_slot_changes(d,c[15],t,get_default_slot_changes_2):get_all_dirty_from_scope(c[15]),get_default_slot_context_2),set_attributes(e,p=get_spread_update(h,[t&128&&c[7],t&4096&&c[12],c[11]]))},i(s){i||(transition_in(f,s),s&&add_render_callback(()=>{i&&(r&&r.end(1),n=create_in_transition(e,c[2],c[3]),n.start())}),i=!0)},o(s){transition_out(f,s),n&&n.invalidate(),s&&(r=create_out_transition(e,c[4],c[5])),i=!1},d(s){s&&detach(e),f&&f.d(s),s&&r&&r.end(),o=!1,a()}}}function create_if_block_1$d(c){let e,n,r,i,o;const a=c[16].default,d=create_slot(a,c,c[15],get_default_slot_context_1$8);let f=[c[7],c[12],c[11]],h={};for(let p=0;p<f.length;p+=1)h=assign(h,f[p]);return{c(){e=element("div"),d&&d.c(),this.h()},l(p){e=claim_element(p,"DIV",{});var s=children(e);d&&d.l(s),s.forEach(detach),this.h()},h(){set_attributes(e,h)},m(p,s){insert_hydration(p,e,s),d&&d.m(e,null),r=!0,i||(o=action_destroyer(c[7].action(e)),i=!0)},p(p,s){c=p,d&&d.p&&(!r||s&32896)&&update_slot_base(d,a,c,c[15],r?get_slot_changes(a,c[15],s,get_default_slot_changes_1$8):get_all_dirty_from_scope(c[15]),get_default_slot_context_1$8),set_attributes(e,h=get_spread_update(f,[s&128&&c[7],s&4096&&c[12],c[11]]))},i(p){r||(transition_in(d,p),p&&add_render_callback(()=>{r&&(n||(n=create_bidirectional_transition(e,c[0],c[1],!0)),n.run(1))}),r=!0)},o(p){transition_out(d,p),p&&(n||(n=create_bidirectional_transition(e,c[0],c[1],!1)),n.run(0)),r=!1},d(p){p&&detach(e),d&&d.d(p),p&&n&&n.end(),i=!1,o()}}}function create_if_block$q(c){let e;const n=c[16].default,r=create_slot(n,c,c[15],get_default_slot_context$8);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&32896)&&update_slot_base(r,n,i,i[15],e?get_slot_changes(n,i[15],o,get_default_slot_changes$8):get_all_dirty_from_scope(i[15]),get_default_slot_context$8)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$T(c){let e,n,r,i;const o=[create_if_block$q,create_if_block_1$d,create_if_block_2$7,create_if_block_3$3,create_if_block_4$1,create_if_block_5$1],a=[];function d(f,h){return f[6]&&f[8]?0:f[0]&&f[8]?1:f[2]&&f[4]&&f[8]?2:f[2]&&f[8]?3:f[4]&&f[8]?4:f[8]?5:-1}return~(e=d(c))&&(n=a[e]=o[e](c)),{c(){n&&n.c(),r=empty()},l(f){n&&n.l(f),r=empty()},m(f,h){~e&&a[e].m(f,h),insert_hydration(f,r,h),i=!0},p(f,[h]){let p=e;e=d(f),e===p?~e&&a[e].p(f,h):(n&&(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros()),~e?(n=a[e],n?n.p(f,h):(n=a[e]=o[e](f),n.c()),transition_in(n,1),n.m(r.parentNode,r)):n=null)},i(f){i||(transition_in(n),i=!0)},o(f){transition_out(n),i=!1},d(f){f&&detach(r),~e&&a[e].d(f)}}}function instance$W(c,e,n){let r;const i=["transition","transitionConfig","inTransition","inTransitionConfig","outTransition","outTransitionConfig","asChild","id"];let o=compute_rest_props(e,i),a,d,{$$slots:f={},$$scope:h}=e,{transition:p=void 0}=e,{transitionConfig:s=void 0}=e,{inTransition:t=void 0}=e,{inTransitionConfig:l=void 0}=e,{outTransition:u=void 0}=e,{outTransitionConfig:g=void 0}=e,{asChild:m=!1}=e,{id:_=void 0}=e;const{elements:{content:b},states:{open:y},ids:v}=getCtx$1();component_subscribe(c,b,w=>n(14,a=w)),component_subscribe(c,y,w=>n(8,d=w));const T=getAttrs$1("content");return c.$$set=w=>{e=assign(assign({},e),exclude_internal_props(w)),n(12,o=compute_rest_props(e,i)),"transition"in w&&n(0,p=w.transition),"transitionConfig"in w&&n(1,s=w.transitionConfig),"inTransition"in w&&n(2,t=w.inTransition),"inTransitionConfig"in w&&n(3,l=w.inTransitionConfig),"outTransition"in w&&n(4,u=w.outTransition),"outTransitionConfig"in w&&n(5,g=w.outTransitionConfig),"asChild"in w&&n(6,m=w.asChild),"id"in w&&n(13,_=w.id),"$$scope"in w&&n(15,h=w.$$scope)},c.$$.update=()=>{c.$$.dirty&8192&&_&&v.content.set(_),c.$$.dirty&16384&&n(7,r=a)},[p,s,t,l,u,g,m,r,d,b,y,T,o,_,a,h,f]}class PopoverContent extends SvelteComponent{constructor(e){super(),init(this,e,instance$W,create_fragment$T,safe_not_equal,{transition:0,transitionConfig:1,inTransition:2,inTransitionConfig:3,outTransition:4,outTransitionConfig:5,asChild:6,id:13})}}const get_default_slot_changes_1$7=c=>({builder:c&2}),get_default_slot_context_1$7=c=>({builder:c[1],attrs:c[4]}),get_default_slot_changes$7=c=>({builder:c&2}),get_default_slot_context$7=c=>({builder:c[1],attrs:c[4]});function create_else_block$c(c){let e,n,r,i;const o=c[9].default,a=create_slot(o,c,c[8],get_default_slot_context_1$7);let d=[c[1],{type:"button"},c[5],c[4]],f={};for(let h=0;h<d.length;h+=1)f=assign(f,d[h]);return{c(){e=element("button"),a&&a.c(),this.h()},l(h){e=claim_element(h,"BUTTON",{type:!0});var p=children(e);a&&a.l(p),p.forEach(detach),this.h()},h(){set_attributes(e,f)},m(h,p){insert_hydration(h,e,p),a&&a.m(e,null),e.autofocus&&e.focus(),n=!0,r||(i=[action_destroyer(c[1].action(e)),listen(e,"m-click",c[3]),listen(e,"m-keydown",c[3])],r=!0)},p(h,p){a&&a.p&&(!n||p&258)&&update_slot_base(a,o,h,h[8],n?get_slot_changes(o,h[8],p,get_default_slot_changes_1$7):get_all_dirty_from_scope(h[8]),get_default_slot_context_1$7),set_attributes(e,f=get_spread_update(d,[p&2&&h[1],{type:"button"},p&32&&h[5],h[4]]))},i(h){n||(transition_in(a,h),n=!0)},o(h){transition_out(a,h),n=!1},d(h){h&&detach(e),a&&a.d(h),r=!1,run_all(i)}}}function create_if_block$p(c){let e;const n=c[9].default,r=create_slot(n,c,c[8],get_default_slot_context$7);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&258)&&update_slot_base(r,n,i,i[8],e?get_slot_changes(n,i[8],o,get_default_slot_changes$7):get_all_dirty_from_scope(i[8]),get_default_slot_context$7)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$S(c){let e,n,r,i;const o=[create_if_block$p,create_else_block$c],a=[];function d(f,h){return f[0]?0:1}return e=d(c),n=a[e]=o[e](c),{c(){n.c(),r=empty()},l(f){n.l(f),r=empty()},m(f,h){a[e].m(f,h),insert_hydration(f,r,h),i=!0},p(f,[h]){let p=e;e=d(f),e===p?a[e].p(f,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),n=a[e],n?n.p(f,h):(n=a[e]=o[e](f),n.c()),transition_in(n,1),n.m(r.parentNode,r))},i(f){i||(transition_in(n),i=!0)},o(f){transition_out(n),i=!1},d(f){f&&detach(r),a[e].d(f)}}}function instance$V(c,e,n){let r;const i=["asChild","id"];let o=compute_rest_props(e,i),a,{$$slots:d={},$$scope:f}=e,{asChild:h=!1}=e,{id:p=void 0}=e;const{elements:{trigger:s},ids:t}=getCtx$1();component_subscribe(c,s,g=>n(7,a=g));const l=createDispatcher(),u=getAttrs$1("trigger");return c.$$set=g=>{e=assign(assign({},e),exclude_internal_props(g)),n(5,o=compute_rest_props(e,i)),"asChild"in g&&n(0,h=g.asChild),"id"in g&&n(6,p=g.id),"$$scope"in g&&n(8,f=g.$$scope)},c.$$.update=()=>{c.$$.dirty&64&&p&&t.trigger.set(p),c.$$.dirty&128&&n(1,r=a)},[h,r,s,l,u,o,p,a,f,d]}class PopoverTrigger extends SvelteComponent{constructor(e){super(),init(this,e,instance$V,create_fragment$S,safe_not_equal,{asChild:0,id:6})}}const get_default_slot_changes_1$6=c=>({builder:c&2}),get_default_slot_context_1$6=c=>({builder:c[1],attrs:c[3]}),get_default_slot_changes$6=c=>({builder:c&2}),get_default_slot_context$6=c=>({builder:c[1],attrs:c[3]});function create_else_block$b(c){let e,n,r,i;const o=c[13].default,a=create_slot(o,c,c[12],get_default_slot_context_1$6);let d=[c[1],c[4],c[3]],f={};for(let h=0;h<d.length;h+=1)f=assign(f,d[h]);return{c(){e=element("div"),a&&a.c(),this.h()},l(h){e=claim_element(h,"DIV",{});var p=children(e);a&&a.l(p),p.forEach(detach),this.h()},h(){set_attributes(e,f)},m(h,p){insert_hydration(h,e,p),a&&a.m(e,null),n=!0,r||(i=action_destroyer(c[1].action(e)),r=!0)},p(h,p){a&&a.p&&(!n||p&4098)&&update_slot_base(a,o,h,h[12],n?get_slot_changes(o,h[12],p,get_default_slot_changes_1$6):get_all_dirty_from_scope(h[12]),get_default_slot_context_1$6),set_attributes(e,f=get_spread_update(d,[p&2&&h[1],p&16&&h[4],h[3]]))},i(h){n||(transition_in(a,h),n=!0)},o(h){transition_out(a,h),n=!1},d(h){h&&detach(e),a&&a.d(h),r=!1,i()}}}function create_if_block$o(c){let e;const n=c[13].default,r=create_slot(n,c,c[12],get_default_slot_context$6);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&4098)&&update_slot_base(r,n,i,i[12],e?get_slot_changes(n,i[12],o,get_default_slot_changes$6):get_all_dirty_from_scope(i[12]),get_default_slot_context$6)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$R(c){let e,n,r,i;const o=[create_if_block$o,create_else_block$b],a=[];function d(f,h){return f[0]?0:1}return e=d(c),n=a[e]=o[e](c),{c(){n.c(),r=empty()},l(f){n.l(f),r=empty()},m(f,h){a[e].m(f,h),insert_hydration(f,r,h),i=!0},p(f,[h]){let p=e;e=d(f),e===p?a[e].p(f,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),n=a[e],n?n.p(f,h):(n=a[e]=o[e](f),n.c()),transition_in(n,1),n.m(r.parentNode,r))},i(f){i||(transition_in(n),i=!0)},o(f){transition_out(n),i=!1},d(f){f&&detach(r),a[e].d(f)}}}function instance$U(c,e,n){let r;const i=["orientation","activateOnFocus","loop","autoSet","value","onValueChange","asChild"];let o=compute_rest_props(e,i),a,{$$slots:d={},$$scope:f}=e,{orientation:h=void 0}=e,{activateOnFocus:p=void 0}=e,{loop:s=void 0}=e,{autoSet:t=void 0}=e,{value:l=void 0}=e,{onValueChange:u=void 0}=e,{asChild:g=!1}=e;const{elements:{root:m},states:{value:_},updateOption:b}=setCtx$2({orientation:h,activateOnFocus:p,loop:s,autoSet:t,defaultValue:l,onValueChange:({next:v})=>(l!==v&&(u==null||u(v),n(5,l=v)),v)});component_subscribe(c,m,v=>n(11,a=v));const y=getAttrs$2("root");return c.$$set=v=>{e=assign(assign({},e),exclude_internal_props(v)),n(4,o=compute_rest_props(e,i)),"orientation"in v&&n(6,h=v.orientation),"activateOnFocus"in v&&n(7,p=v.activateOnFocus),"loop"in v&&n(8,s=v.loop),"autoSet"in v&&n(9,t=v.autoSet),"value"in v&&n(5,l=v.value),"onValueChange"in v&&n(10,u=v.onValueChange),"asChild"in v&&n(0,g=v.asChild),"$$scope"in v&&n(12,f=v.$$scope)},c.$$.update=()=>{c.$$.dirty&32&&l!==void 0&&_.set(l),c.$$.dirty&64&&b("orientation",h),c.$$.dirty&128&&b("activateOnFocus",p),c.$$.dirty&256&&b("loop",s),c.$$.dirty&512&&b("autoSet",t),c.$$.dirty&2048&&n(1,r=a)},[g,r,m,y,o,l,h,p,s,t,u,a,f,d]}class Tabs extends SvelteComponent{constructor(e){super(),init(this,e,instance$U,create_fragment$R,safe_not_equal,{orientation:6,activateOnFocus:7,loop:8,autoSet:9,value:5,onValueChange:10,asChild:0})}}const get_default_slot_changes_1$5=c=>({builder:c&2}),get_default_slot_context_1$5=c=>({builder:c[1],attrs:c[3]}),get_default_slot_changes$5=c=>({builder:c&2}),get_default_slot_context$5=c=>({builder:c[1],attrs:c[3]});function create_else_block$a(c){let e,n,r,i;const o=c[8].default,a=create_slot(o,c,c[7],get_default_slot_context_1$5);let d=[c[1],c[4],c[3]],f={};for(let h=0;h<d.length;h+=1)f=assign(f,d[h]);return{c(){e=element("div"),a&&a.c(),this.h()},l(h){e=claim_element(h,"DIV",{});var p=children(e);a&&a.l(p),p.forEach(detach),this.h()},h(){set_attributes(e,f)},m(h,p){insert_hydration(h,e,p),a&&a.m(e,null),n=!0,r||(i=action_destroyer(c[1].action(e)),r=!0)},p(h,p){a&&a.p&&(!n||p&130)&&update_slot_base(a,o,h,h[7],n?get_slot_changes(o,h[7],p,get_default_slot_changes_1$5):get_all_dirty_from_scope(h[7]),get_default_slot_context_1$5),set_attributes(e,f=get_spread_update(d,[p&2&&h[1],p&16&&h[4],h[3]]))},i(h){n||(transition_in(a,h),n=!0)},o(h){transition_out(a,h),n=!1},d(h){h&&detach(e),a&&a.d(h),r=!1,i()}}}function create_if_block$n(c){let e;const n=c[8].default,r=create_slot(n,c,c[7],get_default_slot_context$5);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&130)&&update_slot_base(r,n,i,i[7],e?get_slot_changes(n,i[7],o,get_default_slot_changes$5):get_all_dirty_from_scope(i[7]),get_default_slot_context$5)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$Q(c){let e,n,r,i;const o=[create_if_block$n,create_else_block$a],a=[];function d(f,h){return f[0]?0:1}return e=d(c),n=a[e]=o[e](c),{c(){n.c(),r=empty()},l(f){n.l(f),r=empty()},m(f,h){a[e].m(f,h),insert_hydration(f,r,h),i=!0},p(f,[h]){let p=e;e=d(f),e===p?a[e].p(f,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),n=a[e],n?n.p(f,h):(n=a[e]=o[e](f),n.c()),transition_in(n,1),n.m(r.parentNode,r))},i(f){i||(transition_in(n),i=!0)},o(f){transition_out(n),i=!1},d(f){f&&detach(r),a[e].d(f)}}}function instance$T(c,e,n){let r;const i=["value","asChild"];let o=compute_rest_props(e,i),a,{$$slots:d={},$$scope:f}=e,{value:h}=e,{asChild:p=!1}=e;const{elements:{content:s}}=getCtx$2();component_subscribe(c,s,l=>n(6,a=l));const t=getAttrs$2("content");return c.$$set=l=>{e=assign(assign({},e),exclude_internal_props(l)),n(4,o=compute_rest_props(e,i)),"value"in l&&n(5,h=l.value),"asChild"in l&&n(0,p=l.asChild),"$$scope"in l&&n(7,f=l.$$scope)},c.$$.update=()=>{c.$$.dirty&96&&n(1,r=a(h))},[p,r,s,t,o,h,a,f,d]}class TabsContent extends SvelteComponent{constructor(e){super(),init(this,e,instance$T,create_fragment$Q,safe_not_equal,{value:5,asChild:0})}}const get_default_slot_changes_1$4=c=>({builder:c&2}),get_default_slot_context_1$4=c=>({builder:c[1],attrs:c[3]}),get_default_slot_changes$4=c=>({builder:c&2}),get_default_slot_context$4=c=>({builder:c[1],attrs:c[3]});function create_else_block$9(c){let e,n,r,i;const o=c[7].default,a=create_slot(o,c,c[6],get_default_slot_context_1$4);let d=[c[1],c[4],c[3]],f={};for(let h=0;h<d.length;h+=1)f=assign(f,d[h]);return{c(){e=element("div"),a&&a.c(),this.h()},l(h){e=claim_element(h,"DIV",{});var p=children(e);a&&a.l(p),p.forEach(detach),this.h()},h(){set_attributes(e,f)},m(h,p){insert_hydration(h,e,p),a&&a.m(e,null),n=!0,r||(i=action_destroyer(c[1].action(e)),r=!0)},p(h,p){a&&a.p&&(!n||p&66)&&update_slot_base(a,o,h,h[6],n?get_slot_changes(o,h[6],p,get_default_slot_changes_1$4):get_all_dirty_from_scope(h[6]),get_default_slot_context_1$4),set_attributes(e,f=get_spread_update(d,[p&2&&h[1],p&16&&h[4],h[3]]))},i(h){n||(transition_in(a,h),n=!0)},o(h){transition_out(a,h),n=!1},d(h){h&&detach(e),a&&a.d(h),r=!1,i()}}}function create_if_block$m(c){let e;const n=c[7].default,r=create_slot(n,c,c[6],get_default_slot_context$4);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&66)&&update_slot_base(r,n,i,i[6],e?get_slot_changes(n,i[6],o,get_default_slot_changes$4):get_all_dirty_from_scope(i[6]),get_default_slot_context$4)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$P(c){let e,n,r,i;const o=[create_if_block$m,create_else_block$9],a=[];function d(f,h){return f[0]?0:1}return e=d(c),n=a[e]=o[e](c),{c(){n.c(),r=empty()},l(f){n.l(f),r=empty()},m(f,h){a[e].m(f,h),insert_hydration(f,r,h),i=!0},p(f,[h]){let p=e;e=d(f),e===p?a[e].p(f,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),n=a[e],n?n.p(f,h):(n=a[e]=o[e](f),n.c()),transition_in(n,1),n.m(r.parentNode,r))},i(f){i||(transition_in(n),i=!0)},o(f){transition_out(n),i=!1},d(f){f&&detach(r),a[e].d(f)}}}function instance$S(c,e,n){let r;const i=["asChild"];let o=compute_rest_props(e,i),a,{$$slots:d={},$$scope:f}=e,{asChild:h=!1}=e;const{elements:{list:p}}=getCtx$2();component_subscribe(c,p,t=>n(5,a=t));const s=getAttrs$2("list");return c.$$set=t=>{e=assign(assign({},e),exclude_internal_props(t)),n(4,o=compute_rest_props(e,i)),"asChild"in t&&n(0,h=t.asChild),"$$scope"in t&&n(6,f=t.$$scope)},c.$$.update=()=>{c.$$.dirty&32&&n(1,r=a)},[h,r,p,s,o,a,f,d]}class TabsList extends SvelteComponent{constructor(e){super(),init(this,e,instance$S,create_fragment$P,safe_not_equal,{asChild:0})}}const get_default_slot_changes_1$3=c=>({builder:c&2}),get_default_slot_context_1$3=c=>({builder:c[1],attrs:c[4]}),get_default_slot_changes$3=c=>({builder:c&2}),get_default_slot_context$3=c=>({builder:c[1],attrs:c[4]});function create_else_block$8(c){let e,n,r,i;const o=c[10].default,a=create_slot(o,c,c[9],get_default_slot_context_1$3);let d=[c[1],{type:"button"},c[5],c[4]],f={};for(let h=0;h<d.length;h+=1)f=assign(f,d[h]);return{c(){e=element("button"),a&&a.c(),this.h()},l(h){e=claim_element(h,"BUTTON",{type:!0});var p=children(e);a&&a.l(p),p.forEach(detach),this.h()},h(){set_attributes(e,f)},m(h,p){insert_hydration(h,e,p),a&&a.m(e,null),e.autofocus&&e.focus(),n=!0,r||(i=[action_destroyer(c[1].action(e)),listen(e,"m-click",c[3]),listen(e,"m-focus",c[3]),listen(e,"m-keydown",c[3])],r=!0)},p(h,p){a&&a.p&&(!n||p&514)&&update_slot_base(a,o,h,h[9],n?get_slot_changes(o,h[9],p,get_default_slot_changes_1$3):get_all_dirty_from_scope(h[9]),get_default_slot_context_1$3),set_attributes(e,f=get_spread_update(d,[p&2&&h[1],{type:"button"},p&32&&h[5],h[4]]))},i(h){n||(transition_in(a,h),n=!0)},o(h){transition_out(a,h),n=!1},d(h){h&&detach(e),a&&a.d(h),r=!1,run_all(i)}}}function create_if_block$l(c){let e;const n=c[10].default,r=create_slot(n,c,c[9],get_default_slot_context$3);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&514)&&update_slot_base(r,n,i,i[9],e?get_slot_changes(n,i[9],o,get_default_slot_changes$3):get_all_dirty_from_scope(i[9]),get_default_slot_context$3)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$O(c){let e,n,r,i;const o=[create_if_block$l,create_else_block$8],a=[];function d(f,h){return f[0]?0:1}return e=d(c),n=a[e]=o[e](c),{c(){n.c(),r=empty()},l(f){n.l(f),r=empty()},m(f,h){a[e].m(f,h),insert_hydration(f,r,h),i=!0},p(f,[h]){let p=e;e=d(f),e===p?a[e].p(f,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),n=a[e],n?n.p(f,h):(n=a[e]=o[e](f),n.c()),transition_in(n,1),n.m(r.parentNode,r))},i(f){i||(transition_in(n),i=!0)},o(f){transition_out(n),i=!1},d(f){f&&detach(r),a[e].d(f)}}}function instance$R(c,e,n){let r;const i=["value","disabled","asChild"];let o=compute_rest_props(e,i),a,{$$slots:d={},$$scope:f}=e,{value:h}=e,{disabled:p=void 0}=e,{asChild:s=!1}=e;const{elements:{trigger:t}}=getCtx$2();component_subscribe(c,t,g=>n(8,a=g));const l=createDispatcher(),u=getAttrs$2("trigger");return c.$$set=g=>{e=assign(assign({},e),exclude_internal_props(g)),n(5,o=compute_rest_props(e,i)),"value"in g&&n(6,h=g.value),"disabled"in g&&n(7,p=g.disabled),"asChild"in g&&n(0,s=g.asChild),"$$scope"in g&&n(9,f=g.$$scope)},c.$$.update=()=>{c.$$.dirty&448&&n(1,r=a({value:h,disabled:p}))},[s,r,t,l,u,o,h,p,a,f,d]}class TabsTrigger extends SvelteComponent{constructor(e){super(),init(this,e,instance$R,create_fragment$O,safe_not_equal,{value:6,disabled:7,asChild:0})}}function create_default_slot$y(c){let e;const n=c[3].default,r=create_slot(n,c,c[4],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&16)&&update_slot_base(r,n,i,i[4],e?get_slot_changes(n,i[4],o,null):get_all_dirty_from_scope(i[4]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$N(c){let e,n;const r=[{class:cn("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",c[0])},{value:c[1]},c[2]];let i={$$slots:{default:[create_default_slot$y]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new TabsContent({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&7?get_spread_update(r,[a&1&&{class:cn("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",o[0])},a&2&&{value:o[1]},a&4&&get_spread_object(o[2])]):{};a&16&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$Q(c,e,n){const r=["class","value"];let i=compute_rest_props(e,r),{$$slots:o={},$$scope:a}=e,{class:d=void 0}=e,{value:f}=e;return c.$$set=h=>{e=assign(assign({},e),exclude_internal_props(h)),n(2,i=compute_rest_props(e,r)),"class"in h&&n(0,d=h.class),"value"in h&&n(1,f=h.value),"$$scope"in h&&n(4,a=h.$$scope)},[d,f,i,o,a]}class Tabs_content extends SvelteComponent{constructor(e){super(),init(this,e,instance$Q,create_fragment$N,safe_not_equal,{class:0,value:1})}}function create_default_slot$x(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$M(c){let e,n;const r=[{class:cn("inline-flex w-full h-10 items-center justify-center p-1 text-muted-foreground",c[0])},c[1]];let i={$$slots:{default:[create_default_slot$x]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new TabsList({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[a&1&&{class:cn("inline-flex w-full h-10 items-center justify-center p-1 text-muted-foreground",o[0])},a&2&&get_spread_object(o[1])]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$P(c,e,n){const r=["class"];let i=compute_rest_props(e,r),{$$slots:o={},$$scope:a}=e,{class:d=void 0}=e;return c.$$set=f=>{e=assign(assign({},e),exclude_internal_props(f)),n(1,i=compute_rest_props(e,r)),"class"in f&&n(0,d=f.class),"$$scope"in f&&n(3,a=f.$$scope)},[d,i,o,a]}class Tabs_list extends SvelteComponent{constructor(e){super(),init(this,e,instance$P,create_fragment$M,safe_not_equal,{class:0})}}function create_default_slot$w(c){let e;const n=c[3].default,r=create_slot(n,c,c[5],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&32)&&update_slot_base(r,n,i,i[5],e?get_slot_changes(n,i[5],o,null):get_all_dirty_from_scope(i[5]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$L(c){let e,n;const r=[{class:cn("inline-flex flex-grow items-center justify-center whitespace-nowrap uppercase font-light text-slate-800 px-3 pt-6 pb-2 ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border-transparent border-b-2 data-[state=active]:border-primary",c[0])},{value:c[1]},c[2]];let i={$$slots:{default:[create_default_slot$w]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new TabsTrigger({props:i}),e.$on("click",c[4]),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&7?get_spread_update(r,[a&1&&{class:cn("inline-flex flex-grow items-center justify-center whitespace-nowrap uppercase font-light text-slate-800 px-3 pt-6 pb-2 ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border-transparent border-b-2 data-[state=active]:border-primary",o[0])},a&2&&{value:o[1]},a&4&&get_spread_object(o[2])]):{};a&32&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$O(c,e,n){const r=["class","value"];let i=compute_rest_props(e,r),{$$slots:o={},$$scope:a}=e,{class:d=void 0}=e,{value:f}=e;function h(p){bubble.call(this,c,p)}return c.$$set=p=>{e=assign(assign({},e),exclude_internal_props(p)),n(2,i=compute_rest_props(e,r)),"class"in p&&n(0,d=p.class),"value"in p&&n(1,f=p.value),"$$scope"in p&&n(5,a=p.$$scope)},[d,f,i,o,h,a]}class Tabs_trigger extends SvelteComponent{constructor(e){super(),init(this,e,instance$O,create_fragment$L,safe_not_equal,{class:0,value:1})}}const Root$1=Tabs;function create_fragment$K(c){let e,n,r=[{class:n=cn("animate-pulse rounded-md bg-muted",c[0])},c[1]],i={};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return{c(){e=element("div"),this.h()},l(o){e=claim_element(o,"DIV",{class:!0}),children(e).forEach(detach),this.h()},h(){set_attributes(e,i)},m(o,a){insert_hydration(o,e,a)},p(o,[a]){set_attributes(e,i=get_spread_update(r,[a&1&&n!==(n=cn("animate-pulse rounded-md bg-muted",o[0]))&&{class:n},a&2&&o[1]]))},i:noop,o:noop,d(o){o&&detach(e)}}}function instance$N(c,e,n){const r=["class"];let i=compute_rest_props(e,r),{class:o=void 0}=e;return c.$$set=a=>{e=assign(assign({},e),exclude_internal_props(a)),n(1,i=compute_rest_props(e,r)),"class"in a&&n(0,o=a.class)},[o,i]}class Skeleton extends SvelteComponent{constructor(e){super(),init(this,e,instance$N,create_fragment$K,safe_not_equal,{class:0})}}function create_default_slot$v(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$J(c){let e,n;const r=[{name:"brush"},c[1],{iconNode:c[0]}];let i={$$slots:{default:[create_default_slot$v]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new Icon({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[r[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$M(c,e,n){let{$$slots:r={},$$scope:i}=e;const o=[["path",{d:"m9.06 11.9 8.07-8.06a2.85 2.85 0 1 1 4.03 4.03l-8.06 8.08"}],["path",{d:"M7.07 14.94c-1.66 0-3 1.35-3 3.02 0 1.33-2.5 1.52-2 2.02 1.08 1.1 2.49 2.02 4 2.02 2.2 0 4-1.8 4-4.04a3.01 3.01 0 0 0-3-3.02z"}]];return c.$$set=a=>{n(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&n(3,i=a.$$scope)},e=exclude_internal_props(e),[o,e,r,i]}class Brush extends SvelteComponent{constructor(e){super(),init(this,e,instance$M,create_fragment$J,safe_not_equal,{})}}function create_default_slot$u(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$I(c){let e,n;const r=[{name:"check-check"},c[1],{iconNode:c[0]}];let i={$$slots:{default:[create_default_slot$u]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new Icon({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[r[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$L(c,e,n){let{$$slots:r={},$$scope:i}=e;const o=[["path",{d:"M18 6 7 17l-5-5"}],["path",{d:"m22 10-7.5 7.5L13 16"}]];return c.$$set=a=>{n(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&n(3,i=a.$$scope)},e=exclude_internal_props(e),[o,e,r,i]}class Check_check extends SvelteComponent{constructor(e){super(),init(this,e,instance$L,create_fragment$I,safe_not_equal,{})}}function create_default_slot$t(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$H(c){let e,n;const r=[{name:"check"},c[1],{iconNode:c[0]}];let i={$$slots:{default:[create_default_slot$t]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new Icon({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[r[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$K(c,e,n){let{$$slots:r={},$$scope:i}=e;const o=[["path",{d:"M20 6 9 17l-5-5"}]];return c.$$set=a=>{n(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&n(3,i=a.$$scope)},e=exclude_internal_props(e),[o,e,r,i]}class Check extends SvelteComponent{constructor(e){super(),init(this,e,instance$K,create_fragment$H,safe_not_equal,{})}}function create_default_slot$s(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$G(c){let e,n;const r=[{name:"chevron-right"},c[1],{iconNode:c[0]}];let i={$$slots:{default:[create_default_slot$s]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new Icon({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[r[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$J(c,e,n){let{$$slots:r={},$$scope:i}=e;const o=[["path",{d:"m9 18 6-6-6-6"}]];return c.$$set=a=>{n(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&n(3,i=a.$$scope)},e=exclude_internal_props(e),[o,e,r,i]}class Chevron_right extends SvelteComponent{constructor(e){super(),init(this,e,instance$J,create_fragment$G,safe_not_equal,{})}}const ChevronRight=Chevron_right;function create_default_slot$r(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$F(c){let e,n;const r=[{name:"chevrons-up-down"},c[1],{iconNode:c[0]}];let i={$$slots:{default:[create_default_slot$r]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new Icon({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[r[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$I(c,e,n){let{$$slots:r={},$$scope:i}=e;const o=[["path",{d:"m7 15 5 5 5-5"}],["path",{d:"m7 9 5-5 5 5"}]];return c.$$set=a=>{n(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&n(3,i=a.$$scope)},e=exclude_internal_props(e),[o,e,r,i]}class Chevrons_up_down extends SvelteComponent{constructor(e){super(),init(this,e,instance$I,create_fragment$F,safe_not_equal,{})}}function create_default_slot$q(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$E(c){let e,n;const r=[{name:"eye-off"},c[1],{iconNode:c[0]}];let i={$$slots:{default:[create_default_slot$q]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new Icon({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[r[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$H(c,e,n){let{$$slots:r={},$$scope:i}=e;const o=[["path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24"}],["path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"}],["path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22"}]];return c.$$set=a=>{n(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&n(3,i=a.$$scope)},e=exclude_internal_props(e),[o,e,r,i]}class Eye_off extends SvelteComponent{constructor(e){super(),init(this,e,instance$H,create_fragment$E,safe_not_equal,{})}}function create_default_slot$p(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$D(c){let e,n;const r=[{name:"eye"},c[1],{iconNode:c[0]}];let i={$$slots:{default:[create_default_slot$p]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new Icon({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[r[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$G(c,e,n){let{$$slots:r={},$$scope:i}=e;const o=[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}],["circle",{cx:"12",cy:"12",r:"3"}]];return c.$$set=a=>{n(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&n(3,i=a.$$scope)},e=exclude_internal_props(e),[o,e,r,i]}class Eye extends SvelteComponent{constructor(e){super(),init(this,e,instance$G,create_fragment$D,safe_not_equal,{})}}function create_default_slot$o(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$C(c){let e,n;const r=[{name:"lock"},c[1],{iconNode:c[0]}];let i={$$slots:{default:[create_default_slot$o]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new Icon({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[r[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$F(c,e,n){let{$$slots:r={},$$scope:i}=e;const o=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}]];return c.$$set=a=>{n(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&n(3,i=a.$$scope)},e=exclude_internal_props(e),[o,e,r,i]}class Lock extends SvelteComponent{constructor(e){super(),init(this,e,instance$F,create_fragment$C,safe_not_equal,{})}}function create_default_slot$n(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$B(c){let e,n;const r=[{name:"minus-circle"},c[1],{iconNode:c[0]}];let i={$$slots:{default:[create_default_slot$n]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new Icon({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[r[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$E(c,e,n){let{$$slots:r={},$$scope:i}=e;const o=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M8 12h8"}]];return c.$$set=a=>{n(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&n(3,i=a.$$scope)},e=exclude_internal_props(e),[o,e,r,i]}class Minus_circle extends SvelteComponent{constructor(e){super(),init(this,e,instance$E,create_fragment$B,safe_not_equal,{})}}function create_default_slot$m(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$A(c){let e,n;const r=[{name:"minus"},c[1],{iconNode:c[0]}];let i={$$slots:{default:[create_default_slot$m]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new Icon({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[r[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$D(c,e,n){let{$$slots:r={},$$scope:i}=e;const o=[["path",{d:"M5 12h14"}]];return c.$$set=a=>{n(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&n(3,i=a.$$scope)},e=exclude_internal_props(e),[o,e,r,i]}class Minus extends SvelteComponent{constructor(e){super(),init(this,e,instance$D,create_fragment$A,safe_not_equal,{})}}function create_default_slot$l(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$z(c){let e,n;const r=[{name:"mouse-pointer"},c[1],{iconNode:c[0]}];let i={$$slots:{default:[create_default_slot$l]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new Icon({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[r[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$C(c,e,n){let{$$slots:r={},$$scope:i}=e;const o=[["path",{d:"m3 3 7.07 16.97 2.51-7.39 7.39-2.51L3 3z"}],["path",{d:"m13 13 6 6"}]];return c.$$set=a=>{n(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&n(3,i=a.$$scope)},e=exclude_internal_props(e),[o,e,r,i]}class Mouse_pointer extends SvelteComponent{constructor(e){super(),init(this,e,instance$C,create_fragment$z,safe_not_equal,{})}}function create_default_slot$k(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$y(c){let e,n;const r=[{name:"pencil"},c[1],{iconNode:c[0]}];let i={$$slots:{default:[create_default_slot$k]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new Icon({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[r[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$B(c,e,n){let{$$slots:r={},$$scope:i}=e;const o=[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}],["path",{d:"m15 5 4 4"}]];return c.$$set=a=>{n(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&n(3,i=a.$$scope)},e=exclude_internal_props(e),[o,e,r,i]}class Pencil extends SvelteComponent{constructor(e){super(),init(this,e,instance$B,create_fragment$y,safe_not_equal,{})}}function create_default_slot$j(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$x(c){let e,n;const r=[{name:"plus-circle"},c[1],{iconNode:c[0]}];let i={$$slots:{default:[create_default_slot$j]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new Icon({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[r[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$A(c,e,n){let{$$slots:r={},$$scope:i}=e;const o=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M8 12h8"}],["path",{d:"M12 8v8"}]];return c.$$set=a=>{n(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&n(3,i=a.$$scope)},e=exclude_internal_props(e),[o,e,r,i]}class Plus_circle extends SvelteComponent{constructor(e){super(),init(this,e,instance$A,create_fragment$x,safe_not_equal,{})}}function create_default_slot$i(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$w(c){let e,n;const r=[{name:"share-2"},c[1],{iconNode:c[0]}];let i={$$slots:{default:[create_default_slot$i]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new Icon({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[r[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$z(c,e,n){let{$$slots:r={},$$scope:i}=e;const o=[["circle",{cx:"18",cy:"5",r:"3"}],["circle",{cx:"6",cy:"12",r:"3"}],["circle",{cx:"18",cy:"19",r:"3"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49"}]];return c.$$set=a=>{n(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&n(3,i=a.$$scope)},e=exclude_internal_props(e),[o,e,r,i]}class Share_2 extends SvelteComponent{constructor(e){super(),init(this,e,instance$z,create_fragment$w,safe_not_equal,{})}}function create_default_slot$h(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$v(c){let e,n;const r=[{name:"square"},c[1],{iconNode:c[0]}];let i={$$slots:{default:[create_default_slot$h]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new Icon({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[r[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$y(c,e,n){let{$$slots:r={},$$scope:i}=e;const o=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}]];return c.$$set=a=>{n(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&n(3,i=a.$$scope)},e=exclude_internal_props(e),[o,e,r,i]}class Square extends SvelteComponent{constructor(e){super(),init(this,e,instance$y,create_fragment$v,safe_not_equal,{})}}function create_default_slot$g(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$u(c){let e,n;const r=[{name:"trash-2"},c[1],{iconNode:c[0]}];let i={$$slots:{default:[create_default_slot$g]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new Icon({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[r[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$x(c,e,n){let{$$slots:r={},$$scope:i}=e;const o=[["path",{d:"M3 6h18"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17"}]];return c.$$set=a=>{n(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&n(3,i=a.$$scope)},e=exclude_internal_props(e),[o,e,r,i]}class Trash_2 extends SvelteComponent{constructor(e){super(),init(this,e,instance$x,create_fragment$u,safe_not_equal,{})}}function create_if_block_1$c(c){let e,n;return e=new Minus({props:{class:"h-3.5 w-3.5"}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_if_block$k(c){let e,n;return e=new Check({props:{class:"h-3.5 w-3.5"}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_default_slot_1$8(c){let e,n,r,i;const o=[create_if_block$k,create_if_block_1$c],a=[];function d(f,h){return f[8]?0:f[9]?1:-1}return~(e=d(c))&&(n=a[e]=o[e](c)),{c(){n&&n.c(),r=empty()},l(f){n&&n.l(f),r=empty()},m(f,h){~e&&a[e].m(f,h),insert_hydration(f,r,h),i=!0},p(f,h){let p=e;e=d(f),e!==p&&(n&&(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros()),~e?(n=a[e],n||(n=a[e]=o[e](f),n.c()),transition_in(n,1),n.m(r.parentNode,r)):n=null)},i(f){i||(transition_in(n),i=!0)},o(f){transition_out(n),i=!1},d(f){f&&detach(r),~e&&a[e].d(f)}}}function create_default_slot$f(c){let e,n;return e=new CheckboxIndicator({props:{class:cn("flex items-center justify-center text-current h-4 w-4"),$$slots:{default:[create_default_slot_1$8,({isChecked:r,isIndeterminate:i})=>({8:r,9:i}),({isChecked:r,isIndeterminate:i})=>(r?256:0)|(i?512:0)]},$$scope:{ctx:c}}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p(r,i){const o={};i&1792&&(o.$$scope={dirty:i,ctx:r}),e.$set(o)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_fragment$t(c){let e,n,r;const i=[{class:cn("box-content peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary-light data-[state=checked]:text-primary-foreground data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50",c[1])},c[5],{disabled:c[2]}];function o(d){c[6](d)}let a={$$slots:{default:[create_default_slot$f]},$$scope:{ctx:c}};for(let d=0;d<i.length;d+=1)a=assign(a,i[d]);return c[0]!==void 0&&(a.checked=c[0]),e=new Checkbox$1({props:a}),binding_callbacks.push(()=>bind(e,"checked",o)),e.$on("click",c[7]),e.$on("keydown",c[4]),{c(){create_component(e.$$.fragment)},l(d){claim_component(e.$$.fragment,d)},m(d,f){mount_component(e,d,f),r=!0},p(d,[f]){const h=f&38?get_spread_update(i,[f&2&&{class:cn("box-content peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary-light data-[state=checked]:text-primary-foreground data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50",d[1])},f&32&&get_spread_object(d[5]),f&4&&{disabled:d[2]}]):{};f&1024&&(h.$$scope={dirty:f,ctx:d}),!n&&f&1&&(n=!0,h.checked=d[0],add_flush_callback(()=>n=!1)),e.$set(h)},i(d){r||(transition_in(e.$$.fragment,d),r=!0)},o(d){transition_out(e.$$.fragment,d),r=!1},d(d){destroy_component(e,d)}}}function instance$w(c,e,n){const r=["class","disabled","checked","handleClick"];let i=compute_rest_props(e,r),{class:o=void 0}=e,{disabled:a=!1}=e,{checked:d=!1}=e,{handleClick:f=()=>{}}=e;const h=t=>{t.detail.originalEvent.key==="Enter"&&(f(!d),n(0,d=!d))};function p(t){d=t,n(0,d)}const s=()=>f(!d);return c.$$set=t=>{e=assign(assign({},e),exclude_internal_props(t)),n(5,i=compute_rest_props(e,r)),"class"in t&&n(1,o=t.class),"disabled"in t&&n(2,a=t.disabled),"checked"in t&&n(0,d=t.checked),"handleClick"in t&&n(3,f=t.handleClick)},[d,o,a,f,h,i,p,s]}class Checkbox extends SvelteComponent{constructor(e){super(),init(this,e,instance$w,create_fragment$t,safe_not_equal,{class:1,disabled:2,checked:0,handleClick:3})}}function styleToString(c){return Object.keys(c).reduce((e,n)=>c[n]===void 0?e:e+`${n}:${c[n]};`,"")}const srOnlyStyles={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function addEventListener(c,e,n,r){const i=Array.isArray(e)?e:[e];return i.forEach(o=>c.addEventListener(o,n,r)),()=>{i.forEach(o=>c.removeEventListener(o,n,r))}}function executeCallbacks(...c){return(...e)=>{for(const n of c)typeof n=="function"&&n(...e)}}const get_default_slot_spread_changes_1=c=>c&4,get_default_slot_changes_1$2=c=>({}),get_default_slot_context_1$2=c=>({...c[2]}),get_default_slot_spread_changes=c=>c&4,get_default_slot_changes$2=c=>({}),get_default_slot_context$2=c=>({...c[2]});function create_else_block$7(c){let e,n,r=(c[0]??"")+"",i,o,a,d,f,h=[c[6]],p={};for(let g=0;g<h.length;g+=1)p=assign(p,h[g]);const s=c[18].default,t=create_slot(s,c,c[17],get_default_slot_context_1$2);let l=[c[5],c[7]],u={};for(let g=0;g<l.length;g+=1)u=assign(u,l[g]);return{c(){e=element("div"),n=element("label"),i=text(r),o=space(),t&&t.c(),this.h()},l(g){e=claim_element(g,"DIV",{});var m=children(e);n=claim_element(m,"LABEL",{});var _=children(n);i=claim_text(_,r),_.forEach(detach),o=claim_space(m),t&&t.l(m),m.forEach(detach),this.h()},h(){set_attributes(n,p),set_attributes(e,u)},m(g,m){insert_hydration(g,e,m),append_hydration(e,n),append_hydration(n,i),append_hydration(e,o),t&&t.m(e,null),a=!0,d||(f=action_destroyer(c[4].call(null,e)),d=!0)},p(g,m){(!a||m&1)&&r!==(r=(g[0]??"")+"")&&set_data_maybe_contenteditable(i,r,p.contenteditable),t&&t.p&&(!a||m&131076)&&update_slot_base(t,s,g,g[17],get_default_slot_spread_changes_1(m)||!a?get_all_dirty_from_scope(g[17]):get_slot_changes(s,g[17],m,get_default_slot_changes_1$2),get_default_slot_context_1$2),set_attributes(e,u=get_spread_update(l,[g[5],m&128&&g[7]]))},i(g){a||(transition_in(t,g),a=!0)},o(g){transition_out(t,g),a=!1},d(g){g&&detach(e),t&&t.d(g),d=!1,f()}}}function create_if_block$j(c){let e;const n=c[18].default,r=create_slot(n,c,c[17],get_default_slot_context$2);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&131076)&&update_slot_base(r,n,i,i[17],get_default_slot_spread_changes(o)||!e?get_all_dirty_from_scope(i[17]):get_slot_changes(n,i[17],o,get_default_slot_changes$2),get_default_slot_context$2)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$s(c){let e,n,r,i;const o=[create_if_block$j,create_else_block$7],a=[];function d(f,h){return f[1]?0:1}return e=d(c),n=a[e]=o[e](c),{c(){n.c(),r=empty()},l(f){n.l(f),r=empty()},m(f,h){a[e].m(f,h),insert_hydration(f,r,h),i=!0},p(f,[h]){let p=e;e=d(f),e===p?a[e].p(f,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),n=a[e],n?n.p(f,h):(n=a[e]=o[e](f),n.c()),transition_in(n,1),n.m(r.parentNode,r))},i(f){i||(transition_in(n),i=!0)},o(f){transition_out(n),i=!1},d(f){f&&detach(r),a[e].d(f)}}}function instance$v(c,e,n){let r;const i=["label","shouldFilter","filter","value","onValueChange","loop","onKeydown","state","ids","asChild"];let o=compute_rest_props(e,i),a,{$$slots:d={},$$scope:f}=e,{label:h=void 0}=e,{shouldFilter:p=!0}=e,{filter:s=void 0}=e,{value:t=void 0}=e,{onValueChange:l=void 0}=e,{loop:u=void 0}=e,{onKeydown:g=void 0}=e,{state:m=void 0}=e,{ids:_=void 0}=e,{asChild:b=!1}=e;const{commandEl:y,handleRootKeydown:v,ids:T,state:w}=createCommand({label:h,shouldFilter:p,filter:s,value:t,onValueChange:E=>{E!==t&&(n(8,t=E),l==null||l(E))},loop:u,state:m,ids:_});component_subscribe(c,w,E=>n(16,a=E));function S(E){E&&E!==a.value&&set_store_value(w,a.value=E,a)}function x(E){return y.set(E),{destroy:executeCallbacks(addEventListener(E,"keydown",N))}}const P={role:"application",id:T.root,"data-cmdk-root":""},I={"data-cmdk-label":"",for:T.input,id:T.label,style:styleToString(srOnlyStyles)};function N(E){g==null||g(E),!E.defaultPrevented&&v(E)}const L={action:x,attrs:P};return c.$$set=E=>{e=assign(assign({},e),exclude_internal_props(E)),n(7,o=compute_rest_props(e,i)),"label"in E&&n(0,h=E.label),"shouldFilter"in E&&n(9,p=E.shouldFilter),"filter"in E&&n(10,s=E.filter),"value"in E&&n(8,t=E.value),"onValueChange"in E&&n(11,l=E.onValueChange),"loop"in E&&n(12,u=E.loop),"onKeydown"in E&&n(13,g=E.onKeydown),"state"in E&&n(14,m=E.state),"ids"in E&&n(15,_=E.ids),"asChild"in E&&n(1,b=E.asChild),"$$scope"in E&&n(17,f=E.$$scope)},c.$$.update=()=>{c.$$.dirty&256&&S(t),c.$$.dirty&65536&&n(2,r={root:L,label:{attrs:I},stateStore:w,state:a})},[h,b,r,w,x,P,I,o,t,p,s,l,u,g,m,_,a,f,d]}let Command$1=class extends SvelteComponent{constructor(e){super(),init(this,e,instance$v,create_fragment$s,safe_not_equal,{label:0,shouldFilter:9,filter:10,value:8,onValueChange:11,loop:12,onKeydown:13,state:14,ids:15,asChild:1})}};const get_default_slot_changes_1$1=c=>({container:c&32,group:c&16}),get_default_slot_context_1$1=c=>({container:c[5],group:c[4],heading:{attrs:c[8]}}),get_default_slot_changes$1=c=>({container:c&32,group:c&16}),get_default_slot_context$1=c=>({container:c[5],group:c[4],heading:{attrs:c[8]}});function create_else_block$6(c){let e,n,r,i,o,a,d=c[0]&&create_if_block_1$b(c);const f=c[14].default,h=create_slot(f,c,c[13],get_default_slot_context_1$1);let p=[c[2]],s={};for(let u=0;u<p.length;u+=1)s=assign(s,p[u]);let t=[c[3],c[9]],l={};for(let u=0;u<t.length;u+=1)l=assign(l,t[u]);return{c(){e=element("div"),d&&d.c(),n=space(),r=element("div"),h&&h.c(),this.h()},l(u){e=claim_element(u,"DIV",{});var g=children(e);d&&d.l(g),n=claim_space(g),r=claim_element(g,"DIV",{});var m=children(r);h&&h.l(m),m.forEach(detach),g.forEach(detach),this.h()},h(){set_attributes(r,s),set_attributes(e,l)},m(u,g){insert_hydration(u,e,g),d&&d.m(e,null),append_hydration(e,n),append_hydration(e,r),h&&h.m(r,null),i=!0,o||(a=action_destroyer(c[7].call(null,e)),o=!0)},p(u,g){u[0]?d?d.p(u,g):(d=create_if_block_1$b(u),d.c(),d.m(e,n)):d&&(d.d(1),d=null),h&&h.p&&(!i||g&8240)&&update_slot_base(h,f,u,u[13],i?get_slot_changes(f,u[13],g,get_default_slot_changes_1$1):get_all_dirty_from_scope(u[13]),get_default_slot_context_1$1),set_attributes(r,s=get_spread_update(p,[g&4&&u[2]])),set_attributes(e,l=get_spread_update(t,[g&8&&u[3],g&512&&u[9]]))},i(u){i||(transition_in(h,u),i=!0)},o(u){transition_out(h,u),i=!1},d(u){u&&detach(e),d&&d.d(),h&&h.d(u),o=!1,a()}}}function create_if_block$i(c){let e;const n=c[14].default,r=create_slot(n,c,c[13],get_default_slot_context$1);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8240)&&update_slot_base(r,n,i,i[13],e?get_slot_changes(n,i[13],o,get_default_slot_changes$1):get_all_dirty_from_scope(i[13]),get_default_slot_context$1)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_if_block_1$b(c){let e,n,r=[c[8]],i={};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return{c(){e=element("div"),n=text(c[0]),this.h()},l(o){e=claim_element(o,"DIV",{});var a=children(e);n=claim_text(a,c[0]),a.forEach(detach),this.h()},h(){set_attributes(e,i)},m(o,a){insert_hydration(o,e,a),append_hydration(e,n)},p(o,a){a&1&&set_data_maybe_contenteditable(n,o[0],i.contenteditable)},d(o){o&&detach(e)}}}function create_fragment$r(c){let e,n,r,i;const o=[create_if_block$i,create_else_block$6],a=[];function d(f,h){return f[1]?0:1}return e=d(c),n=a[e]=o[e](c),{c(){n.c(),r=empty()},l(f){n.l(f),r=empty()},m(f,h){a[e].m(f,h),insert_hydration(f,r,h),i=!0},p(f,[h]){let p=e;e=d(f),e===p?a[e].p(f,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),n=a[e],n?n.p(f,h):(n=a[e]=o[e](f),n.c()),transition_in(n,1),n.m(r.parentNode,r))},i(f){i||(transition_in(n),i=!0)},o(f){transition_out(n),i=!1},d(f){f&&detach(r),a[e].d(f)}}}function instance$u(c,e,n){let r,i,o,a;const d=["heading","value","alwaysRender","asChild"];let f=compute_rest_props(e,d),h,{$$slots:p={},$$scope:s}=e,{heading:t=void 0}=e,{value:l=""}=e,{alwaysRender:u=!1}=e,{asChild:g=!1}=e;const{id:m}=createGroup(u),_=getCtx$3(),b=getState(),y=generateId(),v=derived(b,S=>u||_.filter()===!1||!S.search?!0:S.filtered.groups.has(m));component_subscribe(c,v,S=>n(12,h=S)),onMount(()=>_.group(m));function T(S){if(l){_.value(m,l),S.setAttribute(VALUE_ATTR,l);return}t?n(10,l=t.trim().toLowerCase()):S.textContent&&n(10,l=S.textContent.trim().toLowerCase()),_.value(m,l),S.setAttribute(VALUE_ATTR,l)}const w={"data-cmdk-group-heading":"","aria-hidden":!0,id:y};return c.$$set=S=>{e=assign(assign({},e),exclude_internal_props(S)),n(9,f=compute_rest_props(e,d)),"heading"in S&&n(0,t=S.heading),"value"in S&&n(10,l=S.value),"alwaysRender"in S&&n(11,u=S.alwaysRender),"asChild"in S&&n(1,g=S.asChild),"$$scope"in S&&n(13,s=S.$$scope)},c.$$.update=()=>{c.$$.dirty&5120&&n(3,r={"data-cmdk-group":"",role:"presentation",hidden:h?void 0:!0,"data-value":l}),c.$$.dirty&1&&n(2,i={"data-cmdk-group-items":"",role:"group","aria-labelledby":t?y:void 0}),c.$$.dirty&8&&n(5,o={action:T,attrs:r}),c.$$.dirty&4&&n(4,a={attrs:i})},[t,g,i,r,a,o,v,T,w,f,l,u,h,s,p]}class CommandGroup extends SvelteComponent{constructor(e){super(),init(this,e,instance$u,create_fragment$r,safe_not_equal,{heading:0,value:10,alwaysRender:11,asChild:1})}}const get_default_slot_changes_1=c=>({attrs:c&4}),get_default_slot_context_1=c=>({action:c[6],attrs:c[2]}),get_default_slot_changes=c=>({attrs:c&4}),get_default_slot_context=c=>({action:c[6],attrs:c[2]});function create_if_block$h(c){let e,n,r,i;const o=[create_if_block_1$a,create_else_block$5],a=[];function d(f,h){return f[0]?0:1}return e=d(c),n=a[e]=o[e](c),{c(){n.c(),r=empty()},l(f){n.l(f),r=empty()},m(f,h){a[e].m(f,h),insert_hydration(f,r,h),i=!0},p(f,h){let p=e;e=d(f),e===p?a[e].p(f,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),n=a[e],n?n.p(f,h):(n=a[e]=o[e](f),n.c()),transition_in(n,1),n.m(r.parentNode,r))},i(f){i||(transition_in(n),i=!0)},o(f){transition_out(n),i=!1},d(f){f&&detach(r),a[e].d(f)}}}function create_else_block$5(c){let e,n,r,i;const o=c[15].default,a=create_slot(o,c,c[14],get_default_slot_context_1);let d=[c[2],c[7]],f={};for(let h=0;h<d.length;h+=1)f=assign(f,d[h]);return{c(){e=element("div"),a&&a.c(),this.h()},l(h){e=claim_element(h,"DIV",{});var p=children(e);a&&a.l(p),p.forEach(detach),this.h()},h(){set_attributes(e,f)},m(h,p){insert_hydration(h,e,p),a&&a.m(e,null),n=!0,r||(i=action_destroyer(c[6].call(null,e)),r=!0)},p(h,p){a&&a.p&&(!n||p&16388)&&update_slot_base(a,o,h,h[14],n?get_slot_changes(o,h[14],p,get_default_slot_changes_1):get_all_dirty_from_scope(h[14]),get_default_slot_context_1),set_attributes(e,f=get_spread_update(d,[p&4&&h[2],p&128&&h[7]]))},i(h){n||(transition_in(a,h),n=!0)},o(h){transition_out(a,h),n=!1},d(h){h&&detach(e),a&&a.d(h),r=!1,i()}}}function create_if_block_1$a(c){let e;const n=c[15].default,r=create_slot(n,c,c[14],get_default_slot_context);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&16388)&&update_slot_base(r,n,i,i[14],e?get_slot_changes(n,i[14],o,get_default_slot_changes):get_all_dirty_from_scope(i[14]),get_default_slot_context)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$q(c){let e,n,r=(c[3]||c[1])&&create_if_block$h(c);return{c(){r&&r.c(),e=empty()},l(i){r&&r.l(i),e=empty()},m(i,o){r&&r.m(i,o),insert_hydration(i,e,o),n=!0},p(i,[o]){i[3]||i[1]?r?(r.p(i,o),o&10&&transition_in(r,1)):(r=create_if_block$h(i),r.c(),transition_in(r,1),r.m(e.parentNode,e)):r&&(group_outros(),transition_out(r,1,1,()=>{r=null}),check_outros())},i(i){n||(transition_in(r),n=!0)},o(i){transition_out(r),n=!1},d(i){i&&detach(e),r&&r.d(i)}}}function instance$t(c,e,n){let r;const i=["disabled","value","onSelect","alwaysRender","asChild","id"];let o=compute_rest_props(e,i),a,d,{$$slots:f={},$$scope:h}=e,{disabled:p=!1}=e,{value:s=""}=e,{onSelect:t=void 0}=e,{alwaysRender:l=!1}=e,{asChild:u=!1}=e,{id:g=generateId()}=e;const m=getGroup(),_=getCtx$3(),b=getState(),y=l??(m==null?void 0:m.alwaysRender),v=derived(b,I=>{if(y||_.filter()===!1||!I.search)return!0;const N=I.filtered.items.get(g);return isUndefined(N)?!1:N>0});component_subscribe(c,v,I=>n(3,d=I));let T=!0;onMount(()=>(n(1,T=!1),_.item(g,m==null?void 0:m.id)));const w=derived(b,I=>I.value===s);component_subscribe(c,w,I=>n(13,a=I));function S(I){!s&&I.textContent&&n(8,s=I.textContent.trim().toLowerCase()),_.value(g,s),I.setAttribute(VALUE_ATTR,s);const N=executeCallbacks(addEventListener(I,"pointermove",()=>{p||P()}),addEventListener(I,"click",()=>{p||x()}));return{destroy(){N()}}}function x(){P(),t==null||t(s)}function P(){b.updateState("value",s,!0)}return c.$$set=I=>{e=assign(assign({},e),exclude_internal_props(I)),n(7,o=compute_rest_props(e,i)),"disabled"in I&&n(9,p=I.disabled),"value"in I&&n(8,s=I.value),"onSelect"in I&&n(10,t=I.onSelect),"alwaysRender"in I&&n(11,l=I.alwaysRender),"asChild"in I&&n(0,u=I.asChild),"id"in I&&n(12,g=I.id),"$$scope"in I&&n(14,h=I.$$scope)},c.$$.update=()=>{c.$$.dirty&13056&&n(2,r={"aria-disabled":p?!0:void 0,"aria-selected":a?!0:void 0,"data-disabled":p?!0:void 0,"data-selected":a?!0:void 0,"data-cmdk-item":"","data-value":s,role:"option",id:g})},[u,T,r,d,v,w,S,o,s,p,t,l,g,a,h,f]}class CommandItem extends SvelteComponent{constructor(e){super(),init(this,e,instance$t,create_fragment$q,safe_not_equal,{disabled:9,value:8,onSelect:10,alwaysRender:11,asChild:0,id:12})}}function create_default_slot$e(c){let e;const n=c[3].default,r=create_slot(n,c,c[5],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&32)&&update_slot_base(r,n,i,i[5],e?get_slot_changes(n,i[5],o,null):get_all_dirty_from_scope(i[5]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$p(c){let e,n,r;const i=[{class:cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",c[1])},c[2]];function o(d){c[4](d)}let a={$$slots:{default:[create_default_slot$e]},$$scope:{ctx:c}};for(let d=0;d<i.length;d+=1)a=assign(a,i[d]);return c[0]!==void 0&&(a.value=c[0]),e=new Command$1({props:a}),binding_callbacks.push(()=>bind(e,"value",o)),{c(){create_component(e.$$.fragment)},l(d){claim_component(e.$$.fragment,d)},m(d,f){mount_component(e,d,f),r=!0},p(d,[f]){const h=f&6?get_spread_update(i,[f&2&&{class:cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",d[1])},f&4&&get_spread_object(d[2])]):{};f&32&&(h.$$scope={dirty:f,ctx:d}),!n&&f&1&&(n=!0,h.value=d[0],add_flush_callback(()=>n=!1)),e.$set(h)},i(d){r||(transition_in(e.$$.fragment,d),r=!0)},o(d){transition_out(e.$$.fragment,d),r=!1},d(d){destroy_component(e,d)}}}function instance$s(c,e,n){const r=["value","class"];let i=compute_rest_props(e,r),{$$slots:o={},$$scope:a}=e,{value:d=void 0}=e,{class:f=void 0}=e;function h(p){d=p,n(0,d)}return c.$$set=p=>{e=assign(assign({},e),exclude_internal_props(p)),n(2,i=compute_rest_props(e,r)),"value"in p&&n(0,d=p.value),"class"in p&&n(1,f=p.class),"$$scope"in p&&n(5,a=p.$$scope)},[d,f,i,o,h,a]}class Command extends SvelteComponent{constructor(e){super(),init(this,e,instance$s,create_fragment$p,safe_not_equal,{value:0,class:1})}}function create_default_slot$d(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$o(c){let e,n;const r=[{class:cn("overflow-hidden p-1 text-foreground [&_[data-cmdk-group-heading]]:px-2 [&_[data-cmdk-group-heading]]:py-1.5 [&_[data-cmdk-group-heading]]:text-xs [&_[data-cmdk-group-heading]]:font-medium [&_[data-cmdk-group-heading]]:text-muted-foreground",c[0])},c[1]];let i={$$slots:{default:[create_default_slot$d]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new CommandGroup({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[a&1&&{class:cn("overflow-hidden p-1 text-foreground [&_[data-cmdk-group-heading]]:px-2 [&_[data-cmdk-group-heading]]:py-1.5 [&_[data-cmdk-group-heading]]:text-xs [&_[data-cmdk-group-heading]]:font-medium [&_[data-cmdk-group-heading]]:text-muted-foreground",o[0])},a&2&&get_spread_object(o[1])]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$r(c,e,n){const r=["class"];let i=compute_rest_props(e,r),{$$slots:o={},$$scope:a}=e,{class:d=void 0}=e;return c.$$set=f=>{e=assign(assign({},e),exclude_internal_props(f)),n(1,i=compute_rest_props(e,r)),"class"in f&&n(0,d=f.class),"$$scope"in f&&n(3,a=f.$$scope)},[d,i,o,a]}class Command_group extends SvelteComponent{constructor(e){super(),init(this,e,instance$r,create_fragment$o,safe_not_equal,{class:0})}}function create_default_slot$c(c){let e;const n=c[2].default,r=create_slot(n,c,c[3],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&8)&&update_slot_base(r,n,i,i[3],e?get_slot_changes(n,i[3],o,null):get_all_dirty_from_scope(i[3]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$n(c){let e,n;const r=[{class:cn("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",c[0])},c[1]];let i={$$slots:{default:[create_default_slot$c]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new CommandItem({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&3?get_spread_update(r,[a&1&&{class:cn("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",o[0])},a&2&&get_spread_object(o[1])]):{};a&8&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$q(c,e,n){const r=["class"];let i=compute_rest_props(e,r),{$$slots:o={},$$scope:a}=e,{class:d=void 0}=e;return c.$$set=f=>{e=assign(assign({},e),exclude_internal_props(f)),n(1,i=compute_rest_props(e,r)),"class"in f&&n(0,d=f.class),"$$scope"in f&&n(3,a=f.$$scope)},[d,i,o,a]}class Command_item extends SvelteComponent{constructor(e){super(),init(this,e,instance$q,create_fragment$n,safe_not_equal,{class:0})}}function create_default_slot$b(c){let e;const n=c[4].default,r=create_slot(n,c,c[5],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&32)&&update_slot_base(r,n,i,i[5],e?get_slot_changes(n,i[5],o,null):get_all_dirty_from_scope(i[5]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$m(c){let e,n;const r=[{transition:c[1]},{transitionConfig:c[2]},{class:cn("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none",c[0])},c[3]];let i={$$slots:{default:[create_default_slot$b]},$$scope:{ctx:c}};for(let o=0;o<r.length;o+=1)i=assign(i,r[o]);return e=new PopoverContent({props:i}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),n=!0},p(o,[a]){const d=a&15?get_spread_update(r,[a&2&&{transition:o[1]},a&4&&{transitionConfig:o[2]},a&1&&{class:cn("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none",o[0])},a&8&&get_spread_object(o[3])]):{};a&32&&(d.$$scope={dirty:a,ctx:o}),e.$set(d)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$p(c,e,n){const r=["class","transition","transitionConfig"];let i=compute_rest_props(e,r),{$$slots:o={},$$scope:a}=e,{class:d=void 0}=e,{transition:f=flyAndScale}=e,{transitionConfig:h=void 0}=e;return c.$$set=p=>{e=assign(assign({},e),exclude_internal_props(p)),n(3,i=compute_rest_props(e,r)),"class"in p&&n(0,d=p.class),"transition"in p&&n(1,f=p.transition),"transitionConfig"in p&&n(2,h=p.transitionConfig),"$$scope"in p&&n(5,a=p.$$scope)},[d,f,h,i,o,a]}class Popover_content extends SvelteComponent{constructor(e){super(),init(this,e,instance$p,create_fragment$m,safe_not_equal,{class:0,transition:1,transitionConfig:2})}}const Root=Popover,Trigger=PopoverTrigger;function get_each_context$6(c,e,n){const r=c.slice();return r[10]=e[n],r}function create_default_slot_6(c){let e,n,r,i;return r=new Chevrons_up_down({props:{class:"ml-2 h-4 w-4 shrink-0 opacity-50"}}),{c(){e=text(c[3]),n=space(),create_component(r.$$.fragment)},l(o){e=claim_text(o,c[3]),n=claim_space(o),claim_component(r.$$.fragment,o)},m(o,a){insert_hydration(o,e,a),insert_hydration(o,n,a),mount_component(r,o,a),i=!0},p(o,a){(!i||a&8)&&set_data(e,o[3])},i(o){i||(transition_in(r.$$.fragment,o),i=!0)},o(o){transition_out(r.$$.fragment,o),i=!1},d(o){o&&(detach(e),detach(n)),destroy_component(r,o)}}}function create_default_slot_5$2(c){let e,n;return e=new Button({props:{builders:[c[13]],variant:"outline",role:"combobox","aria-expanded":c[2],class:"w-[200px] justify-between",$$slots:{default:[create_default_slot_6]},$$scope:{ctx:c}}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p(r,i){const o={};i&8192&&(o.builders=[r[13]]),i&4&&(o["aria-expanded"]=r[2]),i&16392&&(o.$$scope={dirty:i,ctx:r}),e.$set(o)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_default_slot_4$3(c){let e,n,r=c[10].label+"",i,o,a;return e=new Check({props:{class:cn("mr-2 h-4 w-4",c[0]!==c[10].value&&"text-transparent")}}),{c(){create_component(e.$$.fragment),n=space(),i=text(r),o=space()},l(d){claim_component(e.$$.fragment,d),n=claim_space(d),i=claim_text(d,r),o=claim_space(d)},m(d,f){mount_component(e,d,f),insert_hydration(d,n,f),insert_hydration(d,i,f),insert_hydration(d,o,f),a=!0},p(d,f){const h={};f&3&&(h.class=cn("mr-2 h-4 w-4",d[0]!==d[10].value&&"text-transparent")),e.$set(h),(!a||f&2)&&r!==(r=d[10].label+"")&&set_data(i,r)},i(d){a||(transition_in(e.$$.fragment,d),a=!0)},o(d){transition_out(e.$$.fragment,d),a=!1},d(d){d&&(detach(n),detach(i),detach(o)),destroy_component(e,d)}}}function create_each_block$6(c){let e,n;function r(...i){return c[7](c[9],...i)}return e=new Command_item({props:{value:c[10].value,onSelect:r,$$slots:{default:[create_default_slot_4$3]},$$scope:{ctx:c}}}),{c(){create_component(e.$$.fragment)},l(i){claim_component(e.$$.fragment,i)},m(i,o){mount_component(e,i,o),n=!0},p(i,o){c=i;const a={};o&2&&(a.value=c[10].value),o&513&&(a.onSelect=r),o&16387&&(a.$$scope={dirty:o,ctx:c}),e.$set(a)},i(i){n||(transition_in(e.$$.fragment,i),n=!0)},o(i){transition_out(e.$$.fragment,i),n=!1},d(i){destroy_component(e,i)}}}function create_default_slot_3$3(c){let e,n,r=ensure_array_like(c[1]),i=[];for(let a=0;a<r.length;a+=1)i[a]=create_each_block$6(get_each_context$6(c,r,a));const o=a=>transition_out(i[a],1,1,()=>{i[a]=null});return{c(){for(let a=0;a<i.length;a+=1)i[a].c();e=empty()},l(a){for(let d=0;d<i.length;d+=1)i[d].l(a);e=empty()},m(a,d){for(let f=0;f<i.length;f+=1)i[f]&&i[f].m(a,d);insert_hydration(a,e,d),n=!0},p(a,d){if(d&531){r=ensure_array_like(a[1]);let f;for(f=0;f<r.length;f+=1){const h=get_each_context$6(a,r,f);i[f]?(i[f].p(h,d),transition_in(i[f],1)):(i[f]=create_each_block$6(h),i[f].c(),transition_in(i[f],1),i[f].m(e.parentNode,e))}for(group_outros(),f=r.length;f<i.length;f+=1)o(f);check_outros()}},i(a){if(!n){for(let d=0;d<r.length;d+=1)transition_in(i[d]);n=!0}},o(a){i=i.filter(Boolean);for(let d=0;d<i.length;d+=1)transition_out(i[d]);n=!1},d(a){a&&detach(e),destroy_each(i,a)}}}function create_default_slot_2$4(c){let e,n;return e=new Command_group({props:{$$slots:{default:[create_default_slot_3$3]},$$scope:{ctx:c}}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p(r,i){const o={};i&16899&&(o.$$scope={dirty:i,ctx:r}),e.$set(o)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_default_slot_1$7(c){let e,n;return e=new Command({props:{$$slots:{default:[create_default_slot_2$4]},$$scope:{ctx:c}}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p(r,i){const o={};i&16899&&(o.$$scope={dirty:i,ctx:r}),e.$set(o)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_default_slot$a(c){let e,n,r,i;return e=new Trigger({props:{asChild:!0,$$slots:{default:[create_default_slot_5$2,({builder:o})=>({13:o}),({builder:o})=>o?8192:0]},$$scope:{ctx:c}}}),r=new Popover_content({props:{class:"w-[200px] p-0",$$slots:{default:[create_default_slot_1$7]},$$scope:{ctx:c}}}),{c(){create_component(e.$$.fragment),n=space(),create_component(r.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(r.$$.fragment,o)},m(o,a){mount_component(e,o,a),insert_hydration(o,n,a),mount_component(r,o,a),i=!0},p(o,a){const d={};a&24588&&(d.$$scope={dirty:a,ctx:o}),e.$set(d);const f={};a&16899&&(f.$$scope={dirty:a,ctx:o}),r.$set(f)},i(o){i||(transition_in(e.$$.fragment,o),transition_in(r.$$.fragment,o),i=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(r.$$.fragment,o),i=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(r,o)}}}function create_fragment$l(c){let e,n,r;function i(a){c[8](a)}let o={$$slots:{default:[create_default_slot$a,({ids:a})=>({9:a}),({ids:a})=>a?512:0]},$$scope:{ctx:c}};return c[2]!==void 0&&(o.open=c[2]),e=new Root({props:o}),binding_callbacks.push(()=>bind(e,"open",i)),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,d){mount_component(e,a,d),r=!0},p(a,[d]){const f={};d&16911&&(f.$$scope={dirty:d,ctx:a}),!n&&d&4&&(n=!0,f.open=a[2],add_flush_callback(()=>n=!1)),e.$set(f)},i(a){r||(transition_in(e.$$.fragment,a),r=!0)},o(a){transition_out(e.$$.fragment,a),r=!1},d(a){destroy_component(e,a)}}}function instance$o(c,e,n){let r,{listItems:i=[]}=e,{placeholder:o="Select an item"}=e,a=!1,{value:d=""}=e,{saveValue:f=()=>{}}=e;function h(t){n(2,a=!1),tick().then(()=>{var l;(l=document.getElementById(t))==null||l.focus()},()=>{})}const p=(t,l)=>{n(0,d=l),h(t.trigger)};function s(t){a=t,n(2,a)}return c.$$set=t=>{"listItems"in t&&n(1,i=t.listItems),"placeholder"in t&&n(5,o=t.placeholder),"value"in t&&n(0,d=t.value),"saveValue"in t&&n(6,f=t.saveValue)},c.$$.update=()=>{var t;c.$$.dirty&35&&n(3,r=((t=i.find(l=>l.value===d))==null?void 0:t.label)??o),c.$$.dirty&65&&d&&f(d)},[d,i,a,r,h,o,f,p,s]}class Combobox extends SvelteComponent{constructor(e){super(),init(this,e,instance$o,create_fragment$l,safe_not_equal,{listItems:1,placeholder:5,value:0,saveValue:6})}}function create_fragment$k(c){let e,n,r,i,o,a,d,f;const h=c[4].default,p=create_slot(h,c,c[3],null);let s=[{class:i=cn("w-full p-2 placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",c[1])},c[2]],t={};for(let l=0;l<s.length;l+=1)t=assign(t,s[l]);return{c(){e=element("div"),p&&p.c(),n=space(),r=element("input"),this.h()},l(l){e=claim_element(l,"DIV",{class:!0});var u=children(e);p&&p.l(u),n=claim_space(u),r=claim_element(u,"INPUT",{class:!0}),u.forEach(detach),this.h()},h(){set_attributes(r,t),attr(e,"class",o=cn("flex h-10 items-center rounded-md border border-input bg-white pl-3 text-sm ring-offset-background focus-within:ring-1 focus-within:ring-ring focus-within:ring-offset-2",c[1]))},m(l,u){insert_hydration(l,e,u),p&&p.m(e,null),append_hydration(e,n),append_hydration(e,r),r.autofocus&&r.focus(),set_input_value(r,c[0]),a=!0,d||(f=[listen(r,"input",c[17]),listen(r,"blur",c[5]),listen(r,"change",c[6]),listen(r,"click",c[7]),listen(r,"focus",c[8]),listen(r,"keydown",c[9]),listen(r,"keypress",c[10]),listen(r,"keyup",c[11]),listen(r,"mouseover",c[12]),listen(r,"mouseenter",c[13]),listen(r,"mouseleave",c[14]),listen(r,"paste",c[15]),listen(r,"input",c[16])],d=!0)},p(l,[u]){p&&p.p&&(!a||u&8)&&update_slot_base(p,h,l,l[3],a?get_slot_changes(h,l[3],u,null):get_all_dirty_from_scope(l[3]),null),set_attributes(r,t=get_spread_update(s,[(!a||u&2&&i!==(i=cn("w-full p-2 placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",l[1])))&&{class:i},u&4&&l[2]])),u&1&&r.value!==l[0]&&set_input_value(r,l[0]),(!a||u&2&&o!==(o=cn("flex h-10 items-center rounded-md border border-input bg-white pl-3 text-sm ring-offset-background focus-within:ring-1 focus-within:ring-ring focus-within:ring-offset-2",l[1])))&&attr(e,"class",o)},i(l){a||(transition_in(p,l),a=!0)},o(l){transition_out(p,l),a=!1},d(l){l&&detach(e),p&&p.d(l),d=!1,run_all(f)}}}function instance$n(c,e,n){const r=["class","value"];let i=compute_rest_props(e,r),{$$slots:o={},$$scope:a}=e,{class:d=void 0}=e,{value:f=void 0}=e;function h(w){bubble.call(this,c,w)}function p(w){bubble.call(this,c,w)}function s(w){bubble.call(this,c,w)}function t(w){bubble.call(this,c,w)}function l(w){bubble.call(this,c,w)}function u(w){bubble.call(this,c,w)}function g(w){bubble.call(this,c,w)}function m(w){bubble.call(this,c,w)}function _(w){bubble.call(this,c,w)}function b(w){bubble.call(this,c,w)}function y(w){bubble.call(this,c,w)}function v(w){bubble.call(this,c,w)}function T(){f=this.value,n(0,f)}return c.$$set=w=>{e=assign(assign({},e),exclude_internal_props(w)),n(2,i=compute_rest_props(e,r)),"class"in w&&n(1,d=w.class),"value"in w&&n(0,f=w.value),"$$scope"in w&&n(3,a=w.$$scope)},[f,d,i,a,o,h,p,s,t,l,u,g,m,_,b,y,v,T]}class Input extends SvelteComponent{constructor(e){super(),init(this,e,instance$n,create_fragment$k,safe_not_equal,{class:1,value:0})}}const prerender=!1,ssr=!1,_page=Object.freeze(Object.defineProperty({__proto__:null,prerender,ssr},Symbol.toStringTag,{value:"Module"}));function create_fragment$j(c){let e,n,r,i,o,a;return{c(){e=svg_element("svg"),n=svg_element("g"),r=svg_element("rect"),i=svg_element("rect"),o=svg_element("rect"),a=svg_element("rect"),this.h()},l(d){e=claim_svg_element(d,"svg",{xmlns:!0,version:!0,viewBox:!0,class:!0,fill:!0});var f=children(e);n=claim_svg_element(f,"g",{"stroke-width":!0,fill:!0,"stroke-linecap":!0});var h=children(n);r=claim_svg_element(h,"rect",{fill:!0,x:!0,y:!0,transform:!0,width:!0,height:!0,rx:!0}),children(r).forEach(detach),i=claim_svg_element(h,"rect",{fill:!0,x:!0,y:!0,width:!0,height:!0,rx:!0}),children(i).forEach(detach),o=claim_svg_element(h,"rect",{fill:!0,x:!0,y:!0,transform:!0,width:!0,height:!0,rx:!0}),children(o).forEach(detach),a=claim_svg_element(h,"rect",{fill:!0,x:!0,y:!0,transform:!0,width:!0,height:!0,rx:!0}),children(a).forEach(detach),h.forEach(detach),f.forEach(detach),this.h()},h(){attr(r,"fill","currentColor"),attr(r,"x","-5.92"),attr(r,"y","-4.01"),attr(r,"transform","translate(27.13,84.71) rotate(43.3)"),attr(r,"width","11.84"),attr(r,"height","8.02"),attr(r,"rx","0.52"),attr(i,"fill","currentColor"),attr(i,"x","15.28"),attr(i,"y","95.80"),attr(i,"width","14.22"),attr(i,"height","7.96"),attr(i,"rx","0.31"),attr(o,"fill","currentColor"),attr(o,"x","-6.46"),attr(o,"y","-4.02"),attr(o,"transform","translate(27.39,116.33) rotate(-43.7)"),attr(o,"width","12.92"),attr(o,"height","8.04"),attr(o,"rx","0.56"),attr(a,"fill","currentColor"),attr(a,"x","-4.00"),attr(a,"y","-7.13"),attr(a,"transform","translate(42.50,119.88) rotate(-0.2)"),attr(a,"width","8.00"),attr(a,"height","14.26"),attr(a,"rx","0.27"),attr(n,"stroke-width","2.00"),attr(n,"fill","none"),attr(n,"stroke-linecap","butt"),attr(e,"xmlns","http://www.w3.org/2000/svg"),attr(e,"version","1.1"),attr(e,"viewBox","0.00 0.00 124.00 144.00"),attr(e,"class","absolute top-[-6px] left-[-3px]"),attr(e,"fill","#2a3039")},m(d,f){insert_hydration(d,e,f),append_hydration(e,n),append_hydration(n,r),append_hydration(n,i),append_hydration(n,o),append_hydration(n,a)},p:noop,i:noop,o:noop,d(d){d&&detach(e)}}}class MagicIcon extends SvelteComponent{constructor(e){super(),init(this,e,null,create_fragment$j,safe_not_equal,{})}}const panTool={name:"Move image",type:"PAN",cursor:"move"},smartRectangleTool={name:"Smart rectangle selection",type:"RECTANGLE",cursor:"crosshair",isSmart:!0},rectangleTool={name:"Rectangle selection",type:"RECTANGLE",cursor:"crosshair",isSmart:!1},removeSmartPointTool={name:"Negative point selection",type:"POINT_SELECTION",cursor:"crosshair",label:0,isSmart:!0},addSmartPointTool={name:"Positive point selection",type:"POINT_SELECTION",cursor:"crosshair",label:1,isSmart:!0},polygoneTool={name:"Polygone selection",type:"POLYGON",cursor:"crosshair",isSmart:!1};function maskDataToFortranArrayToRle(c,e,n){const r=[];let i=0,o=!1;for(let a=0;a<n;a++)for(let d=0;d<e;d++){const f=a+d*n;f<c.length&&(c[f]>0!==o?(r.push(i),o=!o,i=1):i++)}return i>0&&r.push(i),r}function splitPointKey(c){return c.split(" ").map(e=>parseInt(e))}function getLineBreakpoints(c,e){const n=[],r={line:-1,points:[]};let i=0;const o=()=>{r.points.length>0&&(n.push({line:r.line,points:r.points}),r.points=[])};for(let a=1;a<c.length;a+=2){i+=c[a-1];const d=i%e,f=Math.floor(i/e);i+=c[a];const h=i%e,p=Math.floor(i/e);if(r.line!==f&&(o(),r.line=f),f===p){r.points.push(d,h);continue}r.points.push(d,e),o(),r.line=p;for(let s=f+1;s<p;s++)n.push({line:s,points:[0,e]});h>0&&r.points.push(0,h)}return o(),n}function generatePolygonSegments(c,e){const n=getLineBreakpoints(c,e);if(n.length===0)return new Map;const r=new Map;let i=-1,o=[];const a=new Map,d=(t,l)=>{const u=`${t.x} ${t.y}`,g=`${l.x} ${l.y}`;r.has(u)||r.set(u,new Set),r.get(u).add(g),r.has(g)||r.set(g,new Set),r.get(g).add(u)},f=(t,l)=>{l!==a.get(t)&&(d({x:a.get(t),y:t},{x:l,y:t}),a.delete(t))},h=(t,l,u,g)=>{if(l===g){a.has(l)||a.set(l,t);return}let m=!1;const _=Math.max(t,u);a.has(l)&&(f(l,_),m=!0),a.has(g)&&(f(g,_),m=!0),m?d({x:_,y:l},{x:_,y:g}):d({x:t,y:l},{x:u,y:g})},p=(t,l)=>{for(const u of l)h(t,u,t+1,u);for(let u=1;u<l.length;u+=2)h(t+1,l[u-1],t+1,l[u])};for(const{line:t,points:l}of n){t!==i+1&&(p(i,o),i=t-1,o=[]);let u=o.length&&o[0]<=l[0]?i:t,g=u===i?o[0]:l[0],m=u===i?1:0,_=u===i?0:1,b=!0;for(;m<o.length||_<l.length;){let y,v;m===o.length||l[_]<o[m]?(y=t,v=l[_],_++):(y=i,v=o[m],m++),b&&(u===i&&y===i?(h(i,g,t,g),h(i,v,t,v),h(t,g,t,v)):h(u,g,y,v)),b=!b,u=y,g=v}i=t,o=l}return p(i,o),new Map([...r].sort((t,l)=>{const[u,g]=splitPointKey(t[0]),[m,_]=splitPointKey(l[0]);return u===m?g-_:u-m}))}function convertSegmentsToSVG(c){const e=[];for(;c.size;){let[a,d]=c.entries().next().value;const f=a,h=[splitPointKey(f)];let p=null;for(;p!==f;){p=d.values().next().value,h.push(splitPointKey(p)),d.delete(p),d.size===0&&c.delete(a);const s=c.get(p);if(s.delete(a),s.size===0){c.delete(p);break}else a=p,d=s}e.push(h)}const n=[],r=[],o=document.createElement("canvas").getContext("2d");for(const a of e){let d=!1;const[f,h]=a[0];for(const l of n)o.isPointInPath(l,f+.5,h+.5)&&(d=!d);d&&a.reverse();const p=a.slice(1).map(([l,u])=>`${l} ${u}`).join(" "),s=`M${a[0][0]} ${a[0][1]} L`+p;r.push(s);const t=new Path2D(s);o.fill(t),n.push(t)}return r}/**
 * @copyright CEA
 * @author CEA
 * @license CECILL
 *
 * This software is a collaborative computer program whose purpose is to
 * generate and explore labeled data for computer vision applications.
 * This software is governed by the CeCILL-C license under French law and
 * abiding by the rules of distribution of free software. You can use,
 * modify and/ or redistribute the software under the terms of the CeCILL-C
 * license as circulated by CEA, CNRS and INRIA at the following URL
 *
 * http://www.cecill.info
 */const dtypes={"<u1":{name:"uint8",size:8,arrayConstructor:Uint8Array},"|u1":{name:"uint8",size:8,arrayConstructor:Uint8Array},"<u2":{name:"uint16",size:16,arrayConstructor:Uint16Array},"|i1":{name:"int8",size:8,arrayConstructor:Int8Array},"<i2":{name:"int16",size:16,arrayConstructor:Int16Array},"<u4":{name:"uint32",size:32,arrayConstructor:Int32Array},"<i4":{name:"int32",size:32,arrayConstructor:Int32Array},"<u8":{name:"uint64",size:64,arrayConstructor:BigUint64Array},"<i8":{name:"int64",size:64,arrayConstructor:BigInt64Array},"<f4":{name:"float32",size:32,arrayConstructor:Float32Array},"<f8":{name:"float64",size:64,arrayConstructor:Float64Array}};function parse(c){const e=new Uint8Array(c);if(e[6]!=1)throw"Only npy version 1 is supported";const n=e[8]+e[9]*256,r=10+n,i=JSON.parse(new TextDecoder("utf-8").decode(e.slice(10,10+n)).replace(/'/g,'"').replace("False","false").replace("(","[").replace(/,*\),*/g,"]"));if(i.fortan_order)throw"Fortran-contiguous array data are not supported";const o=dtypes[i.descr];return{data:new o.arrayConstructor(e.slice(r).buffer),shape:i.shape,dtype:o.name}}function b64ToBuffer(c){const e=atob(c),n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n.buffer}var ort_min={exports:{}};/*!
* ONNX Runtime Web v1.16.3
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/(function(module,exports){(function(c,e){module.exports=e()})(self,()=>(()=>{var __webpack_modules__={5716:(c,e,n)=>{e.R=void 0;const r=n(6027),i=n(1723);e.R=new class{async init(){}async createSessionHandler(o,a){const d=new r.Session(a);return await d.loadModel(o),new i.OnnxjsSessionHandler(d)}}},2818:(c,e,n)=>{e.c8=e.rX=void 0;const r=n(2235),i=n(5381),o=n(9544),a=n(6640);e.rX=()=>{if((typeof r.env.wasm.initTimeout!="number"||r.env.wasm.initTimeout<0)&&(r.env.wasm.initTimeout=0),typeof r.env.wasm.simd!="boolean"&&(r.env.wasm.simd=!0),typeof r.env.wasm.proxy!="boolean"&&(r.env.wasm.proxy=!1),typeof r.env.wasm.numThreads!="number"||!Number.isInteger(r.env.wasm.numThreads)||r.env.wasm.numThreads<=0){const d=typeof navigator>"u"?(0,i.cpus)().length:navigator.hardwareConcurrency;r.env.wasm.numThreads=Math.min(4,Math.ceil((d||1)/2))}},e.c8=new class{async init(){(0,e.rX)(),await(0,o.initializeWebAssemblyInstance)()}async createSessionHandler(d,f){const h=new a.OnnxruntimeWebAssemblySessionHandler;return await h.loadModel(d,f),Promise.resolve(h)}}},1057:function(c,e,n){var r=this&&this.__createBinding||(Object.create?function(d,f,h,p){p===void 0&&(p=h);var s=Object.getOwnPropertyDescriptor(f,h);s&&!("get"in s?!f.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return f[h]}}),Object.defineProperty(d,p,s)}:function(d,f,h,p){p===void 0&&(p=h),d[p]=f[h]}),i=this&&this.__exportStar||function(d,f){for(var h in d)h==="default"||Object.prototype.hasOwnProperty.call(f,h)||r(f,d,h)};Object.defineProperty(e,"__esModule",{value:!0}),i(n(2235),e);const o=n(2235),a=n(8408);{const d=n(5716).R;(0,o.registerBackend)("webgl",d,-10)}{const d=n(2818).c8;(0,o.registerBackend)("cpu",d,10),(0,o.registerBackend)("wasm",d,10),(0,o.registerBackend)("xnnpack",d,9),(0,o.registerBackend)("webnn",d,9)}o.env.versions.web=a.version},4910:(c,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createAttributeWithCacheKey=void 0;class n{constructor(i){Object.assign(this,i)}get cacheKey(){return this._cacheKey||(this._cacheKey=Object.getOwnPropertyNames(this).sort().map(i=>`${this[i]}`).join(";")),this._cacheKey}}e.createAttributeWithCacheKey=r=>new n(r)},6874:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Attribute=void 0;const r=n(5127),i=n(2446),o=n(9240),a=n(7273);var d=r.onnxruntime.experimental.fbs;class f{constructor(p){if(this._attributes=new Map,p!=null){for(const s of p)s instanceof i.onnx.AttributeProto?this._attributes.set(s.name,[f.getValue(s),f.getType(s)]):s instanceof d.Attribute&&this._attributes.set(s.name(),[f.getValue(s),f.getType(s)]);if(this._attributes.size<p.length)throw new Error("duplicated attribute names")}}set(p,s,t){this._attributes.set(p,[t,s])}delete(p){this._attributes.delete(p)}getFloat(p,s){return this.get(p,"float",s)}getInt(p,s){return this.get(p,"int",s)}getString(p,s){return this.get(p,"string",s)}getTensor(p,s){return this.get(p,"tensor",s)}getFloats(p,s){return this.get(p,"floats",s)}getInts(p,s){return this.get(p,"ints",s)}getStrings(p,s){return this.get(p,"strings",s)}getTensors(p,s){return this.get(p,"tensors",s)}get(p,s,t){const l=this._attributes.get(p);if(l===void 0){if(t!==void 0)return t;throw new Error(`required attribute not found: ${p}`)}if(l[1]!==s)throw new Error(`type mismatch: expected ${s} but got ${l[1]}`);return l[0]}static getType(p){const s=p instanceof i.onnx.AttributeProto?p.type:p.type();switch(s){case i.onnx.AttributeProto.AttributeType.FLOAT:return"float";case i.onnx.AttributeProto.AttributeType.INT:return"int";case i.onnx.AttributeProto.AttributeType.STRING:return"string";case i.onnx.AttributeProto.AttributeType.TENSOR:return"tensor";case i.onnx.AttributeProto.AttributeType.FLOATS:return"floats";case i.onnx.AttributeProto.AttributeType.INTS:return"ints";case i.onnx.AttributeProto.AttributeType.STRINGS:return"strings";case i.onnx.AttributeProto.AttributeType.TENSORS:return"tensors";default:throw new Error(`attribute type is not supported yet: ${i.onnx.AttributeProto.AttributeType[s]}`)}}static getValue(p){const s=p instanceof i.onnx.AttributeProto?p.type:p.type();if(s===i.onnx.AttributeProto.AttributeType.GRAPH||s===i.onnx.AttributeProto.AttributeType.GRAPHS)throw new Error("graph attribute is not supported yet");const t=this.getValueNoCheck(p);if(s===i.onnx.AttributeProto.AttributeType.INT&&a.LongUtil.isLong(t))return a.LongUtil.longToNumber(t);if(s===i.onnx.AttributeProto.AttributeType.INTS){const l=t,u=new Array(l.length);for(let g=0;g<l.length;g++){const m=l[g];u[g]=a.LongUtil.longToNumber(m)}return u}if(s===i.onnx.AttributeProto.AttributeType.TENSOR)return p instanceof i.onnx.AttributeProto?o.Tensor.fromProto(t):o.Tensor.fromOrtTensor(t);if(s===i.onnx.AttributeProto.AttributeType.TENSORS){if(p instanceof i.onnx.AttributeProto)return t.map(l=>o.Tensor.fromProto(l));if(p instanceof d.Attribute)return t.map(l=>o.Tensor.fromOrtTensor(l))}if(s===i.onnx.AttributeProto.AttributeType.STRING&&p instanceof i.onnx.AttributeProto){const l=t;return(0,a.decodeUtf8String)(l)}return s===i.onnx.AttributeProto.AttributeType.STRINGS&&p instanceof i.onnx.AttributeProto?t.map(a.decodeUtf8String):t}static getValueNoCheck(p){return p instanceof i.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(p):this.getValueNoCheckFromOrtFormat(p)}static getValueNoCheckFromOnnxFormat(p){switch(p.type){case i.onnx.AttributeProto.AttributeType.FLOAT:return p.f;case i.onnx.AttributeProto.AttributeType.INT:return p.i;case i.onnx.AttributeProto.AttributeType.STRING:return p.s;case i.onnx.AttributeProto.AttributeType.TENSOR:return p.t;case i.onnx.AttributeProto.AttributeType.GRAPH:return p.g;case i.onnx.AttributeProto.AttributeType.FLOATS:return p.floats;case i.onnx.AttributeProto.AttributeType.INTS:return p.ints;case i.onnx.AttributeProto.AttributeType.STRINGS:return p.strings;case i.onnx.AttributeProto.AttributeType.TENSORS:return p.tensors;case i.onnx.AttributeProto.AttributeType.GRAPHS:return p.graphs;default:throw new Error(`unsupported attribute type: ${i.onnx.AttributeProto.AttributeType[p.type]}`)}}static getValueNoCheckFromOrtFormat(p){switch(p.type()){case d.AttributeType.FLOAT:return p.f();case d.AttributeType.INT:return p.i();case d.AttributeType.STRING:return p.s();case d.AttributeType.TENSOR:return p.t();case d.AttributeType.GRAPH:return p.g();case d.AttributeType.FLOATS:return p.floatsArray();case d.AttributeType.INTS:{const s=[];for(let t=0;t<p.intsLength();t++)s.push(p.ints(t));return s}case d.AttributeType.STRINGS:{const s=[];for(let t=0;t<p.stringsLength();t++)s.push(p.strings(t));return s}case d.AttributeType.TENSORS:{const s=[];for(let t=0;t<p.tensorsLength();t++)s.push(p.tensors(t));return s}default:throw new Error(`unsupported attribute type: ${d.AttributeType[p.type()]}`)}}}e.Attribute=f},1975:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveBackend=e.backend=void 0;const r=n(4418),i=new Map;async function o(a){const d=e.backend;if(d[a]!==void 0&&function(f){const h=f;return"initialize"in h&&typeof h.initialize=="function"&&"createSessionHandler"in h&&typeof h.createSessionHandler=="function"&&"dispose"in h&&typeof h.dispose=="function"}(d[a])){const f=d[a];let h=f.initialize();if(typeof h=="object"&&"then"in h&&(h=await h),h)return i.set(a,f),f}}e.backend={webgl:new r.WebGLBackend},e.resolveBackend=async function a(d){if(!d)return a(["webgl"]);{const f=typeof d=="string"?[d]:d;for(const h of f){const p=i.get(h);if(p)return p;const s=await o(h);if(s)return s}}throw new Error("no available backend to use")}},4418:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLBackend=void 0;const r=n(2235),i=n(1315),o=n(2171),a=n(3389);e.WebGLBackend=class{get contextId(){return r.env.webgl.contextId}set contextId(d){r.env.webgl.contextId=d}get matmulMaxBatchSize(){return r.env.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(d){r.env.webgl.matmulMaxBatchSize=d}get textureCacheMode(){return r.env.webgl.textureCacheMode}set textureCacheMode(d){r.env.webgl.textureCacheMode=d}get pack(){return r.env.webgl.pack}set pack(d){r.env.webgl.pack=d}get async(){return r.env.webgl.async}set async(d){r.env.webgl.async=d}initialize(){try{return this.glContext=(0,a.createWebGLContext)(this.contextId),typeof this.matmulMaxBatchSize!="number"&&(this.matmulMaxBatchSize=16),typeof this.textureCacheMode!="string"&&(this.textureCacheMode="full"),typeof this.pack!="boolean"&&(this.pack=!1),typeof this.async!="boolean"&&(this.async=!1),i.Logger.setWithEnv(r.env),i.Logger.verbose("WebGLBackend",`Created WebGLContext: ${typeof this.glContext} with matmulMaxBatchSize: ${this.matmulMaxBatchSize}; textureCacheMode: ${this.textureCacheMode}; pack: ${this.pack}; async: ${this.async}.`),!0}catch(d){return i.Logger.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${d}`),!1}}createSessionHandler(d){return new o.WebGLSessionHandler(this,d)}dispose(){this.glContext.dispose()}}},6859:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CoordsGlslLib=void 0;const r=n(7273),i=n(1997),o=n(6757),a=n(7618),d=n(432);class f extends i.GlslLib{constructor(p){super(p)}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.offsetToCoords()),this.coordsToOffset()),this.toVec()),this.valueFrom()),this.getCommonUtilFuncs()),this.getInputsSamplingSnippets()),this.getOutputSamplingSnippet())}getCustomTypes(){return{}}offsetToCoords(){return{offsetToCoords:new i.GlslLibRoutine(`
      vec2 offsetToCoords(int offset, int width, int height) {
        int t = offset / width;
        int s = offset - t*width;
        vec2 coords = (vec2(s,t) + vec2(0.5,0.5)) / vec2(width, height);
        return coords;
      }
      `)}}coordsToOffset(){return{coordsToOffset:new i.GlslLibRoutine(`
      int coordsToOffset(vec2 coords, int width, int height) {
        float s = coords.s * float(width);
        float t = coords.t * float(height);
        int offset = int(t) * width + int(s);
        return offset;
      }
      `)}}getOutputSamplingSnippet(){const p=this.context.outputTextureLayout;return p.isPacked?this.getPackedOutputSamplingSnippet(p):this.getUnpackedOutputSamplingSnippet(p)}getPackedOutputSamplingSnippet(p){const s=p.unpackedShape,t=[p.width,p.height],l={},u="getOutputCoords";switch(s.length){case 0:l[u]=this.getOutputScalarCoords();break;case 1:l[u]=this.getOutputPacked1DCoords(s,t);break;case 2:l[u]=this.getOutputPacked2DCoords(s,t);break;case 3:l[u]=this.getOutputPacked3DCoords(s,t);break;default:l[u]=this.getOutputPackedNDCoords(s,t)}const g=`
      void setOutput(vec4 val) {
        ${(0,o.getGlsl)(this.context.glContext.version).output} = val;
      }
    `;return l.floatTextureSetRGBA=new i.GlslLibRoutine(g),l}getUnpackedOutputSamplingSnippet(p){const s=p.unpackedShape,t=[p.width,p.height],l={},u="getOutputCoords";switch(s.length){case 0:l[u]=this.getOutputScalarCoords();break;case 1:l[u]=this.getOutputUnpacked1DCoords(s,t);break;case 2:l[u]=this.getOutputUnpacked2DCoords(s,t);break;case 3:l[u]=this.getOutputUnpacked3DCoords(s,t);break;case 4:l[u]=this.getOutputUnpacked4DCoords(s,t);break;case 5:l[u]=this.getOutputUnpacked5DCoords(s,t);break;case 6:l[u]=this.getOutputUnpacked6DCoords(s,t);break;default:throw new Error(`Unsupported output dimensionality: ${s.length}`)}const g=`
        void setOutput(float val) {
          ${(0,o.getGlsl)(this.context.glContext.version).output} = vec4(val, 0, 0, 0);
        }
    `;return l.floatTextureSetR=new i.GlslLibRoutine(g),l}getOutputScalarCoords(){return new i.GlslLibRoutine(`
      int getOutputCoords() {
        return 0;
      }
    `)}getOutputPacked1DCoords(p,s){const t=s;let l="";return t[0]===1?(l=`
          int getOutputCoords() {
            return 2 * int(TexCoords.y * ${t[1]}.0);
          }
        `,new i.GlslLibRoutine(l)):t[1]===1?(l=`
          int getOutputCoords() {
            return 2 * int(TexCoords.x * ${t[0]}.0);
          }
        `,new i.GlslLibRoutine(l)):(l=`
        int getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                 vec2(${t[0]}, ${t[1]}));
          return 2 * (resTexRC.y * ${t[0]} + resTexRC.x);
        }
      `,new i.GlslLibRoutine(l))}getOutputPacked2DCoords(p,s){let t="";if(r.ArrayUtil.arraysEqual(p,s))return t=`
        ivec2 getOutputCoords() {
          return 2 * ivec2(TexCoords.xy * vec2(${s[0]}, ${s[1]}));
        }
      `,new i.GlslLibRoutine(t);const l=s,u=Math.ceil(p[1]/2);return t=`
        ivec2 getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${l[0]}, ${l[1]}));

          int index = resTexRC.y * ${l[0]} + resTexRC.x;

          // reverse r and c order for packed texture
          int r = imod(index, ${u}) * 2;
          int c = 2 * (index / ${u});

          return ivec2(r, c);
        }
      `,new i.GlslLibRoutine(t)}getOutputPacked3DCoords(p,s){const t=[s[0],s[1]],l=Math.ceil(p[2]/2),u=l*Math.ceil(p[1]/2),g=`
        ivec3 getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${t[0]}, ${t[1]}));
          int index = resTexRC.y * ${t[0]} + resTexRC.x;

          int b = index / ${u};
          index -= b * ${u};

          // reverse r and c order for packed texture
          int r = imod(index, ${l}) * 2;
          int c = 2 * (index / ${l});

          return ivec3(b, r, c);
        }
      `;return new i.GlslLibRoutine(g)}getOutputPackedNDCoords(p,s){const t=[s[0],s[1]],l=Math.ceil(p[p.length-1]/2),u=l*Math.ceil(p[p.length-2]/2);let g=u,m="",_="b, r, c";for(let y=2;y<p.length-1;y++)g*=p[p.length-y-1],m=`
      int b${y} = index / ${g};
      index -= b${y} * ${g};
    `+m,_=`b${y}, `+_;const b=`
      ivec${p.length} getOutputCoords() {
        ivec2 resTexRC = ivec2(TexCoords.xy *
                              vec2(${t[0]}, ${t[1]}));
        int index = resTexRC.y * ${t[0]} + resTexRC.x;

        ${m}

        int b = index / ${u};
        index -= b * ${u};

        // reverse r and c order for packed texture
        int r = imod(index, ${l}) * 2;
        int c = 2 * (index / ${l});

        return ivec${p.length}(${_});
      }
    `;return new i.GlslLibRoutine(b)}getOutputUnpacked1DCoords(p,s){const t=`
        int getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${s[0]}, ${s[1]}));
          return resTexRC.y * ${s[0]} + resTexRC.x;
        }
      `;return new i.GlslLibRoutine(t)}getOutputUnpacked2DCoords(p,s){const t=`
        ivec2 getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${s[0]}, ${s[1]}));
          int index = resTexRC.y * ${s[0]} + resTexRC.x;
          int r = index / ${p[1]};
          int c = index - r * ${p[1]};
          return ivec2(r, c);
        }
      `;return new i.GlslLibRoutine(t)}getOutputUnpacked3DCoords(p,s){let t="";const l=p.length;let u=null;l<2&&(u=[]),u=new Array(l-1),u[l-2]=p[l-1];for(let _=l-3;_>=0;--_)u[_]=u[_+1]*p[_+1];const g=["r","c","d"],m=u.map((_,b)=>`int ${g[b]} = index / ${_}; ${b===u.length-1?`int ${g[b+1]} = index - ${g[b]} * ${_}`:`index -= ${g[b]} * ${_}`};`).join("");return t=`
        ivec3 getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${s[0]}, ${s[1]}));
          int index = resTexRC.y * ${s[0]} + resTexRC.x;
          ${m}
          return ivec3(r, c, d);
        }
      `,new i.GlslLibRoutine(t)}getOutputUnpacked4DCoords(p,s){let t="";const l=p.length;let u=null;l<2&&(u=[]),u=new Array(l-1),u[l-2]=p[l-1];for(let _=l-3;_>=0;--_)u[_]=u[_+1]*p[_+1];const g=["r","c","d","d2"],m=u.map((_,b)=>`int ${g[b]} = index / ${_}; ${b===u.length-1?`int ${g[b+1]} = index - ${g[b]} * ${_}`:`index -= ${g[b]} * ${_}`};`).join("");return t=`
      ivec4 getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${s[0]}, ${s[1]}));
          int index = resTexRC.y * ${s[0]} + resTexRC.x;
          ${m}
          return ivec4(r, c, d, d2);
        }
      `,new i.GlslLibRoutine(t)}getOutputUnpacked5DCoords(p,s){let t="";const l=p.length;let u=null;l<2&&(u=[]),u=new Array(l-1),u[l-2]=p[l-1];for(let _=l-3;_>=0;--_)u[_]=u[_+1]*p[_+1];const g=["r","c","d","d2","d3"],m=u.map((_,b)=>`int ${g[b]} = index / ${_}; ${b===u.length-1?`int ${g[b+1]} = index - ${g[b]} * ${_}`:`index -= ${g[b]} * ${_}`};`).join("");return t=`
      ivec5 getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${s[0]}, ${s[1]}));
          int index = resTexRC.y * ${s[0]} + resTexRC.x;
          ${m}
          return ivec5(r, c, d, d2, d3);
        }
      `,new i.GlslLibRoutine(t)}getOutputUnpacked6DCoords(p,s){let t="";const l=p.length;let u=null;l<2&&(u=[]),u=new Array(l-1),u[l-2]=p[l-1];for(let _=l-3;_>=0;--_)u[_]=u[_+1]*p[_+1];const g=["r","c","d","d2","d3","d4"],m=u.map((_,b)=>`int ${g[b]} = index / ${_}; ${b===u.length-1?`int ${g[b+1]} = index - ${g[b]} * ${_}`:`index -= ${g[b]} * ${_}`};`).join("");return t=`
     ivec6 getOutputCoords() {
         ivec2 resTexRC = ivec2(TexCoords.xy *
                               vec2(${s[0]}, ${s[1]}));
         int index = resTexRC.y * ${s[0]} + resTexRC.x;
         ${m}
         return ivec6(r, c, d, d2, d3, d4);
       }
     `,new i.GlslLibRoutine(t)}getCommonUtilFuncs(){const p={};let s="uvFromFlat";p[s]=new i.GlslLibRoutine(`
    vec2 uvFromFlat(int texNumR, int texNumC, int index) {
      int texC = index / texNumR;
      int texR = index - texC * texNumR;
      // TODO: swap texR, texC order in following function so row is corresponding to u and column is corresponding to
      //       v.
      return (vec2(texR, texC) + halfCR) / vec2(texNumR, texNumC);
    }
    `),s="packedUVfrom1D",p[s]=new i.GlslLibRoutine(`
      vec2 packedUVfrom1D(int texNumR, int texNumC, int index) {
        int texelIndex = index / 2;
        int texR = texelIndex / texNumC;
        int texC = texelIndex - texR * texNumC;
        return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
      }
      `),s="packedUVfrom2D",p[s]=new i.GlslLibRoutine(`
      vec2 packedUVfrom2D(int texNumR, int texNumC, int texelsInLogicalRow, int row, int col) {
        int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);
        int texR = texelIndex / texNumC;
        int texC = texelIndex - texR * texNumC;
        return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
      }
      `),s="packedUVfrom3D",p[s]=new i.GlslLibRoutine(`
      vec2 packedUVfrom3D(int texNumR, int texNumC,
          int texelsInBatch, int texelsInLogicalRow, int b,
          int row, int col) {
        int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);
        int texR = index / texNumC;
        int texC = index - texR * texNumC;
        return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
      }
      `),s="sampleTexture";const t=(0,o.getGlsl)(this.context.glContext.version);return p[s]=new i.GlslLibRoutine(`
        float sampleTexture(sampler2D textureSampler, vec2 uv) {
            return ${t.texture2D}(textureSampler, uv).r;
        }`),p}getInputsSamplingSnippets(){const p={},s=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((t,l)=>{const u=this.context.inputTextureLayouts[l],g=(0,d.generateShaderFuncNameFromInputSamplerName)(t);u.isPacked?p[g]=this.getPackedSamplerFromInput(g,t,u):p[g]=this.getUnpackedSamplerFromInput(g,t,u);const m=(0,d.generateShaderFuncNameFromInputSamplerNameAtOutCoords)(t);u.unpackedShape.length<=s.unpackedShape.length&&(u.isPacked?p[m]=this.getPackedSamplerAtOutputCoords(m,u,s,t):p[m]=this.getUnpackedSamplerAtOutputCoords(m,u,s,t))}),p}getPackedSamplerAtOutputCoords(p,s,t,l){const u=s.unpackedShape,g=t.unpackedShape,m=l,_=(0,d.generateShaderFuncNameFromInputSamplerName)(m),b=u.length,y=g.length,v=r.BroadcastUtil.getBroadcastDims(u,g),T=(0,d.getCoordsDataType)(y),w=y-b;let S;const x=(0,d.getGlChannels)();S=b===0?"":y<2&&v.length>=1?"coords = 0;":v.map(M=>`coords.${x[M+w]} = 0;`).join(`
`);let P="";P=y<2&&b>0?"coords":u.map((M,k)=>`coords.${x[k+w]}`).join(", ");let I="return outputValue;";const N=r.ShapeUtil.size(u)===1,L=r.ShapeUtil.size(g)===1;if(b!==1||N||L){if(N&&!L)I=y===1?`
          return vec4(outputValue.x, outputValue.x, 0., 0.);
        `:`
          return vec4(outputValue.x);
        `;else if(v.length){const M=b-2,k=b-1;v.indexOf(M)>-1&&v.indexOf(k)>-1?I="return vec4(outputValue.x);":v.indexOf(M)>-1?I="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":v.indexOf(k)>-1&&(I="return vec4(outputValue.xx, outputValue.zz);")}}else I=`
        return vec4(outputValue.xy, outputValue.xy);
      `;const E=`
      vec4 ${p}() {
        ${T} coords = getOutputCoords();
        
        int lastDim = coords.${x[y-1]};
        coords.${x[y-1]} = coords.${x[y-2]};
        coords.${x[y-2]} = lastDim;
      
        ${S}
        vec4 outputValue = ${_}(${P});
        ${I}
      }
    `;return new i.GlslLibRoutine(E,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(p,s,t,l){const u=[t.width,t.height],g=[s.width,s.height],m=s.unpackedShape.length,_=t.unpackedShape.length,b=s.unpackedShape,y=t.unpackedShape,v=(0,d.generateShaderFuncNameFromInputSamplerName)(l);if(m===_&&r.ArrayUtil.arraysEqual(g,u)){const L=`
          float ${p}() {
            return sampleTexture(${l}, TexCoords);
          }
        `;return new i.GlslLibRoutine(L,["coordinates.sampleTexture"])}const T=(0,d.getCoordsDataType)(_),w=r.BroadcastUtil.getBroadcastDims(b,y),S=_-m;let x;const P=(0,d.getGlChannels)();x=m===0?"":_<2&&w.length>=1?"coords = 0;":w.map(L=>`coords.${P[L+S]} = 0;`).join(`
`);let I="";I=_<2&&m>0?"coords":s.unpackedShape.map((L,E)=>`coords.${P[E+S]}`).join(", ");const N=`
        float ${p}() {
          ${T} coords = getOutputCoords();
          ${x}
          return ${v}(${I});
        }
      `;return new i.GlslLibRoutine(N,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(p,s,t){switch(t.unpackedShape.length){case 0:return this.getPackedSamplerScalar(p,s);case 1:return this.getPackedSampler1D(p,s,t);case 2:return this.getPackedSampler2D(p,s,t);case 3:return this.getPackedSampler3D(p,s,t);default:return this.getPackedSamplerND(p,s,t)}}getUnpackedSamplerFromInput(p,s,t){const l=t.unpackedShape;switch(l.length){case 0:return this.getUnpackedSamplerScalar(p,s,t);case 1:return this.getUnpackedSampler1D(p,s,t);case 2:return this.getUnpackedSampler2D(p,s,t);case 3:return this.getUnpackedSampler3D(p,s,t);case 4:return this.getUnpackedSampler4D(p,s,t);case 5:return this.getUnpackedSampler5D(p,s,t);case 6:return this.getUnpackedSampler6D(p,s,t);default:throw new Error(`Unsupported dimension ${l.length}-D`)}}getPackedSamplerScalar(p,s){const t=`
          vec4 ${p}() {
            return ${(0,o.getGlsl)(this.context.glContext.version).texture2D}(${s}, halfCR);
          }
        `;return new i.GlslLibRoutine(t)}getPackedSampler1D(p,s,t){const l=[t.width,t.height],u=[l[1],l[0]],g=(0,o.getGlsl)(this.context.glContext.version),m=`vec4 ${p}(int index) {
      vec2 uv = packedUVfrom1D(
      ${u[0]}, ${u[1]}, index);
      return ${g.texture2D}(${s}, uv);
    }`;return new i.GlslLibRoutine(m,["coordinates.packedUVfrom1D"])}getPackedSampler2D(p,s,t){const l=t.unpackedShape,u=[t.width,t.height],g=(0,o.getGlsl)(this.context.glContext.version),m=u[0],_=u[1];if(u!=null&&r.ArrayUtil.arraysEqual(l,u)){const T=`vec4 ${p}(int row, int col) {
        vec2 uv = (vec2(col, row) + halfCR) / vec2(${_}.0, ${m}.0);
        return ${g.texture2D}(${s}, uv);
      }`;return new i.GlslLibRoutine(T)}const b=u,y=Math.ceil(l[1]/2),v=`vec4 ${p}(int row, int col) {
      vec2 uv = packedUVfrom2D(${b[1]}, ${b[0]}, ${y}, row, col);
      return ${g.texture2D}(${s}, uv);
    }`;return new i.GlslLibRoutine(v,["coordinates.packedUVfrom2D"])}getPackedSampler3D(p,s,t){const l=t.unpackedShape,u=[t.width,t.height],g=[u[0],u[1]],m=(0,o.getGlsl)(this.context.glContext.version);if(l[0]===1){const T=l.slice(1),w=[1,2],S=(0,d.squeezeInputShape)(l,T),x=["b","row","col"],P=JSON.parse(JSON.stringify(t));P.unpackedShape=S;const I=this.getPackedSamplerFromInput(p,s,P),N=`${I.routineBody}
      vec4 ${p}(int b, int row, int col) {
        return ${p}(${(0,d.getSqueezedParams)(x,w)});
      } `;return new i.GlslLibRoutine(N,I.dependencies)}const _=g[0],b=g[1],y=Math.ceil(l[2]/2),v=`vec4 ${p}(int b, int row, int col) {
      vec2 uv = packedUVfrom3D(
        ${b}, ${_}, ${y*Math.ceil(l[1]/2)}, ${y}, b, row, col);
      return ${m.texture2D}(${s}, uv);}`;return new i.GlslLibRoutine(v,["coordinates.packedUVfrom3D"])}getPackedSamplerND(p,s,t){const l=t.unpackedShape,u=l.length,g=[t.width,t.height],m=(0,o.getGlsl)(this.context.glContext.version),_=[g[0],g[1]],b=_[1],y=_[0],v=Math.ceil(l[u-1]/2);let T=v*Math.ceil(l[u-2]/2),w="int b, int row, int col",S=`b * ${T} + (row / 2) * ${v} + (col / 2)`;for(let P=2;P<u-1;P++)w=`int b${P}, `+w,T*=l[u-P-1],S=`b${P} * ${T} + `+S;const x=`vec4 ${p}(${w}) {
      int index = ${S};
      int texR = index / ${y};
      int texC = index - texR * ${y};
      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${y}, ${b});
      return ${m.texture2D}(${s}, uv);
    }`;return new i.GlslLibRoutine(x)}getUnpackedSamplerScalar(p,s,t){const[l,u]=[t.width,t.height];if(l===1&&u===1){const m=`
          float ${p}() {
            return sampleTexture(${s}, halfCR);
          }
        `;return new i.GlslLibRoutine(m,["coordinates.sampleTexture"])}const g=`
        float ${p}() {
          int offset_${s} = coordsToOffset(TexCoords, ${l}, ${u});
          vec2 uv = uvFromFlat(${l}, ${u}, offset_${s});
          return sampleTexture(${s}, uv);
        }
      `;return new i.GlslLibRoutine(g,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler1D(p,s,t){const l=t.width,u=t.height;if(u===1&&l===1){const m=`
        float ${p}(int index) {
          return sampleTexture(${s}, halfCR);
        }
      `;return new i.GlslLibRoutine(m,["coordinates.sampleTexture"])}if(u===1){const m=`
          float ${p}(int index) {
            vec2 uv = vec2((float(index) + 0.5) / ${l}.0, 0.5);
            return sampleTexture(${s}, uv);
          }
        `;return new i.GlslLibRoutine(m,["coordinates.sampleTexture"])}if(l===1){const m=`
          float ${p}(int index) {
            vec2 uv = vec2(0.5, (float(index) + 0.5) / ${u}.0);
            return sampleTexture(${s}, uv);
          }
        `;return new i.GlslLibRoutine(m,["coordinates.sampleTexture"])}const g=`
        float ${p}(int index) {
          vec2 uv = uvFromFlat(${l}, ${u}, index);
          return sampleTexture(${s}, uv);
        }
      `;return new i.GlslLibRoutine(g,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler2D(p,s,t){const l=t.unpackedShape,u=[t.height,t.width];if(u!=null&&r.ArrayUtil.arraysEqual(l,u)){const T=`
          float ${p}(int row, int col) {
            vec2 uv = (vec2(row, col) + halfCR) / vec2(${u[1]}.0, ${u[0]}.0);
            return sampleTexture(${s}, uv);
          }
        `;return new i.GlslLibRoutine(T,["coordinates.sampleTexture"])}const{newShape:g,keptDims:m}=(0,a.squeezeShape)(l),_=g;if(_.length<l.length){const T=(0,d.squeezeInputShape)(l,_),w=JSON.parse(JSON.stringify(t));w.unpackedShape=T;const S=["col","row"],x=`
          ${this.getUnpackedSamplerFromInput(p,s,w).routineBody}
          float ${p}(int row, int col) {
            return ${p}(${(0,d.getSqueezedParams)(S,m)});
          }
        `;return new i.GlslLibRoutine(x,["coordinates.sampleTexture"])}const b=u[1],y=u[0];if(y===1){const T=`
          float ${p}(int row, int col) {
            int offset_${s} = coordsToOffset(TexCoords, ${b}, ${y});
            float index = dot(vec3(row, col, offset_${s}), vec3(${l[1]}, 1, 1));
            vec2 uv = vec2(0.5, (index + 0.5) / ${b}.0);
            return sampleTexture(${s}, uv);
          }
        `;return new i.GlslLibRoutine(T,["coordinates.sampleTexture","coordinates.coordsToOffset"])}if(b===1){const T=`
          float ${p}(int row, int col) {
            int offset_${s} = coordsToOffset(TexCoords, ${b}, ${y});
            float index = dot(vec3(row, col, offset_${s}), vec3(${l[1]}, 1, 1));
            vec2 uv = vec2((index + 0.5) / ${y}.0, 0.5);
            return sampleTexture(${s}, uv);
          }
        `;return new i.GlslLibRoutine(T,["coordinates.sampleTexture","coordinates.coordsToOffset"])}const v=`
        float ${p}(int row, int col) {
          int index = col * ${l[1]} + row;
          vec2 uv = uvFromFlat(${b}, ${y}, index);
          return sampleTexture(${s}, uv);
        }
      `;return new i.GlslLibRoutine(v,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler3D(p,s,t){const l=t.unpackedShape,u=l[1]*l[2],g=l[2],{newShape:m,keptDims:_}=(0,a.squeezeShape)(l),b=m;if(b.length<l.length){const v=(0,d.squeezeInputShape)(l,b),T=["batch","col","row"],w=JSON.parse(JSON.stringify(t));w.unpackedShape=v;const S=this.getUnpackedSamplerFromInput(p,s,w),x=_.reverse(),P=`
          ${S.routineBody}
          float ${p}(int batch, int row, int col) {
            return ${p}(${(0,d.getSqueezedParams)(T,x)});
          }
        `;return new i.GlslLibRoutine(P,S.dependencies)}const y=`
          float ${p}(int depth, int row, int col) {
            // Explicitly use integer operations as dot() only works on floats.
            int index = depth * ${u} + col * ${g} + row;
            vec2 uv = uvFromFlat(${t.width}, ${t.height}, index);
            return sampleTexture(${s}, uv);
          }
      `;return new i.GlslLibRoutine(y,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler4D(p,s,t){const l=t.unpackedShape,u=l[3],g=l[2]*u,m=`
        float ${p}(int row, int col, int depth, int depth2) {
          int index = row * ${l[1]*g} + col * ${g} +
              depth2 * ${u} + depth;
          vec2 uv = uvFromFlat(${t.width}, ${t.height}, index);
          return sampleTexture(${s}, uv);
        }
      `;return new i.GlslLibRoutine(m,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler5D(p,s,t){const l=t.unpackedShape,u=l[4],g=l[3]*u,m=l[2]*g,_=l[1]*m,{newShape:b,keptDims:y}=(0,a.squeezeShape)(l);if(b.length<l.length){const T=(0,d.squeezeInputShape)(l,b),w=["row","col","depth","depth2","depth3"],S=JSON.parse(JSON.stringify(t));S.unpackedShape=T;const x=`
          ${this.getUnpackedSamplerFromInput(p,s,S).routineBody}
          float ${p}(int row, int col, int depth, int depth2, int depth3) {
            return ${p}(${(0,d.getSqueezedParams)(w,y)});
          }
        `;return new i.GlslLibRoutine(x,["coordinates.sampleTexture","coordinates.uvFromFlat"])}const v=`
        float ${p}(int row, int col, int depth, int depth2, int depth3) {
          int index = row * ${_} + col * ${m} + depth * ${g} +
          depth3 * ${u} + depth2;
          vec2 uv = uvFromFlat(${t.width}, ${t.height}, index);
          return sampleTexture(${s}, uv);
        }
      `;return new i.GlslLibRoutine(v,["coordinates.sampleTexture","coordinates.uvFromFlat"])}getUnpackedSampler6D(p,s,t){const l=t.unpackedShape,u=l[5],g=l[4]*u,m=l[3]*g,_=l[2]*m,b=l[1]*_,{newShape:y,keptDims:v}=(0,a.squeezeShape)(l);if(y.length<l.length){const w=(0,d.squeezeInputShape)(l,y),S=["row","col","depth","depth2","depth3","depth4"],x=JSON.parse(JSON.stringify(t));x.unpackedShape=w;const P=`
            ${this.getUnpackedSamplerFromInput(p,s,x).routineBody}
            float ${p}(int row, int col, int depth,
              int depth2, int depth3, int depth4) {
              return ${p}(${(0,d.getSqueezedParams)(S,v)});
            }
          `;return new i.GlslLibRoutine(P,["coordinates.sampleTexture","coordinates.uvFromFlat"])}const T=`
          float ${p}(int row, int col, int depth,
            int depth2, int depth3, int depth4) {
            int index = row * ${b} + col * ${_} + depth * ${m} +
            depth2 * ${g} + depth3 * ${u} + depth4;
            vec2 uv = uvFromFlat(${t.width}, ${t.height}, index);
            return sampleTexture(${s}, uv);
          }
        `;return new i.GlslLibRoutine(T,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}toVec(){const p=this.context.outputTextureLayout,s=p.shape.length,t=p.strides,l=p.width,u=p.height,g=[];for(let _=0;_<s-1;++_)g.push(`
        c[${_}] = offset / ${t[_]};`),g.push(`
        offset -= c[${_}] * ${t[_]};`);g.push(`
        c[${s-1}] = offset;`);const m=`
      void toVec(vec2 texCoords, out int c[${s}]) {
        int offset = coordsToOffset(texCoords, ${l}, ${u});
        ${g.join("")}
      }
      void toVec(int offset, out int c[${s}]) {
        ${g.join("")}
      }
    `;return{toVec:new i.GlslLibRoutine(m,["coordinates.coordsToOffset"])}}valueFrom(){const p={};return this.context.programInfo.inputNames.forEach((s,t)=>{const l=this.context.inputTextureLayouts[t],u=(l.unpackedShape.length>0?l.unpackedShape:l.shape).length;let g=`_${s}`;p[g]=new i.GlslLibRoutine(this.getValueFromSingle(s,u,l.width,l.height,!1),[`shapeUtils.indicesToOffset${g}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),g+="_T",p[g]=new i.GlslLibRoutine(this.getValueFromSingle(s,u,l.width,l.height,!0),[`shapeUtils.indicesToOffset${g}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),p}getValueFromSingle(p,s,t,l,u){let g=`_${p}`;return u&&(g+="_T"),`
        float ${g}(int m[${s}]) {
          int offset = indicesToOffset${g}(m);
          vec2 coords = offsetToCoords(offset, ${t}, ${l});
          float value = getColorAsFloat(${(0,o.getGlsl)(this.context.glContext.version).texture2D}(${p}, coords));
          return value;
        }
        `}getPackedValueFrom(p,s,t,l,u){let g=`_${p}_Pack`;return u&&(g+="_T"),`
        vec4 ${g}(int m[${s}]) {
          int offset = indicesToOffset_${p}(m);
          vec2 coords = offsetToCoords(offset, ${t}, ${l});
          return ${(0,o.getGlsl)(this.context.glContext.version).texture2D}(${p}, coords);
        }
        `}}e.CoordsGlslLib=f},1997:(c,e)=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.TopologicalSortGlslRoutines=e.GlslLibRoutineNode=e.GlslLibRoutine=e.GlslLib=e.GlslContext=e.FunctionType=void 0,(n=e.FunctionType||(e.FunctionType={}))[n.ValueBased=0]="ValueBased",n[n.Positional=1]="Positional",e.GlslContext=class{constructor(r,i,o,a){this.glContext=r,this.programInfo=i,this.inputTextureLayouts=o,this.outputTextureLayout=a}},e.GlslLib=class{constructor(r){this.context=r}},e.GlslLibRoutine=class{constructor(r,i){this.routineBody=r,this.dependencies=i}},e.GlslLibRoutineNode=class{constructor(r,i,o){this.name=r,this.dependencies=o||[],i&&(this.routineBody=i)}addDependency(r){r&&this.dependencies.push(r)}},e.TopologicalSortGlslRoutines=class{static returnOrderedNodes(r){if(!r||r.length===0)return[];if(r.length===1)return r;const i=new Set,o=new Set,a=new Array;return this.createOrderedNodes(r,i,o,a),a}static createOrderedNodes(r,i,o,a){for(let d=0;d<r.length;++d)this.dfsTraverse(r[d],i,o,a)}static dfsTraverse(r,i,o,a){if(!r||o.has(r.name))return;if(i.has(r.name))throw new Error("Cyclic dependency detected. Can't topologically sort routines needed for shader.");i.add(r.name);const d=r.dependencies;if(d&&d.length>0)for(let f=0;f<d.length;++f)this.dfsTraverse(d[f],i,o,a);a.push(r),o.add(r.name),i.delete(r.name)}}},1371:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EncodingGlslLib=void 0;const r=n(1997);class i extends r.GlslLib{constructor(a){super(a)}getFunctions(){return Object.assign(Object.assign({},this.encodeFloat32()),this.decodeFloat32())}getCustomTypes(){return{}}encodeFloat32(){return{encode:new r.GlslLibRoutine(`highp vec4 encode(highp float f) {
        return vec4(f, 0.0, 0.0, 0.0);
      }
        `)}}decodeFloat32(){return{decode:new r.GlslLibRoutine(`highp float decode(highp vec4 rgba) {
        return rgba.r;
      }
        `)}}encodeUint8(){const a=i.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new r.GlslLibRoutine(`
      highp vec4 encode(highp float f) {
        highp float F = abs(f);
        highp float Sign = step(0.0,-f);
        highp float Exponent = floor(log2(F));
        highp float Mantissa = (exp2(- Exponent) * F);
        Exponent = floor(log2(F) + 127.0) + floor(log2(Mantissa));
        highp vec4 rgba;
        rgba[0] = 128.0 * Sign  + floor(Exponent*exp2(-1.0));
        rgba[1] = 128.0 * mod(Exponent,2.0) + mod(floor(Mantissa*128.0),128.0);
        rgba[2] = floor(mod(floor(Mantissa*exp2(23.0 -8.0)),exp2(8.0)));
        rgba[3] = floor(exp2(23.0)*mod(Mantissa,exp2(-15.0)));
        ${a}
        rgba = rgba / 255.0; // values need to be normalized to [0,1]
        return rgba;
    }
        `)}}decodeUint8(){const a=i.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new r.GlslLibRoutine(`
        highp float decode(highp vec4 rgba) {
          rgba = rgba * 255.0; // values need to be de-normalized from [0,1] to [0,255]
          ${a}
          highp float Sign = 1.0 - step(128.0,rgba[0])*2.0;
          highp float Exponent = 2.0 * mod(rgba[0],128.0) + step(128.0,rgba[1]) - 127.0;
          highp float Mantissa = mod(rgba[1],128.0)*65536.0 + rgba[2]*256.0 +rgba[3] + float(0x800000);
          highp float Result =  Sign * exp2(Exponent) * (Mantissa * exp2(-23.0 ));
          return Result;
      }
        `)}}static isLittleEndian(){const a=new ArrayBuffer(4),d=new Uint32Array(a),f=new Uint8Array(a);if(d[0]=3735928559,f[0]===239)return!0;if(f[0]===222)return!1;throw new Error("unknown endianness")}}e.EncodingGlslLib=i},2691:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.FragColorGlslLib=void 0;const r=n(1997),i=n(6757);class o extends r.GlslLib{constructor(d){super(d)}getFunctions(){return Object.assign(Object.assign({},this.setFragColor()),this.getColorAsFloat())}getCustomTypes(){return{}}setFragColor(){const d=(0,i.getGlsl)(this.context.glContext.version);return{setFragColor:new r.GlslLibRoutine(`
        void setFragColor(float value) {
            ${d.output} = encode(value);
        }
        `,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new r.GlslLibRoutine(`
        float getColorAsFloat(vec4 color) {
            return decode(color);
        }
        `,["encoding.decode"])}}}e.FragColorGlslLib=o},3878:(c,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.replaceInlines=void 0;const n=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm;e.replaceInlines=function(r){const i={};let o;for(;(o=n.exec(r))!==null;){const a=o[3].split(",").map(d=>{const f=d.trim().split(" ");return f&&f.length===2?{type:f[0],name:f[1]}:null}).filter(d=>d!==null);i[o[2]]={params:a,body:o[4]}}for(const a in i){const d="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;".replace("__FUNC__",a),f=new RegExp(d,"gm");for(;(o=f.exec(r))!==null;){const h=o[1],p=o[2],s=o[3].split(","),t=h?`${h} ${p};`:"";let l=i[a].body,u="";i[a].params.forEach((m,_)=>{m&&(u+=`${m.type} ${m.name} = ${s[_]};
`)}),l=`${u}
 ${l}`,l=l.replace("return",`${p} = `);const g=`
      ${t}
      {
        ${l}
      }
      `;r=r.replace(o[0],g)}}return r.replace(n,"")}},8897:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GlslPreprocessor=void 0;const r=n(1997),i=n(3878),o=n(1248),a=n(6757);e.GlslPreprocessor=class{constructor(d,f,h,p){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new r.GlslContext(d,f,h,p),Object.keys(o.glslRegistry).forEach(t=>{const l=new o.glslRegistry[t](this.context);this.libs[t]=l});const s=this.glslLibRoutineDependencyGraph;for(const t in this.libs){const l=this.libs[t].getFunctions();for(const u in l){const g=t+"."+u;let m;s[g]?(m=s[g],m.routineBody=l[u].routineBody):(m=new r.GlslLibRoutineNode(g,l[u].routineBody),s[g]=m);const _=l[u].dependencies;if(_)for(let b=0;b<_.length;++b)if(s[_[b]])m.addDependency(s[_[b]]);else{const y=new r.GlslLibRoutineNode(_[b]);s[_[b]]=y,m.addDependency(y)}}}}preprocess(){const d=this.context.programInfo;let f=d.shaderSource;return this.context.programInfo.hasMain||(f=`${f}
      ${(0,a.getDefaultFragShaderMain)(this.context.glContext.version,this.context.outputTextureLayout.shape.length)}`),f=(0,i.replaceInlines)(f),`${(0,a.getFragShaderPreamble)(this.context.glContext.version)}
    ${this.getUniforms(d.inputNames,d.variables)}
    ${this.getImports(f)}
    ${f}`}getImports(d){const f=this.selectGlslLibRoutinesToBeIncluded(d);if(f.length===0)return"";let h="";for(let p=0;p<f.length;++p){if(!f[p].routineBody)throw new Error(`Missing body for the Glsl Library routine: ${f[p].name}`);h+=f[p].routineBody+`
`}return h}selectGlslLibRoutinesToBeIncluded(d){const f=[];return Object.keys(this.glslLibRoutineDependencyGraph).forEach(h=>{const p=h.split(".")[1];d.indexOf(p)!==-1&&f.push(this.glslLibRoutineDependencyGraph[h])}),r.TopologicalSortGlslRoutines.returnOrderedNodes(f)}getUniforms(d,f){const h=[];if(d)for(const p of d)h.push(`uniform sampler2D ${p};`);if(f)for(const p of f)h.push(`uniform ${p.type} ${p.name}${p.arrayLength?`[${p.arrayLength}]`:""};`);return h.join(`
`)}}},1248:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.glslRegistry=void 0;const r=n(6859),i=n(1371),o=n(2691),a=n(9183),d=n(9314);e.glslRegistry={encoding:i.EncodingGlslLib,fragcolor:o.FragColorGlslLib,vec:d.VecGlslLib,shapeUtils:a.ShapeUtilsGlslLib,coordinates:r.CoordsGlslLib}},9183:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ShapeUtilsGlslLib=void 0;const r=n(1997);class i extends r.GlslLib{constructor(a){super(a)}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.bcastIndex()),this.bcastMatmulIndex()),this.offsetToIndices()),this.indicesToOffset()),this.incrementIndices())}getCustomTypes(){return{}}bcastIndex(){const a=this.context.outputTextureLayout.shape.length,d={};return this.context.programInfo.inputNames.forEach((f,h)=>{const p=this.context.inputTextureLayouts[h].unpackedShape;if(p.length<=a){const s=p.length,t=a-s,l=`bcastIndices_${f}`;let u="";for(let m=0;m<s;++m)u+=`
          realIndices[${m}] = int( mod(float(bcastedIndices[${t+m}]), ${p[m]}.0) );
          `;const g=`
        void ${l} (int bcastedIndices[${a}], out int realIndices[${s}]) {
          ${u}
        }
        `;d[l]=new r.GlslLibRoutine(g)}}),d}bcastMatmulIndex(){const a=this.context.outputTextureLayout.shape.length,d={};return this.context.programInfo.inputNames.forEach((f,h)=>{const p=this.context.inputTextureLayouts[h].shape;if(!(p.length<2||p.length>a)){const s=p.length,t=a-s,l=`bcastMatmulIndices_${f}`;let u="";for(let m=0;m<s-2;++m)u+=`
          realIndices[${m}] = int( mod(float(bcastedIndices[${t+m}]), ${p[m]}.0) );
          `;const g=`
        void ${l}(int bcastedIndices[${a}], out int realIndices[${s}]) {
          ${u}
          realIndices[${s-1}] = bcastedIndices[${a-1}];
          realIndices[${s-2}] = bcastedIndices[${a-2}];
        }
        `;d[l]=new r.GlslLibRoutine(g)}}),d}indicesToOffset(){const a={};return this.context.programInfo.inputNames.forEach((d,f)=>{const h=this.context.inputTextureLayouts[f].shape,p=this.context.inputTextureLayouts[f].strides,s=h.length;let t=`indicesToOffset_${d}`;a[t]=new r.GlslLibRoutine(i.indexToOffsetSingle(t,s,p)),t=`indicesToOffset_${d}_T`,a[t]=new r.GlslLibRoutine(i.indexToOffsetSingle(t,s,p.slice().reverse()))}),a}static indexToOffsetSingle(a,d,f){let h="";for(let p=d-1;p>=0;--p)h+=`
        offset += indices[${p}] * ${f[p]};
        `;return`
      int ${a}(int indices[${d}]) {
        int offset = 0;
        ${h}
        return offset;
      }
      `}offsetToIndices(){const a={};return this.context.programInfo.inputNames.forEach((d,f)=>{const h=this.context.inputTextureLayouts[f].shape,p=this.context.inputTextureLayouts[f].strides,s=h.length;let t=`offsetToIndices_${d}`;a[t]=new r.GlslLibRoutine(i.offsetToIndicesSingle(t,s,p)),t=`offsetToIndices_${d}_T`,a[t]=new r.GlslLibRoutine(i.offsetToIndicesSingle(t,s,p.slice().reverse()))}),a}static offsetToIndicesSingle(a,d,f){const h=[];for(let p=0;p<d-1;++p)h.push(`
      indices[${p}] = offset / ${f[p]};`),h.push(`
        offset -= indices[${p}] * ${f[p]};`);return h.push(`
      indices[${d-1}] = offset;`),`
      void ${a}(int offset, out int indices[${d}]) {
        ${h.join("")}
      }
      `}incrementIndices(){const a={};return this.context.programInfo.inputNames.forEach((d,f)=>{const h=this.context.inputTextureLayouts[f].shape,p=h.length,s=`incrementIndices_${d}`;let t="";for(let u=0;u<p;++u)t+=`
        shape[${u}] = ${h[u]};`;const l=`
        void ${s}(int axis, out int indices[${p}]) {
          int shape[${p}];
          ${t};
          for(int i = ${p} -1 ; i >= 0; --i) {
            if(i > axis) continue;
            indices[i] += 1;
            if(indices[i] < shape[i]) {
              break;
            }
            indices[i] = 0;
          }
        }
        `;a[s]=new r.GlslLibRoutine(l)}),a}}e.ShapeUtilsGlslLib=i},6757:(c,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getDefaultFragShaderMain=e.getFragShaderPreamble=e.getVertexShaderSource=e.getGlsl=void 0;const n={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},r={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"};function i(o){return o===1?n:r}e.getGlsl=i,e.getVertexShaderSource=function(o){const a=i(o);return`${a.version}
      precision highp float;
      ${a.attribute} vec3 position;
      ${a.attribute} vec2 textureCoord;

      ${a.varyingVertex} vec2 TexCoords;

      void main()
      {
          gl_Position = vec4(position, 1.0);
          TexCoords = textureCoord;
      }`},e.getFragShaderPreamble=function(o){const a=i(o);return`${a.version}
    precision highp float;
    precision highp int;
    precision highp sampler2D;
    ${a.varyingFrag} vec2 TexCoords;
    ${a.outputDeclaration}
    const vec2 halfCR = vec2(0.5, 0.5);

    // Custom vector types to handle higher dimenalities.
    struct ivec5
    {
      int x;
      int y;
      int z;
      int w;
      int u;
    };

    struct ivec6
    {
      int x;
      int y;
      int z;
      int w;
      int u;
      int v;
    };

    int imod(int x, int y) {
      return x - y * (x / y);
    }

    `},e.getDefaultFragShaderMain=function(o,a){return`
  void main() {
    int indices[${a}];
    toVec(TexCoords, indices);
    vec4 result = vec4(process(indices));
    ${i(o).output} = result;
  }
  `}},9314:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.VecGlslLib=void 0;const r=n(1997);class i extends r.GlslLib{constructor(a){super(a)}getCustomTypes(){return{}}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign({},this.binaryVecFunctions()),this.copyVec()),this.setVecItem()),this.getVecItem())}binaryVecFunctions(){const a=this.context.outputTextureLayout.shape.length,d={add:"+=",sub:"-=",mul:"*=",div:"/="},f={};for(const h in d){const p=`${h}Vec`;let s="";for(let l=0;l<a;++l)s+=`
          dest[${l}] ${d[h]} src[${l}];
          `;const t=`
        void ${p}(int src[${a}], out int dest[${a}]) {
          ${s}
        }
        `;f[p]=new r.GlslLibRoutine(t)}return f}copyVec(){const a=this.context.outputTextureLayout.shape.length;let d="";for(let h=0;h<a;++h)d+=`
        dest[${h}] = src[${h}];
        `;const f=`
      void copyVec(int src[${a}], out int dest[${a}]) {
        ${d}
      }
      `;return{copyVec:new r.GlslLibRoutine(f)}}setVecItem(){const a=this.context.outputTextureLayout.shape.length;let d=`
        if(index < 0)
            index =${a} + index;
        if (index == 0)
            m[0] = value;
        `;for(let h=1;h<a-1;++h)d+=`
        else if (index == ${h})
            m[${h}] = value;
            `;d+=`
        else
            m[${a-1}] = value;
        `;const f=`
      void setVecItem(out int m[${a}], int index, int value) {
        ${d}
      }
        `;return{setVecItem:new r.GlslLibRoutine(f)}}getVecItem(){const a=this.context.outputTextureLayout.shape.length;let d=`
        if(index < 0)
            index = ${a} + index;
        if (index == 0)
            return m[0];
      `;for(let h=1;h<a-1;++h)d+=`
        else if (index == ${h})
            return m[${h}];
      `;d+=`
        else
            return m[${a-1}];
        `;const f=`
      int getVecItem(int m[${a}], int index) {
        ${d}
      }
    `;return{getVecItem:new r.GlslLibRoutine(f)}}}e.VecGlslLib=i},7860:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLInferenceHandler=void 0;const r=n(1315),i=n(9240),o=n(7273),a=n(9),d=n(7379),f=n(2488),h=n(540),p=n(3314),s=n(5639);e.WebGLInferenceHandler=class{constructor(t){this.session=t,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(t,l){return(0,p.calculateTextureWidthAndHeight)(this.session.layoutStrategy,t,l)}executeProgram(t,l){if(l.length<t.inputNames.length)throw new Error(`Input size mustn't be less than ${t.inputNames.length}.`);if(t.inputNames.length!==t.inputTypes.length)throw new Error("input names size does not match input types");const u=[];for(let v=0;v<t.inputNames.length;++v)u[v]=this.getOrCreateTextureData(l[v],t.inputTypes[v]);const g=((v,T)=>{const w=T.map(x=>`${x.unpackedShape.join(",")};${x.width}x${x.height}`).join("_");let S=v.name;return v.cacheHint&&(S+="["+v.cacheHint+"]"),S+=":"+w,S})(t,u);let m=this.session.programManager.getArtifact(g);const _=m?m.programInfo:typeof t.get=="function"?t.get():t,b=(0,p.createTextureLayoutFromTextureType)(this.session.layoutStrategy,_.output.dims,_.output.textureType),y=this.createTextureData(b,_.output.type);return m||(m=this.session.programManager.build(_,u,y),this.session.programManager.setArtifact(g,m)),this.runProgram(m,u,y),y}run(t,l){return this.executeProgram(t,l).tensor}runProgram(t,l,u){for(let g=0;g<l.length;++g)if(!!l[g].isPacked!=(t.programInfo.inputTypes[g]===s.TextureType.packed))throw new Error(`input[${g}] property packed inconsistent`);if(!!u.isPacked!=(t.programInfo.output.textureType===s.TextureType.packed))throw new Error("output property packed inconsistent");this.session.programManager.run(t,l,u)}getOrCreateTextureData(t,l){let u=this.getTextureData(t.dataId,l===s.TextureType.packed);if(!u&&(u=this.getTextureData(t.dataId,l!==s.TextureType.packed),u))return l===s.TextureType.packed?this.pack(u):this.unpack(u);if(!u){const g=(0,p.createTextureLayoutFromTextureType)(this.session.layoutStrategy,t.dims,l);if(l===s.TextureType.packedLastDimension){const b=t.dims;if(b.length===4){const y=[b[0],Math.ceil(b[1]*b[2]*b[3]/4)],v=(0,p.createTextureLayoutFromTextureType)(this.session.layoutStrategy,y,l);let T=t.numberData;if(b[1]*b[2]*b[3]%4!=0){const w=b[0],S=b[1]*b[2]*b[3],x=Math.ceil(S*1/4)*4;T=new Float32Array(w*x);for(let P=0;P<w;++P){const I=P*S,N=P*x+P%1*S;T.set(t.numberData.subarray(I,I+S),N)}}return this.createTextureData(v,t.type,T,t,1)}}if(l===s.TextureType.packed){const m=(0,p.createTextureLayoutFromShape)(this.session.layoutStrategy,t.dims,1,[],{reverseWH:!0}),_=this.createTextureData(m,t.type,t.numberData,t,1);u=this.pack(_)}else u=this.createTextureData(g,t.type,t.numberData,t,1)}return u}createTextureDataFromLayoutBindTensor(t,l,u,g){return this.createTextureData(t,l,u,g,1)}createTextureData(t,l,u,g,m){r.Logger.verbose("InferenceHandler",`Creating TextureData: layout:[${JSON.stringify(t)}]`);const _=this.session.textureManager.createTextureFromLayout(l,t,u,m);return this.createTextureDataFromTexture(t,l,_,g)}reshapeUnpacked(t,l){const u=this.getOrCreateTextureData(t,s.TextureType.unpacked),g={channels:u.channels,height:u.height,width:u.width,shape:l.length!==0?l:[1],strides:o.ShapeUtil.computeStrides(l),unpackedShape:l};return this.createTextureDataFromTexture(g,t.type,u.texture).tensor}reshapePacked(t,l){const u=this.getOrCreateTextureData(t,s.TextureType.packed);if((0,d.isReshapeCheap)(t.dims,l)){const y={channels:u.channels,height:u.height,width:u.width,shape:l.length!==0?l:[1],strides:o.ShapeUtil.computeStrides(l),unpackedShape:l,isPacked:!0};return this.createTextureDataFromTexture(y,t.type,u.texture).tensor}const g=(0,d.processDims3D)(t.dims),m=(0,d.processDims3D)(l),_=this.reshapePacked(t,g),b=this.run((0,d.createPackedReshape3DProgramInfoLoader)(this,_,m),[_]);return this.reshapePacked(b,l)}cast(t,l){const u=this.getOrCreateTextureData(t,s.TextureType.unpacked);return this.createTextureDataFromTexture(u,l,u.texture).tensor}createTextureDataFromTexture(t,l,u,g,m){const _=Object.assign(Object.assign({},t),{tensor:g||new i.Tensor(t.unpackedShape,l,b=>this.readTexture(_),async b=>this.readTextureAsync(_),void 0,m),texture:u});return this.setTextureData(_.tensor.dataId,_,t.isPacked),_}getTextureData(t,l=!1){return this.session.isInitializer(t)?this.session.getTextureData(t,l):l?this.packedTextureDataCache.get(t):this.unpackedTextureDataCache.get(t)}setTextureData(t,l,u=!1){this.session.isInitializer(t)?this.session.setTextureData(t,l,u):(u?this.packedTextureDataCache:this.unpackedTextureDataCache).set(t,l)}isTextureLayoutCached(t,l=!1){return!!this.getTextureData(t.dataId,l)}dispose(){this.session.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(t=>this.session.textureManager.releaseTexture(t)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(t=>this.session.textureManager.releaseTexture(t)),this.unpackedTextureDataCache=new Map}readTexture(t){return t.isPacked?this.readTexture(this.unpack(t)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTexture(t,t.tensor.type,t.channels):this.session.textureManager.readUint8TextureAsFloat((0,f.encodeAsUint8)(this,t))}async readTextureAsync(t){return t.isPacked?this.readTextureAsync(this.unpack(t)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTextureAsync(t,t.tensor.type,t.channels):this.session.textureManager.readUint8TextureAsFloat((0,f.encodeAsUint8)(this,t))}pack(t){return this.executeProgram((0,a.createPackProgramInfoLoader)(this,t.tensor),[t.tensor])}unpack(t){return this.executeProgram((0,h.createUnpackProgramInfoLoader)(this,t.tensor),[t.tensor])}}},4110:function(c,e,n){var r=this&&this.__createBinding||(Object.create?function(J,X,te,oe){oe===void 0&&(oe=te);var ae=Object.getOwnPropertyDescriptor(X,te);ae&&!("get"in ae?!X.__esModule:ae.writable||ae.configurable)||(ae={enumerable:!0,get:function(){return X[te]}}),Object.defineProperty(J,oe,ae)}:function(J,X,te,oe){oe===void 0&&(oe=te),J[oe]=X[te]}),i=this&&this.__setModuleDefault||(Object.create?function(J,X){Object.defineProperty(J,"default",{enumerable:!0,value:X})}:function(J,X){J.default=X}),o=this&&this.__importStar||function(J){if(J&&J.__esModule)return J;var X={};if(J!=null)for(var te in J)te!=="default"&&Object.prototype.hasOwnProperty.call(J,te)&&r(X,J,te);return i(X,J),X};Object.defineProperty(e,"__esModule",{value:!0}),e.WEBGL_OP_RESOLVE_RULES=void 0;const a=n(8817),d=o(n(5194)),f=n(4752),h=n(6668),p=n(9754),s=n(5042),t=n(6742),l=n(4125),u=n(6149),g=n(5378),m=n(6981),_=n(7413),b=n(7006),y=n(8276),v=n(5565),T=n(2834),w=n(1010),S=n(8126),x=n(2801),P=n(565),I=n(2444),N=n(815),L=n(564),E=n(5416),M=n(1240),k=n(5944),A=n(5707),R=o(n(9087)),K=n(7862),Z=n(3980);e.WEBGL_OP_RESOLVE_RULES=[["Abs","","6+",R.abs],["Acos","","7+",R.acos],["Add","","7+",d.add],["And","","7+",d.and],["Asin","","7+",R.asin],["Atan","","7+",R.atan],["AveragePool","","7+",T.averagePool,T.parseAveragePoolAttributes],["BatchNormalization","","7+",a.batchNormalization,a.parseBatchNormalizationAttributes],["Cast","","6+",f.cast,f.parseCastAttributes],["Ceil","","6+",R.ceil],["Clip","","6-10",R.clip,R.parseClipAttributes],["Clip","","11+",R.clipV11],["Concat","","4+",h.concat,h.parseConcatAttributes],["Conv","","1+",p.conv,p.parseConvAttributes],["ConvTranspose","","1+",s.convTranspose,s.parseConvTransposeAttributes],["Cos","","7+",R.cos],["Div","","7+",d.div],["Dropout","","7+",R.identity],["DepthToSpace","","1+",t.depthToSpace,t.parseDepthToSpaceAttributes],["Equal","","7+",d.equal],["Elu","","6+",R.elu,R.parseEluAttributes],["Exp","","6+",R.exp],["Flatten","","1+",l.flatten,l.parseFlattenAttributes],["Floor","","6+",R.floor],["FusedConv","com.microsoft","1+",p.conv,p.parseConvAttributes],["Gather","","1+",u.gather,u.parseGatherAttributes],["Gemm","","7-10",g.gemm,g.parseGemmAttributesV7],["Gemm","","11+",g.gemm,g.parseGemmAttributesV11],["GlobalAveragePool","","1+",T.globalAveragePool,T.parseGlobalAveragePoolAttributes],["GlobalMaxPool","","1+",T.globalMaxPool],["Greater","","7+",d.greater],["Identity","","1+",R.identity],["ImageScaler","","1+",m.imageScaler,m.parseImageScalerAttributes],["InstanceNormalization","","6+",_.instanceNormalization,_.parseInstanceNormalizationAttributes],["LeakyRelu","","6+",R.leakyRelu,R.parseLeakyReluAttributes],["Less","","7+",d.less],["LRN","","1+",b.lrn,b.parseLrnAttributes],["Log","","6+",R.log],["MatMul","","1+",y.matMul,y.parseMatMulAttributes],["MaxPool","","1+",T.maxPool,T.parseMaxPoolAttributes],["Mul","","7+",d.mul],["Neg","","6+",R.neg],["Not","","1+",R.not],["Or","","7+",d.or],["Pad","","2-10",v.padV2,v.parsePadAttributesV2],["Pad","","11+",v.padV11,v.parsePadAttributesV11],["Pow","","7+",d.pow],["PRelu","","7+",d.pRelu],["ReduceLogSum","","1+",w.reduceLogSum,w.parseReduceAttributes],["ReduceMax","","1+",w.reduceMax,w.parseReduceAttributes],["ReduceMean","","1+",w.reduceMean,w.parseReduceAttributes],["ReduceMin","","1+",w.reduceMin,w.parseReduceAttributes],["ReduceProd","","1+",w.reduceProd,w.parseReduceAttributes],["ReduceSum","","1-12",w.reduceSum,w.parseReduceAttributes],["ReduceSumSquare","","1+",w.reduceLogSumSquare,w.parseReduceAttributes],["Relu","","6+",R.relu],["Reshape","","5+",S.reshape],["Resize","","10",x.resize,x.parseResizeAttributesV10],["Resize","","11+",x.resize,x.parseResizeAttributesV11],["Shape","","1+",P.shape],["Sigmoid","","6+",R.sigmoid],["Sin","","7+",R.sin],["Slice","","10+",I.sliceV10],["Slice","","1-9",I.slice,I.parseSliceAttributes],["Softmax","","1-12",N.softmax,N.parseSoftmaxAttributes],["Softmax","","13+",N.softmaxV13,N.parseSoftmaxAttributesV13],["Split","","2-12",L.split,L.parseSplitAttributes],["Sqrt","","6+",R.sqrt],["Squeeze","","1-12",E.squeeze,E.parseSqueezeAttributes],["Squeeze","","13+",E.squeezeV13],["Sub","","7+",d.sub],["Sum","","6+",M.sum],["Tan","","7+",R.tan],["Tanh","","6+",R.tanh],["Tile","","6+",k.tile],["Transpose","","1+",A.transpose,A.parseTransposeAttributes],["Upsample","","7-8",Z.upsample,Z.parseUpsampleAttributesV7],["Upsample","","9",Z.upsample,Z.parseUpsampleAttributesV9],["Unsqueeze","","1-12",K.unsqueeze,K.parseUnsqueezeAttributes],["Unsqueeze","","13+",K.unsqueezeV13],["Xor","","7+",d.xor]]},8817:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseBatchNormalizationAttributes=e.batchNormalization=void 0;const r=n(4910),i=n(6757),o=n(5639),a={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[o.TextureType.unpacked,o.TextureType.unpacked,o.TextureType.unpacked,o.TextureType.unpacked,o.TextureType.unpacked]};e.batchNormalization=(h,p,s)=>(f(p),[h.run(Object.assign(Object.assign({},a),{cacheHint:s.cacheKey,get:()=>d(h,p,s)}),p)]),e.parseBatchNormalizationAttributes=h=>{const p=h.attributes.getFloat("epsilon",1e-5),s=h.attributes.getFloat("momentum",.9),t=h.attributes.getInt("spatial",1);return(0,r.createAttributeWithCacheKey)({epsilon:p,momentum:s,spatial:t})};const d=(h,p,s)=>{const t=(0,i.getGlsl)(h.session.backend.glContext.version),l=p[0].dims.length,[u,g]=h.calculateTextureWidthAndHeight(p[1].dims,o.TextureType.unpacked),m=`
  float process(int[${l}] indices) {
    vec2 position = offsetToCoords(indices[1], ${u}, ${g});
    float scale = getColorAsFloat(${t.texture2D}(Scale, position));
    float mean = getColorAsFloat(${t.texture2D}(Mean, position));
    float variance = getColorAsFloat(${t.texture2D}(Variance, position));
    float b = getColorAsFloat(${t.texture2D}(B, position));

    return scale * ( (_A(indices) - mean) / sqrt(variance + float(${s.epsilon})) ) + b;
  }`;return Object.assign(Object.assign({},a),{output:{dims:p[0].dims,type:p[0].type,textureType:o.TextureType.unpacked},shaderSource:m})},f=h=>{if(!h||h.length!==5)throw new Error("BatchNormalization requires 5 inputs.");const p=h[0],s=h[1],t=h[2],l=h[3],u=h[4];if(p.dims.length<3||s.dims.length!==1||t.dims.length!==1||l.dims.length!==1||u.dims.length!==1)throw new Error("invalid input shape.");if(s.dims[0]!==p.dims[1]||t.dims[0]!==p.dims[1]||l.dims[0]!==p.dims[1]||u.dims[0]!==p.dims[1])throw new Error("invalid input shape.");if(p.type!=="float32"&&p.type!=="float64"||s.type!=="float32"&&s.type!=="float64"||t.type!=="float32"&&t.type!=="float64"||l.type!=="float32"&&l.type!=="float64"||u.type!=="float32"&&u.type!=="float64")throw new Error("invalid input tensor types.")}},5194:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.xor=e.sub=e.pRelu=e.pow=e.or=e.mul=e.less=e.greater=e.equal=e.div=e.and=e.add=e.glslPRelu=e.glslPow=e.glslXor=e.glslOr=e.glslAnd=e.glslLess=e.glslGreater=e.glslEqual=e.glslSub=e.glslMul=e.glslDiv=e.glslAdd=void 0;const r=n(7273),i=n(1997),o=n(6757),a=n(5639);function d(){const T="add_";return{body:`
  float ${T}(float a, float b) {
    return a + b;
  }
  vec4 ${T}(vec4 v1, vec4 v2) {
    return v1 + v2;
  }
  `,name:T,type:i.FunctionType.ValueBased}}function f(){const T="div_";return{body:`
  float ${T}(float a, float b) {
    return a / b;
  }
  vec4 ${T}(vec4 v1, vec4 v2) {
    return v1 / v2;
  }
  `,name:T,type:i.FunctionType.ValueBased}}function h(){const T="mul_";return{body:`
  float ${T}(float a, float b) {
    return a * b;
  }
  vec4 ${T}(vec4 v1, vec4 v2) {
    return v1 * v2;
  }
  `,name:T,type:i.FunctionType.ValueBased}}function p(){const T="sub_";return{body:`
  float ${T}(float a, float b) {
    return a - b;
  }
  vec4 ${T}(vec4 v1, vec4 v2) {
    return v1 - v2;
  }
  `,name:T,type:i.FunctionType.ValueBased}}function s(){const T="equal_";return{body:`
  float ${T}(float a, float b) {
    return float(a == b);
  }
  vec4 ${T}(vec4 v1, vec4 v2) {
    return vec4(equal(v1, v2));
  }
  `,name:T,type:i.FunctionType.ValueBased}}function t(){const T="greater_";return{body:`
  float ${T}(float a, float b) {
    return float(a > b);
  }
  vec4 ${T}(vec4 v1, vec4 v2) {
    return vec4( v1.r > v2.r ,
      v1.g > v2.g,
      v1.b > v2.b,
      v1.a > v2.a );
  }
  `,name:T,type:i.FunctionType.ValueBased}}function l(){const T="less_";return{body:`
  float ${T}(float a, float b) {
    return float(a < b);
  }
  vec4 ${T}(vec4 v1, vec4 v2) {
    return vec4( v1.r < v2.r ,
                v1.g < v2.g,
                v1.b < v2.b,
                v1.a < v2.a );
  }
  `,name:T,type:i.FunctionType.ValueBased}}function u(){const T="and_";return{body:`
  float ${T}(float a, float b) {
    return float( bool(a) && bool(b) );
  }
  vec4 ${T}(vec4 v1, vec4 v2) {
    bvec4 b1 = bvec4(v1);
    bvec4 b2 = bvec4(v2);
    return vec4( b1.r && b2.r ,
                b1.g && b2.g,
                b1.b && b2.b,
                b1.a && b2.a );
  }
  `,name:T,type:i.FunctionType.ValueBased}}function g(){const T="or_";return{body:`
  float ${T}(float a, float b) {
    return float( bool(a) || bool(b) );
  }
  vec4 ${T}(vec4 v1, vec4 v2) {
    bvec4 b1 = bvec4(v1);
    bvec4 b2 = bvec4(v2);
    return vec4( b1.r || b2.r ,
                b1.g || b2.g,
                b1.b || b2.b,
                b1.a || b2.a );
  }
  `,name:T,type:i.FunctionType.ValueBased}}function m(){const T="xor_";return{body:`
  float ${T}(float a, float b) {
    return float( bool(a) ^^ bool(b) );
  }
  vec4 ${T}(vec4 v1, vec4 v2) {
    bvec4 b1 = bvec4(v1);
    bvec4 b2 = bvec4(v2);
    return vec4( b1.r ^^ b2.r ,
                b1.g ^^ b2.g,
                b1.b ^^ b2.b,
                b1.a ^^ b2.a );
  }
  `,name:T,type:i.FunctionType.ValueBased}}function _(){return function(T){const w=`${T}_`;return{body:`
  float ${w}(float a, float b) {
    return ${T}(a, b);
  }
  vec4 ${w}(vec4 v1, vec4 v2) {
    return ${T}(v1, v2);
  }
  `,name:w,type:i.FunctionType.ValueBased}}("pow")}function b(){const T="prelu_";return{body:`
  float ${T}(float a, float b) {
    return a < 0.0 ? a * b: a;
  }
  vec4 ${T}(vec4 v1, vec4 v2) {
    return vec4(
      v1.r < 0.0 ? v1.r * v2.r: v1.r,
      v1.g < 0.0 ? v1.g * v2.g: v1.g,
      v1.b < 0.0 ? v1.b * v2.b: v1.b,
      v1.a < 0.0 ? v1.a * v2.a: v1.a
      );
  }
  `,name:T,type:i.FunctionType.ValueBased}}e.glslAdd=d,e.glslDiv=f,e.glslMul=h,e.glslSub=p,e.glslEqual=s,e.glslGreater=t,e.glslLess=l,e.glslAnd=u,e.glslOr=g,e.glslXor=m,e.glslPow=_,e.glslPRelu=b;const y=(T,w,S,x=w[0].type,P)=>{const I=T.session.pack?a.TextureType.packed:a.TextureType.unpacked;return{name:S.name,inputNames:["A","B"],inputTypes:[I,I],cacheHint:P,get:()=>v(T,w,S,x)}},v=(T,w,S,x=w[0].type)=>{const P=T.session.pack?a.TextureType.packed:a.TextureType.unpacked,I=!r.ShapeUtil.areEqual(w[0].dims,w[1].dims);let N=w[0].dims;const L=T.session.pack;if(I){const k=r.BroadcastUtil.calcShape(w[0].dims,w[1].dims,!1);if(!k)throw new Error("Can't perform binary op on the given tensors");N=k;const A=N.length,R=w[0].dims.length!==0?w[0].dims.length:1,K=w[1].dims.length!==0?w[1].dims.length:1,Z=w[0].dims.length!==0?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",J=w[1].dims.length!==0?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",X=(0,o.getGlsl)(T.session.backend.glContext.version),te=L?`
      ${S.body}
      void main() {
        vec4 a = getAAtOutCoords();
        vec4 b = getBAtOutCoords();
        vec4 result = ${S.name}(a, b);
        ${X.output} = result;
      }`:`
      ${S.body}
      float process(int indices[${A}]) {
        int aindices[${R}];
        int bindices[${K}];
        ${Z}
        ${J}
        return ${S.name}(_A(aindices), _B(bindices));
      }`;return{name:S.name,inputNames:["A","B"],inputTypes:[P,P],output:{dims:N,type:x,textureType:P},shaderSource:te,hasMain:L}}const E=(0,o.getGlsl)(T.session.backend.glContext.version),M=`
    ${S.body}
    void main() {
      vec4 v1 = ${E.texture2D}(A, TexCoords);
      vec4 v2 = ${E.texture2D}(B, TexCoords);
      vec4 result = ${S.name}(v1, v2);
      ${E.output} = result;
    }
    `;return{name:S.name,inputNames:["A","B"],inputTypes:[P,P],output:{dims:w[0].dims,type:x,textureType:P},shaderSource:M,hasMain:!0}};e.add=(T,w)=>[T.run(y(T,w,d()),w)],e.and=(T,w)=>[T.run(y(T,w,u(),"bool"),w)],e.div=(T,w)=>[T.run(y(T,w,f()),w)],e.equal=(T,w)=>[T.run(y(T,w,s(),"bool"),w)],e.greater=(T,w)=>[T.run(y(T,w,t(),"bool"),w)],e.less=(T,w)=>[T.run(y(T,w,l(),"bool"),w)],e.mul=(T,w)=>[T.run(y(T,w,h()),w)],e.or=(T,w)=>[T.run(y(T,w,g(),"bool"),w)],e.pow=(T,w)=>[T.run(y(T,w,_()),w)],e.pRelu=(T,w)=>[T.run(y(T,w,b()),w)],e.sub=(T,w)=>[T.run(y(T,w,p()),w)],e.xor=(T,w)=>[T.run(y(T,w,m(),"bool"),w)]},4752:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseCastAttributes=e.cast=void 0;const r=n(7273);e.cast=(o,a,d)=>(i(a),[o.cast(a[0],d)]),e.parseCastAttributes=o=>r.ProtoUtil.tensorDataTypeFromProto(o.attributes.getInt("to"));const i=o=>{if(!o||o.length!==1)throw new Error("Cast requires 1 input.");if(o[0].type==="string")throw new Error("Invalid input type.")}},4595:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createPackedConcatProgramInfoLoader=void 0;const r=n(6757),i=n(5639),o=n(432),a=n(5614);e.createPackedConcatProgramInfoLoader=(f,h,p)=>{const s=(t=h.length,l=p.cacheKey,{name:"Concat (packed)",inputNames:Array.from({length:t},(u,g)=>`X${g}`),inputTypes:Array(t).fill(i.TextureType.packed),cacheHint:l});var t,l;return Object.assign(Object.assign({},s),{get:()=>((u,g,m,_)=>{const b=m[0].dims.slice();if(_>=b.length||_<-1*b.length)throw new Error("axis specified for concat doesn't match input dimensionality");_<0&&(_=b.length+_);const y=b.slice(0);for(let Z=1;Z<m.length;Z++){const J=m[Z].dims.slice();for(let X=0;X<b.length;X++)if(X===_)y[_]+=J[X];else if(b[X]!==J[X])throw new Error("non concat dimensions must match")}const v=y.length,T=(0,a.getChannels)("coords",v),w=(0,o.getCoordsDataType)(v),S=(0,a.unpackFromChannel)(),x=m.map(Z=>Z.dims),P=(0,o.getGlChannels)(v),I=new Array(x.length-1);I[0]=x[0][_];for(let Z=1;Z<I.length;Z++)I[Z]=I[Z-1]+x[Z][_];const N=P[_],L=P.slice(-2),E=P.join();let M=`if (${N} < ${I[0]}) {
        return getChannel(
            getX0(${E}), vec2(${L.join()}));
        }`;for(let Z=1;Z<I.length;Z++){const J=I[Z-1];M+=`
            if (${N} < ${I[Z]}  && ${N} >= ${I[Z-1]}) {
              return getChannel(
                getX${Z}(${d(P,N,J)}),
                vec2(${d(L,N,J)}));
            }`}const k=I.length,A=I[I.length-1];M+=`
            return getChannel(
              getX${k}(${d(P,N,A)}),
              vec2(${d(L,N,A)}));`;const R=(0,r.getGlsl)(u.session.backend.glContext.version),K=`
          ${S}
          float getValue(${P.map(Z=>"int "+Z)}) {
            ${M}
          }

          void main() {
            ${w} coords = getOutputCoords();
            int lastDim = coords.${P[v-1]};
            coords.${P[v-1]} = coords.${P[v-2]};
            coords.${P[v-2]} = lastDim;

            vec4 result = vec4(getValue(${T}), 0., 0., 0.);

            ${T[v-1]} = ${T[v-1]} + 1;
            if (${T[v-1]} < ${y[v-1]}) {
              result.g = getValue(${T});
            }

            ${T[v-2]} = ${T[v-2]} + 1;
            if (${T[v-2]} < ${y[v-2]}) {
              result.a = getValue(${T});
            }

            ${T[v-1]} = ${T[v-1]} - 1;
            if (${T[v-2]} < ${y[v-2]} &&
                ${T[v-1]} < ${y[v-1]}) {
              result.b = getValue(${T});
            }
            ${R.output} = result;
          }
        `;return Object.assign(Object.assign({},g),{output:{dims:y,type:m[0].type,textureType:i.TextureType.packed},shaderSource:K,hasMain:!0})})(f,s,h,p.axis)})};const d=(f,h,p)=>{const s=f.indexOf(h);return f.map((t,l)=>l===s?`${t} - ${p}`:t).join()}},6668:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseConcatAttributes=e.concat=void 0;const r=n(4910),i=n(5639),o=n(4595);e.concat=(t,l,u)=>(s(l),t.session.pack&&l[0].dims.length>1?[t.run((0,o.createPackedConcatProgramInfoLoader)(t,l,u),l)]:[t.run(a(t,l,u),l)]);const a=(t,l,u)=>{const g=(m=l.length,_=u.cacheKey,{name:"Concat",inputNames:Array.from({length:m},(b,y)=>`X${y}`),inputTypes:Array(m).fill(i.TextureType.unpacked),cacheHint:_});var m,_;return Object.assign(Object.assign({},g),{get:()=>((b,y,v,T)=>{const w=v[0].dims.slice();if(T>=w.length||T<-1*w.length)throw new Error("axis specified for concat doesn't match input dimensionality");T<0&&(T=w.length+T);const S=w.slice(0);for(let E=1;E<v.length;E++){const M=v[E].dims.slice();for(let k=0;k<w.length;k++)if(k===T)S[T]+=M[k];else if(w[k]!==M[k])throw new Error("non concat dimensions must match")}const x=S.length,P=new Array(v.length);let I=0;for(let E=0;E<P.length;++E)I+=v[E].dims[T],P[E]=I;let N="";N=v.length<5?d(P):f(P);const L=`
        ${h(v.length,x)}
        ${p(P)}
        ${N}
        float process(int indices[${x}]) {
          int textureIndex = getTextureWhereDataResides (indices[${T}]);

          if(textureIndex != 0) {
            indices[${T}] = indices[${T}] - int(getSizeInConcatAxisValueFromIndex(textureIndex-int(1)));
          }

          return fetchDataFromCorrectTexture(textureIndex, indices);
        }`;return Object.assign(Object.assign({},y),{output:{dims:S,type:v[0].type,textureType:i.TextureType.unpacked},shaderSource:L})})(0,g,l,u.axis)})},d=t=>`int getTextureWhereDataResides(int index) {
      ${t.map((l,u)=>`if(index<${l}) {return ${u};}
`).join("")}
    }`,f=t=>d(t),h=(t,l)=>{const u=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${l}]) {`];for(let g=0;g<t;++g)g===0?u.push(`	if (textureIndex == ${g}) { return _X${g}(indices); }`):g===t-1?u.push(`	else { return _X${g}(indices); }`):u.push(`	else if (textureIndex == ${g}) { return _X${g}(indices); }`);return u.push("	}"),u.join(`
`)},p=t=>{const l=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let u=0;u<t.length;++u)u===0?l.push(`	if (index == ${u}) { return ${t[u]}; }`):u===t.length-1?l.push(`	else { return ${t[u]}; }`):l.push(`	else if (index == ${u}) { return ${t[u]}; }`);return l.push("	}"),l.join(`
`)};e.parseConcatAttributes=t=>(0,r.createAttributeWithCacheKey)({axis:t.attributes.getInt("axis")});const s=t=>{if(!t||t.length<1)throw new Error("too few inputs");const l=t[0].type,u=t[0].dims.length;if(l==="string")throw new Error("string tensor is not supported yet");for(const g of t){if(g.type!==l)throw new Error("input tensors should be one type");if(g.dims.length!==u)throw new Error("input tensors should have the same shape")}}},7825:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createUnpackedGroupedConvProgramInfoLoader=void 0;const r=n(1315),i=n(6757),o=n(5639),a=n(9754),d=n(2150);e.createUnpackedGroupedConvProgramInfoLoader=(f,h,p)=>{const s=(t=h.length>2,l=p.cacheKey,{name:"GroupedConv",inputNames:t?["X","W","Bias"]:["X","W"],inputTypes:t?[o.TextureType.unpacked,o.TextureType.unpacked,o.TextureType.unpacked]:[o.TextureType.unpacked,o.TextureType.unpacked],cacheHint:l});var t,l;return Object.assign(Object.assign({},s),{get:()=>((u,g,m,_)=>{const b=g.length>2?"value += getBias(output_channel);":"",y=g[0].dims.slice(),v=g[1].dims.slice(),T=v[0]/_.group;r.Logger.verbose("GroupedConv",`autpPad:${_.autoPad}, dilations:${_.dilations}, group:${_.group}, kernelShape:${_.kernelShape}, pads:${_.pads}, strides:${_.strides}`);const w=(0,a.calculateOutputShape)(y,v,_.dilations,_.pads,_.strides),S=(0,i.getGlsl)(u.session.backend.glContext.version),{activationFunction:x,applyActivation:P}=(0,d.getActivationSnippet)(_),I=`
  const ivec2 strides = ivec2(${_.strides[0]}, ${_.strides[1]});
  const ivec2 pads = ivec2(${_.pads[0]}, ${_.pads[1]});
  ${x}
  void main() {
    ivec4 coords = getOutputCoords();
    int batch = coords.x;
    int output_channel = coords.y;
    ivec2 xRCCorner = coords.zw * strides - pads;
    int group_id = output_channel / ${T};

    float value = 0.0;
    for (int wInChannel = 0; wInChannel < ${v[1]}; wInChannel++) {
      int input_channel = group_id * ${v[1]} + wInChannel;
      for (int wHeight = 0; wHeight < ${v[2]}; wHeight++) {
        int xHeight = xRCCorner.x + wHeight * ${_.dilations[0]};

        if (xHeight < 0 || xHeight >= ${y[2]}) {
          continue;
        }

        for (int wWidth = 0; wWidth < ${v[3]}; wWidth++) {
          int xWidth = xRCCorner.y + wWidth * ${_.dilations[1]};
          if (xWidth < 0 || xWidth >= ${y[3]}) {
            continue;
          }

          float xVal = getX(batch, input_channel, xWidth, xHeight);
          float wVal = getW(output_channel, wInChannel, wWidth, wHeight);
          value += xVal*wVal;
        }
      }
    }
    ${b}
    ${P}
    ${S.output} = vec4(value, .0, .0, .0);
  }
`;return Object.assign(Object.assign({},m),{output:{dims:w,type:g[0].type,textureType:o.TextureType.unpacked},shaderSource:I,hasMain:!0})})(f,h,s,p)})}},7708:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.conv2DPacked=e.conv2DPackedPointwise=void 0;const r=n(9754),i=n(5950),o=n(5632);e.conv2DPackedPointwise=(a,d,f)=>{const h=d[0].dims,p=d[1].dims,s=(0,r.calculateOutputShape)(h,p,f.dilations,f.pads,f.strides),t=a.reshapePacked(d[0],[h[1],h[2]*h[3]]),l=a.reshapePacked(d[1],[p[0],p[1]]),u=d.length>2?[l,t,d[2]]:[l,t],g=a.run((0,o.createPackedMatmulProgramInfoLoader)(a,u,f),u);return a.reshapePacked(g,s)},e.conv2DPacked=(a,d,f)=>{const h=d[0].dims,p=d[1].dims,s=(0,r.calculateOutputShape)(h,p,f.dilations,f.pads,f.strides),t=a.run((0,i.createPackedIm2ColProgramInfoLoader)(a,d[0],d[1],s,f),[d[0]]),l=a.reshapePacked(d[1],[p[0],p[1]*p[2]*p[3]]),u=d.length===3?[l,t,d[2]]:[l,t],g=a.run((0,o.createPackedMatmulProgramInfoLoader)(a,u,f),u);return a.reshapePacked(g,s)}},5042:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseConvTransposeAttributes=e.convTranspose=void 0;const r=n(4910),i=n(6757),o=n(5639),a=n(2150),d=(l,u,g,m,_,b)=>(l-1)*u+g+(m-1)*_+1-b,f=(l,u,g,m,_)=>{const b=Math.floor(l/2);u==="SAME_UPPER"?(g[m]=b,g[_]=l-b):u==="SAME_LOWER"&&(g[m]=l-b,g[_]=b)};e.convTranspose=(l,u,g)=>(t(u,g),h(l,u,g));const h=(l,u,g)=>{const m=s(g,u);return[p(l,u,m)]},p=(l,u,g)=>l.run(((m,_,b)=>{const y=(v=_.length>2,T=b.cacheKey,{name:"ConvTranspose",inputNames:v?["X","W","B"]:["X","W"],inputTypes:v?[o.TextureType.unpacked,o.TextureType.unpacked,o.TextureType.unpacked]:[o.TextureType.unpacked,o.TextureType.unpacked],cacheHint:T});var v,T;return Object.assign(Object.assign({},y),{get:()=>((w,S,x,P)=>{const I=S.length>2?"getB(output_channel)":"0.0",N=S[0].dims,L=S[1].dims,E=L[1],M=L[0]/P.group,k=[S[0].dims[0],S[1].dims[1]*P.group,...P.outputShape],A=(0,i.getGlsl)(w.session.backend.glContext.version),{activationFunction:R,applyActivation:K}=(0,a.getActivationSnippet)(P),Z=`
  const ivec2 strides = ivec2(${P.strides[0]}, ${P.strides[1]});
  const ivec2 pads = ivec2(${P.pads[0]}, ${P.pads[1]});
  ${R}
  void main() {
    ivec4 coords = getOutputCoords();
    int batch = coords.x;
    int output_channel = coords.y;

    ivec2 loc = coords.zw + pads;

    int group_id = output_channel / ${E};
    int wOutChannel = output_channel - group_id * ${E};

    float value = ${I};
    for (int inChannelOffset = 0; inChannelOffset < ${M}; inChannelOffset++) {
      int input_channel = group_id * ${M} + inChannelOffset;
      for (int wWOff = 0; wWOff < ${L[2]}; wWOff++) {
        for (int wHOff = 0; wHOff < ${L[3]}; wHOff++) {
          ivec2 wOff = ivec2(wWOff * ${P.dilations[0]}, wHOff * ${P.dilations[1]});
          ivec2 wLoc = loc - wOff;
          ivec2 wLocIn = wLoc / strides;
          if (
            wLocIn * strides == wLoc &&
            wLocIn.x >= 0 && wLocIn.x < ${N[2]} &&
            wLocIn.y >= 0 && wLocIn.y < ${N[3]}
          ) {
            float xVal = getX(batch, input_channel, wLocIn.y, wLocIn.x);
            float wVal = getW(input_channel, wOutChannel, wHOff, wWOff);
            value += xVal * wVal;
          }
        }
      }
    }
    ${K}
    ${A.output} = vec4(value, .0, .0, .0);
  }
`;return Object.assign(Object.assign({},x),{output:{dims:k,type:S[0].type,textureType:o.TextureType.unpacked},shaderSource:Z,hasMain:!0})})(m,_,y,b)})})(l,u,g),u),s=(l,u)=>{const g=l.kernelShape.slice();if(l.kernelShape.length===0)for(let y=2;y<u[1].dims.length;++y)g.push(u[1].dims[y]);const m=l.pads.slice(),_=l.outputShape.slice();((y,v,T,w,S,x,P,I)=>{const N=y.length-2,L=I.length===0;for(let E=0;E<N;++E){const M=L?y[E+2]*x[E]:I[E],k=d(y[E+2],x[E],S[E],v[E],T[E],M);f(k,w,S,E,E+N),L&&I.push(x[E]*(y[E+2]-1)+P[E]+(v[E]-1)*T[E]+1-S[E]-S[E+N])}})(u[0].dims,g,l.dilations,l.autoPad,m,l.strides,l.outputPadding,_);const b=Object.assign({},l);return Object.assign(b,{kernelShape:g,pads:m,outputShape:_,cacheKey:l.cacheKey}),b};e.parseConvTransposeAttributes=l=>{const u=l.attributes,g=(0,a.parseInternalActivationAttributes)(u),m=u.getString("auto_pad","NOTSET"),_=u.getInts("dilations",[1,1]),b=u.getInt("group",1),y=u.getInts("kernel_shape",[]),v=u.getInts("output_padding",[0,0]),T=u.getInts("output_shape",[]),w=u.getInts("pads",[0,0,0,0]),S=u.getInts("strides",[1,1]);return(0,r.createAttributeWithCacheKey)(Object.assign({autoPad:m,dilations:_,group:b,kernelShape:y,outputPadding:v,outputShape:T,pads:w,strides:S},g))};const t=(l,u)=>{if(!l||l.length!==2&&l.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(l[0].dims.length!==4||l[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");if(l[0].dims[1]!==l[1].dims[0])throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");const g=l[1].dims[1]*u.group;if(l.length===3&&(l[2].dims.length!==1||l[2].dims[0]!==g))throw new Error("invalid bias");const m=l[0].dims.length-2;if(u.dilations.length!==m)throw new Error(`dilations should be ${m}D`);if(u.strides.length!==m)throw new Error(`strides should be ${m}D`);if(u.pads.length!==2*m)throw new Error(`pads should be ${2*m}D`);if(u.outputPadding.length!==m)throw new Error(`output_padding should be ${m}D`);if(u.kernelShape.length!==0&&u.kernelShape.length!==l[1].dims.length-2)throw new Error("invalid kernel shape");if(u.outputShape.length!==0&&u.outputShape.length!==l[0].dims.length-2)throw new Error("invalid output shape");if(l[0].type!=="float32"||l[1].type!=="float32")throw new Error("ConvTranspose input(X,W) should be float tensor");if(l.length===3&&l[2].type!=="float32")throw new Error("ConvTranspose input(bias) should be float tensor")}},9754:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseConvAttributes=e.conv=e.calculateOutputShape=void 0;const r=n(4910),i=n(7273),o=n(7825),a=n(7708),d=n(3281),f=n(2150),h=n(1625),p=n(8276);e.calculateOutputShape=(m,_,b,y,v)=>{const T=m[0],w=m.slice(2),S=w.length,x=_[0],P=_.slice(2).map((N,L)=>N+(N-1)*(b[L]-1)),I=w.map((N,L)=>N+y[L]+y[L+S]).map((N,L)=>Math.floor((N-P[L]+v[L])/v[L]));return[T,x].concat(...I)},e.conv=(m,_,b)=>(g(_,b),s(m,_,b));const s=(m,_,b)=>{const y=u(b,_),v=m.session.pack,T=y.kernelShape[0]===1&&y.kernelShape[1]===1;return y.group>1?[m.run((0,o.createUnpackedGroupedConvProgramInfoLoader)(m,_,y),_)]:T&&v?[t(m,_,y)]:v&&_[0].dims.length===4&&_[0].dims[0]===1&&!T?[(0,a.conv2DPacked)(m,_,y)]:[l(m,_,y)]},t=(m,_,b)=>{const y=_[0].dims,v=_[1].dims,T=(0,e.calculateOutputShape)(y,v,b.dilations,b.pads,b.strides),w=m.reshapeUnpacked(_[0],[y[1],y[2]*y[3]]),S=m.reshapeUnpacked(_[1],[v[0],v[1]]),x=_.length>2?[S,w,_[2]]:[S,w],P=m.run((0,p.createMatmulProgramInfoLoader)(x,b),x);return m.reshapeUnpacked(P,T)},l=(m,_,b)=>{const y=_[0].dims,v=_[1].dims,T=(0,e.calculateOutputShape)(y,v,b.dilations,b.pads,b.strides),w=m.run((0,h.createIm2ColProgramInfoLoader)(m,_[0],_[1],T,b),[_[0]]),S=_.length===3?[w,_[1],_[2]]:[w,_[1]];return m.run((0,d.createDotProductProgramInfoLoader)(m,_,T,b),S)},u=(m,_)=>{const b=m.kernelShape.slice();if(m.kernelShape.length===0)for(let T=2;T<_[1].dims.length;++T)b.push(_[1].dims[T]);const y=m.pads.slice();i.PoolConvUtil.adjustPadsBasedOnAutoPad(_[0].dims,m.strides,m.dilations,b,y,m.autoPad);const v=Object.assign({},m);return Object.assign(v,{kernelShape:b,pads:y,cacheKey:m.cacheKey}),v};e.parseConvAttributes=m=>{const _=m.attributes,b=(0,f.parseInternalActivationAttributes)(_),y=_.getString("auto_pad","NOTSET"),v=_.getInts("dilations",[1,1]),T=_.getInt("group",1),w=_.getInts("kernel_shape",[]),S=_.getInts("pads",[0,0,0,0]),x=_.getInts("strides",[1,1]);return(0,r.createAttributeWithCacheKey)(Object.assign({autoPad:y,dilations:v,group:T,kernelShape:w,pads:S,strides:x},b))};const g=(m,_)=>{if(!m||m.length!==2&&m.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(m[0].dims.length!==4||m[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");if(m[0].dims[1]!==m[1].dims[1]*_.group)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(m.length===3&&(m[2].dims.length!==1||m[1].dims[0]!==m[2].dims[0]))throw new Error("invalid bias");const b=m[0].dims.length-2;if(_.dilations.length!==b)throw new Error(`dilations should be ${b}D`);if(_.strides.length!==b)throw new Error(`strides should be ${b}D`);if(_.pads.length!==2*b)throw new Error(`pads should be ${2*b}D`);if(_.kernelShape.length!==0&&_.kernelShape.length!==m[1].dims.length-2)throw new Error("invalid kernel shape");if(m[0].type!=="float32"||m[1].type!=="float32")throw new Error("Conv input(X,W) should be float tensor");if(m.length===3&&m[2].type!=="float32")throw new Error("Conv input(bias) should be float tensor")}},6742:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseDepthToSpaceAttributes=e.depthToSpace=void 0;const r=n(5707);e.depthToSpace=(o,a,d)=>{i(a);const f=d.blocksize,h=f*f,p=d.mode==="DCR"?[0,3,4,1,5,2]:[0,1,4,2,5,3],s=d.mode==="DCR"?[a[0].dims[0],f,f,a[0].dims[1]/h,a[0].dims[2],a[0].dims[3]]:[a[0].dims[0],a[0].dims[1]/h,f,f,a[0].dims[2],a[0].dims[3]],t=o.reshapeUnpacked(a[0],s),l={perm:p,cacheKey:`${p}`},[u]=(0,r.transpose)(o,[t],l),g=[a[0].dims[0],a[0].dims[1]/h,a[0].dims[2]*f,a[0].dims[3]*f];return[o.reshapeUnpacked(u,g)]},e.parseDepthToSpaceAttributes=o=>{const a=o.attributes.getInt("blocksize");if(a<1)throw new Error(`blocksize must be >= 1, but got : ${a} for DepthToSpace`);const d=o.attributes.getString("mode","DCR");if(d!=="DCR"&&d!=="CRD")throw new Error(`unrecognized mode: ${d} for DepthToSpace`);return{mode:d,blocksize:a}};const i=o=>{if(o.length!==1)throw new Error(`DepthToSpace expect 1 inputs, but got ${o.length}`);if(o[0].type==="string"||o[0].dims.length!==4)throw new TypeError("DepthToSpace input should be a 4-D numeric tensor")}},3281:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createDotProductProgramInfoLoader=void 0;const r=n(7273),i=n(6757),o=n(5639),a=n(2150),d=n(1625);e.createDotProductProgramInfoLoader=(f,h,p,s)=>{const t=((l,u)=>({name:"ConvDotProduct",inputNames:l?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:l?[o.TextureType.unpacked,o.TextureType.packedLastDimension,o.TextureType.unpacked]:[o.TextureType.unpacked,o.TextureType.packedLastDimension],cacheKey:u.activationCacheKey}))(h.length>2,s);return Object.assign(Object.assign({},t),{get:()=>((l,u,g,m,_)=>{const b=g[0].dims,y=g[1].dims,v=[y[0],Math.ceil(b[1]*y[2]*y[3]/4)],T=(0,d.calculateIm2ColDims)(b,y,m),[w,S]=l.calculateTextureWidthAndHeight(v,o.TextureType.packedLastDimension),x=r.ShapeUtil.computeStrides(T),[P,I]=l.calculateTextureWidthAndHeight(T,o.TextureType.packedLastDimension),N=m.length,L=g.length<3?"0.0":"_B(b)",E=Math.ceil(b[1]*y[2]*y[3]/4),{activationFunction:M,applyActivation:k}=(0,a.getActivationSnippet)(_),A=(0,i.getGlsl)(l.session.backend.glContext.version),R=`
${M}
float process(int indices[${N}]) {
  int b[1];
  b[0] = indices[1];
  int im2col[4];
  im2col[0] = indices[0];
  im2col[1] = indices[2];
  im2col[2] = indices[3];
  int im2colOffset = im2col[0] * ${x[0]} + im2col[1] * ${x[1]} + im2col[2] * ${x[2]};
  int kernelOffset = indices[1] * ${v[1]};
  float value = ${L};
  for (int i = 0; i < ${E}; ++i) {
    vec2 im2colCoords = offsetToCoords(im2colOffset, ${P}, ${I});
    vec2 kernelCoords = offsetToCoords(kernelOffset, ${w}, ${S});
    value += dot(${A.texture2D}(Im2Col, im2colCoords), ${A.texture2D}(K, kernelCoords));
    ++im2colOffset;
    ++kernelOffset;
  }
  ${k}
  return value;
}`;return Object.assign(Object.assign({},u),{output:{dims:m,type:g[0].type,textureType:o.TextureType.unpacked},shaderSource:R})})(f,t,h,p,s)})}},4125:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseFlattenAttributes=e.flatten=void 0;const r=n(7273);e.flatten=(o,a,d)=>{i(a,d);const f=r.ShapeUtil.flattenShape(a[0].dims,d);return[o.reshapeUnpacked(a[0],f)]},e.parseFlattenAttributes=o=>o.attributes.getInt("axis",1);const i=(o,a)=>{if(!o||o.length!==1)throw new Error("Flatten requires 1 input.");const d=o[0].dims.length;if(d===0)throw new Error("scalar tensor is not supported.");if(a<-d||a>d)throw new Error("Invalid axis");if(o[0].type==="string")throw new Error("string tensor is not supported.")}},2150:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseInternalActivationAttributes=e.getActivationSnippet=void 0;const r=n(7273),i=n(9087);e.getActivationSnippet=function(o){let a;switch(o.activation){case"Relu":a=(0,i.glslRelu)();break;case"Sigmoid":a=(0,i.glslSigmoid)();break;case"Clip":a=(0,i.glslClip)(o.clipMin,o.clipMax);break;default:return{activationFunction:"",applyActivation:""}}const d=a.name;return{activationFunction:a.body,applyActivation:`value = ${d}_(value);`}},e.parseInternalActivationAttributes=o=>{const a=o.getString("activation","");if(a==="Clip"){const[d,f]=o.getFloats("activation_params",[r.MIN_CLIP,r.MAX_CLIP]);return{activation:a,clipMax:f,clipMin:d,activationCacheKey:`${a}:${d},${f}`}}return{activation:a,activationCacheKey:a}}},6149:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseGatherAttributes=e.gather=void 0;const r=n(4910),i=n(6145),o=n(7273),a=n(5639);e.gather=(p,s,t)=>(h(s,t.axis),[p.run(f(p,s,t),s)]),e.parseGatherAttributes=p=>(0,r.createAttributeWithCacheKey)({axis:p.attributes.getInt("axis",0)});const d={name:"Gather",inputNames:["A","B"],inputTypes:[a.TextureType.unpacked,a.TextureType.unpacked]},f=(p,s,t)=>{const l=Object.assign(Object.assign({},d),{cacheHint:t.cacheKey});return Object.assign(Object.assign({},l),{get:()=>((u,g,m,_)=>{const b=m[0].dims.slice(),y=m[1].dims.slice(),v=new Array(b.length+y.length-1);_=o.ShapeUtil.normalizeAxis(_,b.length);const T=[];for(let S=0;S<v.length;S++)S<_?(v[S]=b[S],T.push(`inputIdx[${S}] = outputIdx[${S}];`)):S<_+y.length?(v[S]=y[S-_],T.push(`indexDataIdx[${S-_}] = outputIdx[${S}];`)):(v[S]=b[S-y.length+1],T.push(`inputIdx[${S-y.length+1}] = outputIdx[${S}];`));const w=`
      float process(int outputIdx[${v.length||1}]) {
        int inputIdx[${b.length}];
        int indexDataIdx[${y.length||1}];
        indexDataIdx[0] = 0;
        ${T.join(`
        `)}
        int idx = int(_B(indexDataIdx));
        inputIdx[${_}] = idx < 0 ? idx + ${b[_]} : idx;
        return _A(inputIdx);
      }`;return Object.assign(Object.assign({},g),{output:{dims:v,type:m[0].type,textureType:a.TextureType.unpacked},shaderSource:w})})(0,l,s,t.axis)})},h=(p,s)=>{if(!p||p.length!==2)throw new Error("Gather requires 2 inputs.");const t=p[0].dims.length;if(t<1)throw new Error("Invalid input shape.");if(s<-t||s>t-1)throw new Error("Invalid axis.");if(i.NUMBER_TYPES.indexOf(p[0].type)===-1)throw new Error("Invaid input type.");if(p[1].type!=="int32"&&p[1].type!=="int16")throw new Error("Invaid input type.")}},5378:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseGemmAttributesV11=e.parseGemmAttributesV7=e.gemm=void 0;const r=n(4910),i=n(7273),o=n(5639);e.gemm=(p,s,t)=>(h(s,t),[p.run(d(s,t),s)]);const a=(p,s)=>{const t=p.attributes.getInt("transA",0)!==0,l=p.attributes.getInt("transB",0)!==0,u=p.attributes.getFloat("alpha",1),g=p.attributes.getFloat("beta",1);return(0,r.createAttributeWithCacheKey)({transA:t,transB:l,alpha:u,beta:g,isOptionalC:s})};e.parseGemmAttributesV7=p=>a(p,!1),e.parseGemmAttributesV11=p=>a(p,!0);const d=(p,s)=>{const t={name:"Gemm",inputNames:p.length===3?["A","B","C"]:["A","B"],inputTypes:p.length===3?[o.TextureType.unpacked,o.TextureType.unpacked,o.TextureType.unpacked]:[o.TextureType.unpacked,o.TextureType.unpacked],key:s.cacheKey};return Object.assign(Object.assign({},t),{get:()=>f(t,p,s)})},f=(p,s,t)=>{const l=s[0].dims.slice(),u=s[1].dims.slice(),[g,m]=i.GemmUtil.getShapeOfGemmResult(l,t.transA,u,t.transB,s.length===3?s[2].dims:void 0),_=[g,m];if(!_)throw new Error("Can't use gemm on the given tensors");let b=l[l.length-1],y="";t.transA&&(b=l[0]),t.transA&&t.transB?y="value += _A_T(a) * _B_T(b);":t.transA&&!t.transB?y="value += _A_T(a) * _B(b);":!t.transA&&t.transB?y="value += _A(a) * _B_T(b);":t.transA||t.transB||(y="value += _A(a) * _B(b);");const v=_.length,T=`
      float process(int indices[${v}]) {
          int a[${v}];
          int b[${v}];
          ${s.length===3?`int c[${s[2].dims.length}];`:""}

          copyVec(indices, a);
          copyVec(indices, b);
          ${s.length===3?"bcastIndices_C(indices, c);":""}

          float value = 0.0;
          for (int k=0; k<${b}; ++k) {
              a[${v-1}] = k;
              b[${v-2}] = k;
              ${y}
          }

          value = value * alpha;
          ${s.length===3?"value += beta * _C(c);":""}
          return value;
      }`;return Object.assign(Object.assign({},p),{output:{dims:_,type:s[0].type,textureType:o.TextureType.unpacked},variables:[{name:"alpha",type:"float",data:t.alpha},{name:"beta",type:"float",data:t.beta}],shaderSource:T})},h=(p,s)=>{if(!p)throw new Error("Input is missing");if(s.isOptionalC&&(p.length<2||p.length>3))throw new Error("Invaid input shape.");if(!s.isOptionalC&&p.length!==3)throw new Error("Gemm requires 3 inputs");if(p.length===3&&p[2].dims.length!==1&&p[2].dims.length!==2)throw new Error("Invalid input shape of C");if(p[0].type!=="float32"&&p[0].type!=="float64"||p[1].type!=="float32"&&p[1].type!=="float64"||p.length===3&&p[2].type!=="float32"&&p[2].type!=="float64")throw new Error("Invalid input type.");if(p[0].type!==p[1].type||p.length===3&&p[0].type!==p[2].type)throw new Error("Input types are mismatched")}},5950:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createPackedIm2ColProgramInfoLoader=void 0;const r=n(6757),i=n(5639),o=n(5614);e.createPackedIm2ColProgramInfoLoader=(a,d,f,h,p)=>{const s=(t=p.cacheKey,{name:"Im2Col (packed)",inputNames:["A"],inputTypes:[i.TextureType.packed],cacheHint:t});var t;return Object.assign(Object.assign({},s),{get:()=>((l,u,g,m,_,b)=>{const y=g.dims,v=m.dims,T=_.length,w=[v[1]*v[2]*v[3],_[2]*_[3]],S=v[2]*v[3],x=(0,o.unpackFromChannel)(),P=(0,r.getGlsl)(l.session.backend.glContext.version);let I="";for(let L=0;L<=1;L++)for(let E=0;E<=1;E++)I+=`
            blockIndex = rc.x + ${E};
            pos = rc.y + ${L};

            if(blockIndex < ${w[1]} && pos < ${w[0]}) {
              offsetY = int(blockIndex / (${_[T-1]})) * ${b.strides[0]} -
                ${b.pads[0]};
              d0 = offsetY + ${b.dilations[0]} * (imod(pos, ${S}) / ${v[2]});

              if(d0 < ${y[2]} && d0 >= 0) {
                offsetX = imod(blockIndex, ${_[T-1]}) * ${b.strides[1]} -
                  ${b.pads[1]};
                d1 = offsetX + ${b.dilations[1]} * imod(imod(pos, ${S}), ${v[2]});

                if(d1 < ${y[3]} && d1 >= 0) {

                  ch = int(float(pos)/ ${S}.);
                    innerDims = vec2(d0, d1);
                    result[${2*L+E}] = getChannel(
                      getA(0, ch, int(innerDims.x),
                      int(innerDims.y)), innerDims);
                }
              }
            }

          `;const N=`
      ${x}

      void main() {
        ivec2 rc = getOutputCoords();
          vec4 result = vec4(0.0);
          int blockIndex, pos, offsetY, d0, offsetX, d1, ch;
          vec2 innerDims;
          ${I}
          ${P.output} = result;
      }
            `;return Object.assign(Object.assign({},u),{output:{dims:w,type:g.type,textureType:i.TextureType.packed},shaderSource:N,hasMain:!0})})(a,s,d,f,h,p)})}},1625:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.calculateIm2ColDims=e.createIm2ColProgramInfoLoader=void 0;const r=n(5639);e.createIm2ColProgramInfoLoader=(i,o,a,d,f)=>{const h=(p=f.cacheKey,{name:"Im2Col",inputNames:["X"],inputTypes:[r.TextureType.unpacked],cacheHint:p});var p;return Object.assign(Object.assign({},h),{get:()=>((s,t,l,u,g,m)=>{const _=l.dims,b=u.dims,y=g.length,v=(0,e.calculateIm2ColDims)(_,b,g,4),T=`
        const int XC = ${_[1]};
        const int XH = ${_[2]};
        const int XW = ${_[3]};
        const int KH = ${m.kernelShape[0]};
        const int KW = ${m.kernelShape[1]};
        const int dilationH = ${m.dilations[0]};
        const int dilationW = ${m.dilations[1]};
        const int strideH = ${m.strides[0]};
        const int strideW = ${m.strides[1]};
        const int padH = ${m.pads[0]};
        const int padW = ${m.pads[1]};
        const int KHKW = KH*KW;
        const int XCKHKW = XC * KHKW;
        const int outputChannels = 4;
        vec4 process(int indices[${y}]) {
          int b  = indices[0]; // batch size
          int oh = indices[1] * strideH - padH; //output height
          int ow = indices[2] * strideW - padW; //output width
          int p = indices[3] * outputChannels; //patch
          vec4 value = vec4(0.0);
          for(int i=0; i < outputChannels; ++i) {
            if(p < XCKHKW) {
              int patchC = p / KHKW;
              int patchH = (p - patchC*KHKW) / KW;
              int patchW = (p - patchC*KHKW) - patchH * KW;
              int xh2 = oh + patchH * dilationH;
              int xw2 = ow + patchW * dilationW;
              int x[${_.length}];
              x[0] = b;
              x[1] = patchC;
              x[2] = xh2;
              x[3] = xw2;
              if(xh2 >= 0 &&
                  xh2 < XH &&
                  xw2 >= 0 &&
                  xw2 < XW) {
                value[i] = _X(x);
              }
            }
            ++p;
          }
          return value;
        }
        `;return Object.assign(Object.assign({},t),{output:{dims:v,type:l.type,textureType:r.TextureType.packedLastDimension},shaderSource:T})})(0,h,o,a,d,f)})},e.calculateIm2ColDims=(i,o,a,d=4)=>[a[0],a[2],a[3],Math.ceil(i[1]*o[2]*o[3]/d)]},6981:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseImageScalerAttributes=e.imageScaler=void 0;const r=n(4910),i=n(5639);e.imageScaler=(h,p,s)=>(f(p),[h.run(a(h,p,s),p)]),e.parseImageScalerAttributes=h=>{const p=h.attributes.getFloat("scale"),s=h.attributes.getFloats("bias");return(0,r.createAttributeWithCacheKey)({scale:p,bias:s})};const o={name:"ImageScaler",inputNames:["X"],inputTypes:[i.TextureType.unpacked]},a=(h,p,s)=>{const t=Object.assign(Object.assign({},o),{cacheHint:s.cacheKey});return Object.assign(Object.assign({},t),{get:()=>((l,u,g,m)=>{const _=g[0].dims.slice(),b=_.length,y=`
      ${d(m.bias.length)}
      float process(int indices[${b}]) {
        return _X(indices) * scale + getBias(bias, indices[1]);
      }`;return Object.assign(Object.assign({},u),{output:{dims:_,type:g[0].type,textureType:i.TextureType.unpacked},variables:[{name:"bias",type:"float",arrayLength:m.bias.length,data:m.bias},{name:"scale",type:"float",data:m.scale}],shaderSource:y})})(0,t,p,s)})},d=h=>{const p=[`float getBias(float bias[${h}], int channel) {`];for(let s=0;s<h;++s)s===0?p.push(`	if (channel == ${s}) { return bias[${s}]; }`):s===h-1?p.push(`	else { return bias[${s}]; }`):p.push(`	else if (channel == ${s}) { return bias[${s}]; }`);return p.push("	}"),p.join(`
`)},f=h=>{if(!h||h.length!==1)throw new Error("ImageScaler requires 1 input.");if(h[0].dims.length!==4)throw new Error("Invalid input shape.");if(h[0].type!=="float32"&&h[0].type!=="float64")throw new Error("Invalid input type.")}},7413:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseInstanceNormalizationAttributes=e.instanceNormalization=void 0;const r=n(6757),i=n(5639);e.instanceNormalization=(p,s,t)=>{h(s);const l=p.run(a(s[0]),s);return[p.run(f(p,s[0],t,l.dims),[s[0],l,s[1],s[2]])]},e.parseInstanceNormalizationAttributes=p=>p.attributes.getFloat("epsilon",1e-5);const o={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[i.TextureType.unpacked]},a=p=>Object.assign(Object.assign({},o),{get:()=>((s,t)=>{const l=t.dims.slice(),u=l[1],g=l[2]*l[3],m=[l[0],u],_=`
      vec4 process(int[2] indices) {
        vec4 v = vec4(0.0);
        int a[4];
        a[0] = indices[0];
        a[1] = indices[1];
        float temp = 0.0;
        for(int a2=0; a2<${l[2]}; a2++) {
          a[2] = a2;
          for(int a3=0; a3<${l[3]}; a3++) {
            a[3] = a3;
            float x = _X(a);
            temp += x;
          }
        }
        float mean = temp / float(${g});
        temp = 0.0;
        for(int a2=0; a2<${l[2]}; a2++) {
          a[2] = a2;
          for(int a3=0; a3<${l[3]}; a3++) {
            a[3] = a3;
            float x = _X(a);
            temp += (x - mean) * (x - mean);
          }
        }
        v.r = mean;
        v.g = temp / float(${g});

        return v;
      }`;return Object.assign(Object.assign({},s),{output:{dims:m,type:t.type,textureType:i.TextureType.packedLastDimension},shaderSource:_})})(o,p)}),d={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[i.TextureType.unpacked,i.TextureType.packedLastDimension,i.TextureType.unpacked,i.TextureType.unpacked]},f=(p,s,t,l)=>{const u=Object.assign(Object.assign({},d),{cacheHint:`${t}`});return Object.assign(Object.assign({},u),{get:()=>((g,m,_,b,y)=>{const v=(0,r.getGlsl)(g.session.backend.glContext.version),[T,w]=g.calculateTextureWidthAndHeight(y,i.TextureType.packedLastDimension),[S,x]=[T/4,w],P=`
      vec4 get_MeanAndVariance(int[2] mv) {
        int offset = indicesToOffset_MeanAndVariance(mv);
        vec2 coords = offsetToCoords(offset, ${S}, ${x});
        return ${v.texture2D}(MeanAndVariance, coords);
      }

      float process(int[4] indices) {
        int mv[2];
        mv[0] = indices[0];
        mv[1] = indices[1];
        vec4 mean_and_variance = get_MeanAndVariance(mv);
        float mean = mean_and_variance.r;
        float variance = mean_and_variance.g;

        int sb[1];
        sb[0] = indices[1];
        float scale = _Scale(sb);
        float b = _B(sb);

        return scale * (_X(indices) - mean) / sqrt(variance + epsilon) + b;
      }`;return Object.assign(Object.assign({},m),{output:{dims:_.dims,type:_.type,textureType:i.TextureType.unpacked},variables:[{name:"epsilon",type:"float",data:b}],shaderSource:P})})(p,u,s,t,l)})},h=p=>{if(!p||p.length!==3)throw new Error("InstanceNormalization requires 3 inputs.");const s=p[0],t=p[1],l=p[2];if(s.dims.length<3||t.dims.length!==1||l.dims.length!==1)throw new Error("Invalid input shape.");if(t.dims[0]!==s.dims[1]||l.dims[0]!==s.dims[1])throw new Error("Input shapes are mismatched.");if(s.type!=="float32"&&s.type!=="float64"||t.type!=="float32"&&t.type!=="float64"||l.type!=="float32"&&l.type!=="float64")throw new Error("Invalid input type.");if(p[0].dims.length!==4)throw new Error("Only support 4-D input shape.")}},7006:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createLrnProgramInfoLoader=e.parseLrnAttributes=e.lrn=void 0;const r=n(4910),i=n(5639);e.lrn=(f,h,p)=>(d(h),[f.run(a(h,p),h)]),e.parseLrnAttributes=f=>{const h=f.attributes.getFloat("alpha",1e-4),p=f.attributes.getFloat("beta",.75),s=f.attributes.getFloat("bias",1),t=f.attributes.getInt("size");return(0,r.createAttributeWithCacheKey)({alpha:h,beta:p,bias:s,size:t})};const o={name:"LRN",inputNames:["X"],inputTypes:[i.TextureType.unpacked]};function a(f,h){return Object.assign(Object.assign({},o),{cacheHint:h.cacheKey,get:()=>function(p,s){const t=p[0].dims[1],l=p[0].dims.length,u=-Math.floor((s.size-1)/2),g=Math.ceil((s.size-1)/2),m=`float(${s.alpha}) / float(${s.size})`,_=`
    float process(int indices[${l}]) {
        int c = indices[1];
        float x = _X(indices);
        float square_sum = 0.0;

        for (int i = ${u}; i <= ${g}; i++) {
          int idx = c + i;
          if (c >= 0 && c < ${t}) {
            indices[1] = idx;
            float j = _X(indices);
            square_sum += j * j;
          }
        }
        return x / pow(float(${s.bias}) + ${m} * square_sum, float(${s.beta}));
    }`;return Object.assign(Object.assign({},o),{cacheHint:s.cacheKey,output:{dims:p[0].dims,type:p[0].type,textureType:i.TextureType.unpacked},shaderSource:_})}(f,h)})}e.createLrnProgramInfoLoader=a;const d=f=>{if(!f||f.length!==1)throw new Error("LRN requires 1 input.");if(f[0].dims.length!==4)throw new Error('currently only support LRN for input with "NCHW" format');if(f[0].type!=="float32")throw new Error("input should be float type")}},5632:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createPackedMatmulProgramInfoLoader=void 0;const r=n(7273),i=n(6757),o=n(5639),a=n(432),d=n(2150),f=n(8276);e.createPackedMatmulProgramInfoLoader=(h,p,s)=>{const t=(l=p.length>2,u=s.activationCacheKey,{name:"MatMul (packed)",inputNames:l?["A","B","Bias"]:["A","B"],inputTypes:l?[o.TextureType.packed,o.TextureType.packed,o.TextureType.packed]:[o.TextureType.packed,o.TextureType.packed],cacheHint:u});var l,u;return Object.assign(Object.assign({},t),{get:()=>((g,m,_,b)=>{const y=_.length>2,v=y?"value += getBiasForMatmul();":"",T=_[0].dims,w=_[1].dims,S=r.BroadcastUtil.calcShape(T,w,!0),x=!r.ShapeUtil.areEqual(_[0].dims,_[1].dims);if(!S)throw new Error("Can't use matmul on the given tensors");const P=T[T.length-1],I=Math.ceil(P/2),N=T.length,L=w.length,E=(0,i.getGlsl)(g.session.backend.glContext.version),M=(0,a.getCoordsDataType)(S.length),k=S.length,A=(0,a.getGlChannels)(),{activationFunction:R,applyActivation:K}=(0,d.getActivationSnippet)(b),Z=y?`${(0,f.getBiasForMatmul)(M,A,_[2].dims,S,!0)}`:"",J=x?`${function(ae,ce,fe,he){let xe=[],we=[];const Re=fe[0].dims,be=fe[1].dims,Ne=Re.length,ge=be.length,ye=he.length,Oe=ye-Ne,Pe=ye-ge;xe=Re.map((ke,Ee)=>`coords.${ce[Ee+Oe]}`),xe[Ne-1]="i*2",xe.join(", "),we=be.map((ke,Ee)=>`coords.${ce[Ee+Pe]}`),we[ge-2]="i*2",we.join(", ");const Ae=r.BroadcastUtil.getBroadcastDims(Re,he),$e=r.BroadcastUtil.getBroadcastDims(be,he),Ce=Ae.map(ke=>`coords.${ce[ke+Oe]} = 0;`).join(`
`),Ge=$e.map(ke=>`coords.${ce[ke+Pe]} = 0;`).join(`
`),je=`int lastDim = coords.${ce[ye-1]};
  coords.${ce[ye-1]} = coords.${ce[ye-2]};
  coords.${ce[ye-2]} = lastDim;`;return`
vec4 getAAtOutCoordsMatmul(int i) {
  ${ae} coords = getOutputCoords();
  ${je}
  ${Ce}
  vec4 outputValue = getA(${xe});
  return outputValue;
}

vec4 getBAtOutCoordsMatmul(int i) {
  ${ae} coords = getOutputCoords();
  ${je}
  ${Ge}
  vec4 outputValue = getB(${we});
  return outputValue;
}`}(M,A,_,S)}`:"",X=x?"getAAtOutCoordsMatmul(i)":`getA(${function(ae,ce){let fe="";for(let he=0;he<ce-2;he++)fe+=`rc.${ae[he]}, `;return fe+=`rc.${ae[ce-2]}, i*2`,fe}(A,N)})`,te=x?"getBAtOutCoordsMatmul(i)":`getB(${function(ae,ce){let fe="";for(let he=0;he<ce-2;he++)fe+=`rc.${ae[he]}, `;return fe+=`i*2, rc.${ae[ce-1]}`,fe}(A,L)})`,oe=`
            ${J}
            ${Z}
            ${R}
            void main() {
              ${x?"":`${M} rc =
          getOutputCoords(); int lastDim = rc.${A[k-1]}; rc.${A[k-1]} =
          rc.${A[k-2]}; rc.${A[k-2]} = lastDim;
      `}

              vec4 value = vec4(0);
              for (int i = 0; i < ${I}; i++) {
                vec4 a = ${X};
                vec4 b = ${te};

                value += (a.rrbb * b.rgrg);
                value += (a.ggaa * b.baba);
              }
              ${v}
              ${K}
              ${E.output} = value;
            }`;return Object.assign(Object.assign({},m),{output:{dims:S,type:_[0].type,textureType:o.TextureType.packed},shaderSource:oe,hasMain:!0})})(h,t,p,s)})}},8276:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getBiasForMatmul=e.createMatmulProgramInfoLoader=e.parseMatMulAttributes=e.matMul=void 0;const r=n(7273),i=n(5639),o=n(432),a=n(2150),d=n(5632);e.matMul=(t,l,u)=>(p(l),t.session.pack?[t.run((0,d.createPackedMatmulProgramInfoLoader)(t,l,u),l)]:[t.run(h(l,u),l)]),e.parseMatMulAttributes=t=>(0,a.parseInternalActivationAttributes)(t.attributes);const f=(t,l)=>({name:"MatMul",inputNames:t?["A","B","Bias"]:["A","B"],inputTypes:t?[i.TextureType.unpacked,i.TextureType.unpacked,i.TextureType.unpacked]:[i.TextureType.unpacked,i.TextureType.unpacked],cacheHint:l});function h(t,l){const u=f(t.length>2,l.activationCacheKey);return Object.assign(Object.assign({},u),{get:()=>function(g,m,_){const b=m[0].dims,y=m[1].dims,v=r.BroadcastUtil.calcShape(b,y,!0);if(!v)throw new Error("Can't use matmul on the given tensors");const T=(0,o.getCoordsDataType)(v.length),w=(0,o.getGlChannels)(),{activationFunction:S,applyActivation:x}=(0,a.getActivationSnippet)(_),P=m.length>2,I=P?"value += getBiasForMatmul();":"",N=P?`${s(T,w,m[2].dims,v,!1)}`:"",L=v.length,E=b.length,M=y.length,k=`
    ${S}
    ${N}
    float process(int indices[${L}]) {
        int a[${E}];
        int b[${M}];
        bcastMatmulIndices_A(indices, a);
        bcastMatmulIndices_B(indices, b);

        float value;
        for (int k=0; k<${b[b.length-1]}; ++k) {
            a[${E-1}] = k;
            b[${M-2}] = k;
            value += _A(a) * _B(b);
        }
        ${I}
        ${x}
        return value;
    }`;return Object.assign(Object.assign({},g),{output:{dims:v,type:m[0].type,textureType:i.TextureType.unpacked},shaderSource:k})}(u,t,l)})}e.createMatmulProgramInfoLoader=h;const p=t=>{if(!t||t.length!==2)throw new Error("MatMul requires 2 inputs.");if(t[0].dims[t[0].dims.length-1]!==t[1].dims[t[1].dims.length-2])throw new Error("shared dimension does not match.");if(t[0].type!=="float32"&&t[0].type!=="float64"||t[1].type!=="float32"&&t[1].type!=="float64")throw new Error("inputs should be float type");if(t[0].type!==t[1].type)throw new Error("inputs types should match")};function s(t,l,u,g,m){let _="";const b=u.length,y=g.length,v=y-b;_=y<2&&b>0?"coords":u.map((S,x)=>`coords.${l[x+v]}`).join(", ");const T=r.BroadcastUtil.getBroadcastDims(u,g).map(S=>`coords.${l[S+v]} = 0;`).join(`
`);let w="vec4(outputValue.xx, outputValue.yy)";return r.ShapeUtil.size(u)===1&&(w="vec4(outputValue.x)"),m?`
vec4 getBiasForMatmul() {
  ${t} coords = getOutputCoords();
  ${T}
  vec4 outputValue = getBias(${_});
  return ${w};
}`:`
float getBiasForMatmul() {
  ${t} coords = getOutputCoords();
  ${T}
  return getBias(coords.x);
}`}e.getBiasForMatmul=s},9:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createPackProgramInfoLoader=void 0;const r=n(6757),i=n(5639),o=n(432),a=n(5614),d={name:"pack",inputNames:["A"],inputTypes:[i.TextureType.unpackedReversed]};e.createPackProgramInfoLoader=(f,h)=>Object.assign(Object.assign({},d),{get:()=>((p,s)=>{const t=(0,r.getGlsl)(p.session.backend.glContext.version),l=s.dims,u=l.length,g=s.dims.length,m=(0,o.getCoordsDataType)(g),_=(0,a.getChannels)("rc",g),b=(y=g,v=_,T=l[l.length-2],w=l[l.length-1],y===0||y===1?"":`
    int r = ${v[y-2]};
    int c = ${v[y-1]};
    int rp1 = ${v[y-2]} + 1;
    int cp1 = ${v[y-1]} + 1;
    bool rEdge = rp1 >= ${w};
    bool cEdge = cp1 >= ${T};
    `);var y,v,T,w;let S;S=u===0?[1,1]:u===1?[l[0],1]:[l[g-1],l[g-2]];const x=function(N,L,E){if(N===0)return"false";if(N===1)return`rc > ${L[0]}`;let M="";for(let k=N-2;k<N;k++)M+=`${E[k]} >= ${L[k-N+2]}`,k<N-1&&(M+="||");return M}(g,S,_),P=function(N,L){const E=N.length;if(E===0)return"getA(), 0, 0, 0";if(E===1)return`getA(rc),
            rc + 1 >= ${N[0]} ? 0. : getA(rc + 1),
            0, 0`;let M="";if(E>2)for(let k=0;k<E-2;++k)M+=`${L[k]},`;return`getA(${M}r, c),
          rEdge ? 0. : getA(${M}rp1, c),
          cEdge ? 0. : getA(${M}r, cp1),
          rEdge || cEdge ? 0. : getA(${M}rp1, cp1)`}(l,_),I=`
        void main() {
          ${m} rc = getOutputCoords();

          if(${x}) {
            ${t.output} = vec4(0);
          } else {
            ${b}

            ${t.output} = vec4(${P});
          }
        }
      `;return Object.assign(Object.assign({},d),{hasMain:!0,output:{dims:s.dims,type:s.type,textureType:i.TextureType.packed},shaderSource:I})})(f,h)})},5614:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.unpackFromChannel=e.getChannels=e.getVecChannels=void 0;const r=n(432);function i(o,a){return(0,r.getGlChannels)(a).map(d=>`${o}.${d}`)}e.getVecChannels=i,e.getChannels=function(o,a){return a===1?[o]:i(o,a)},e.unpackFromChannel=function(){return`
    float getChannel(vec4 frag, int dim) {
      int modCoord = imod(dim, 2);
      return modCoord == 0 ? frag.r : frag.g;
    }

    float getChannel(vec4 frag, vec2 innerDims) {
      vec2 modCoord = mod(innerDims, 2.);
      return modCoord.x == 0. ?
        (modCoord.y == 0. ? frag.r : frag.g) :
        (modCoord.y == 0. ? frag.b : frag.a);
    }
  `}},5565:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parsePadAttributesV11=e.padV11=e.parsePadAttributesV2=e.padV2=void 0;const r=n(4910),i=n(7273),o=n(6757),a=n(5639),d={name:"Pad",inputNames:["A"],inputTypes:[a.TextureType.unpacked]};e.padV2=(m,_,b)=>(p(_),[m.run(Object.assign(Object.assign({},d),{cacheHint:b.cacheKey,get:()=>h(m,_[0],b)}),_)]),e.parsePadAttributesV2=m=>{const _=m.attributes.getString("mode","constant"),b=m.attributes.getFloat("value",0),y=m.attributes.getInts("pads");return(0,r.createAttributeWithCacheKey)({mode:_,value:b,pads:y})},e.padV11=(m,_,b)=>{s(_);const y=f(m,_,b);return(0,e.padV2)(m,[_[0]],y)},e.parsePadAttributesV11=m=>m.attributes.getString("mode","constant");const f=(m,_,b)=>{if(!m.session.isInitializer(_[1].dataId)||_.length>=3&&!m.session.isInitializer(_[2].dataId))throw new Error("dynamic pad attributes are not allowed");const y=Array.from(_[1].integerData),v=_.length>=3?_[2].floatData[0]:0;return(0,r.createAttributeWithCacheKey)({mode:b,pads:y,value:v})},h=(m,_,b)=>{const y=i.ShapeUtil.padShape(_.dims.slice(),b.pads),v=y.length,T=`
      ${t(m,_,b)}
      float process(int[${v}] indices) {
          return padA(indices);
      }`;return{name:"Pad",inputNames:["A"],inputTypes:[a.TextureType.unpacked],output:{dims:y,type:_.type,textureType:a.TextureType.unpacked},shaderSource:T}},p=m=>{if(!m||m.length!==1)throw new Error("Pad requires 1 input");if(m[0].type!=="float32"&&m[0].type!=="float64")throw new Error("Invalid input type.")},s=m=>{if(!m||m.length!==2&&m.length!==3)throw new Error("Pad requires 2 or 3 inputs");if(m[1].type!=="int32")throw new Error("Invalid input type.");if(m.length>=3&&m[2].type==="string")throw new Error("Invalid input type.")},t=(m,_,b)=>{const y=(0,o.getGlsl)(m.session.backend.glContext.version),[v,T]=m.calculateTextureWidthAndHeight(_.dims,a.TextureType.unpacked),w=i.ShapeUtil.computeStrides(_.dims);switch(b.mode){case"constant":return l(y,_.dims,w,v,T,b.pads,b.value);case"reflect":return u(y,_.dims,w,v,T,b.pads);case"edge":return g(y,_.dims,w,v,T,b.pads);default:throw new Error("Invalid mode")}},l=(m,_,b,y,v,T,w)=>{const S=_.length;let x="";for(let P=S-1;P>=0;--P)x+=`
        k = m[${P}] - ${T[P]};
        if (k < 0)  return constant;
        if (k >= ${_[P]}) return constant;
        offset += k * ${b[P]};
        `;return`
      float padA(int m[${S}]) {
        const float constant = float(${w});
        int offset = 0;
        int k = 0;
        ${x}
        vec2 coords = offsetToCoords(offset, ${y}, ${v});
        float value = getColorAsFloat(${m.texture2D}(A, coords));
        return value;
      }
      `},u=(m,_,b,y,v,T)=>{const w=_.length;let S="";for(let x=w-1;x>=0;--x)S+=`
        k = m[${x}] - ${T[x]};
        if (k < 0) { k = -k; }
        {
          const int _2n_1 = ${2*(_[x]-1)};
          k = int( mod( float(k), float(_2n_1) ) ) ;
          if(k >= ${_[x]}) { k = _2n_1 - k; }
        }
        offset += k * ${b[x]};
        `;return`
      float padA(int m[${w}]) {
        int offset = 0;
        int k = 0;
        ${S}
        vec2 coords = offsetToCoords(offset, ${y}, ${v});
        float value = getColorAsFloat(${m.texture2D}(A, coords));
        return value;
      }
      `},g=(m,_,b,y,v,T)=>{const w=_.length;let S="";for(let x=w-1;x>=0;--x)S+=`
        k = m[${x}] - ${T[x]};
        if (k < 0)  k = 0;
        if (k >= ${_[x]}) k = ${_[x]-1};
        offset += k * ${b[x]};
      `;return`
      float padA(int m[${w}]) {
        int offset = 0;
        int k = 0;
        ${S}
        vec2 coords = offsetToCoords(offset, ${y}, ${v});
        float value = getColorAsFloat(${m.texture2D}(A, coords));
        return value;
      }
      `}},2834:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.globalMaxPool=e.parseMaxPoolAttributes=e.maxPool=e.parseGlobalAveragePoolAttributes=e.globalAveragePool=e.parseAveragePoolAttributes=e.averagePool=void 0;const r=n(4910),i=n(7273),o=n(5639);e.averagePool=(g,m,_)=>{s(m);const b={name:"AveragePool",inputNames:["X"],inputTypes:[o.TextureType.unpacked],cacheHint:_.cacheKey};return[g.run(Object.assign(Object.assign({},b),{get:()=>a(m,b,!1,_)}),m)]},e.parseAveragePoolAttributes=g=>{const m=g.attributes.getString("auto_pad","NOTSET"),_=g.attributes.getInt("ceil_mode",0),b=g.attributes.getInt("count_include_pad",0)!==0,y=g.attributes.getInts("kernel_shape"),v=g.attributes.getInts("strides",[]),T=g.attributes.getInts("pads",[]);if(_!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return(0,r.createAttributeWithCacheKey)({autoPad:m,ceilMode:_,countIncludePad:b,kernelShape:y,strides:v,pads:T})};const a=(g,m,_,b)=>{const[y,v]=f(g,b,_),T=i.ShapeUtil.size(y.kernelShape);let w="";y.countIncludePad?w+=`value /= float(${T});`:w+=`value /= float(${T} - pad);`;const S=`
        ${t(g[0].dims,y,"value += _X(x);",w,"0.0")}
      `;return Object.assign(Object.assign({},m),{output:{dims:v,type:g[0].type,textureType:o.TextureType.unpacked},shaderSource:S})};e.globalAveragePool=(g,m,_)=>{s(m);const b={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[o.TextureType.unpacked],cacheHint:`${_.countIncludePad}`};return[g.run(Object.assign(Object.assign({},b),{get:()=>a(m,b,!0,_)}),m)]},e.parseGlobalAveragePoolAttributes=g=>{const m=g.attributes.getInt("count_include_pad",0)!==0;return(0,r.createAttributeWithCacheKey)({autoPad:"",ceilMode:0,countIncludePad:m,kernelShape:[],strides:[],pads:[]})},e.maxPool=(g,m,_)=>{s(m);const b={name:"MaxPool",inputNames:["X"],inputTypes:[o.TextureType.unpacked],cacheHint:_.cacheKey};return[g.run(Object.assign(Object.assign({},b),{get:()=>d(m,b,!1,_)}),m)]},e.parseMaxPoolAttributes=g=>{const m=g.attributes.getString("auto_pad","NOTSET"),_=g.attributes.getInt("ceil_mode",0),b=g.attributes.getInts("kernel_shape"),y=g.attributes.getInts("strides",[]),v=g.attributes.getInts("pads",[]),T=g.attributes.getInt("storage_order",0),w=g.attributes.getInts("dilations",[]);if(T!==0)throw new Error("column major storage order is not yet supported for MaxPool");if(_!==0)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return(0,r.createAttributeWithCacheKey)({autoPad:m,ceilMode:_,countIncludePad:!1,kernelShape:b,strides:y,pads:v,storageOrder:T,dilations:w})};const d=(g,m,_,b)=>{const[y,v]=f(g,b,_),T=`
      ${t(g[0].dims,y,`
      value = max(_X(x), value);
    `,"","-1e5")}
    `;return Object.assign(Object.assign({},m),{output:{dims:v,type:g[0].type,textureType:o.TextureType.unpacked},shaderSource:T})},f=(g,m,_)=>{const b=g[0].dims.slice(),y=Object.hasOwnProperty.call(m,"dilations"),v=m.kernelShape.slice(),T=m.strides.slice(),w=y?m.dilations.slice():[],S=m.pads.slice();i.PoolConvUtil.adjustPoolAttributes(_,b,v,T,w,S);const x=i.PoolConvUtil.computePoolOutputShape(_,b,T,w,v,S,m.autoPad),P=Object.assign({},m);return y?Object.assign(P,{kernelShape:v,strides:T,pads:S,dilations:w,cacheKey:m.cacheKey}):Object.assign(P,{kernelShape:v,strides:T,pads:S,cacheKey:m.cacheKey}),[P,x]},h={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},p={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[o.TextureType.unpacked]};e.globalMaxPool=(g,m)=>(s(m),[g.run(Object.assign(Object.assign({},p),{get:()=>d(m,p,!0,h)}),m)]);const s=g=>{if(!g||g.length!==1)throw new Error("Pool ops requires 1 input.");if(g[0].type!=="float32"&&g[0].type!=="float64")throw new Error("Invalid input type.")},t=(g,m,_,b,y)=>{const v=g.length;if(m.kernelShape.length<=2){const T=m.kernelShape[m.kernelShape.length-1],w=m.strides[m.strides.length-1],S=m.pads[m.pads.length/2-1],x=m.pads[m.pads.length-1],P=g[v-1];let I="",N="",L="";if(I=S+x!==0?`
          for (int i = 0; i < ${T}; i++) {
            x[${v} - 1] = indices[${v} - 1] * ${w} - ${S} + i;
            if (x[${v} - 1] < 0 || x[${v} - 1] >= ${P}) {
              pad++;
              continue;
            }
            ${_}
          }`:`
          for (int i = 0; i < ${T}; i++) {
            x[${v} - 1] = indices[${v} - 1] * ${w} - ${S} + i;
            ${_}
          }`,m.kernelShape.length===2){const E=m.kernelShape[m.kernelShape.length-2],M=m.strides[m.strides.length-2],k=m.pads[m.pads.length/2-2],A=m.pads[m.pads.length-2],R=g[v-2];N=k+A!==0?`
            for (int j = 0; j < ${E}; j++) {
              x[${v} - 2] = indices[${v} - 2] * ${M} - ${k} + j;
              if (x[${v} - 2] < 0 || x[${v} - 2] >= ${R}) {
                pad+= ${T};
                continue;
              }
          `:`
            for (int j = 0; j < ${E}; j++) {
              x[${v} - 2] = indices[${v} - 2] * ${M} - ${k} + j;
            `,L=`
          }
        `}return`
        float process(int indices[${v}]) {
          int x[${v}];
          copyVec(indices, x);

          float value = ${y};
          int pad = 0;
          ${N}
          ${I}
          ${L}
          ${b}
          return value;
        }
      `}{const T=i.ShapeUtil.size(m.kernelShape),w=i.ShapeUtil.computeStrides(m.kernelShape),S=w.length,x=m.pads.length,P=u(S),I=l(g,"inputDims"),N=l(m.pads,"pads"),L=l(w,"kernelStrides"),E=l(m.strides,"strides");let M="";return M=m.pads.reduce((k,A)=>k+A)?`
            if (x[j] >= inputDims[j] || x[j] < 0) {
              pad++;
              isPad = true;
              break;
            }
          }
          if (!isPad) {
            ${_}
          }`:`
          }
          ${_}
        `,`
        ${P}
        float process(int indices[${v}]) {
          int x[${v}];
          copyVec(indices, x);
          int offset[${S}];
          int pads[${x}];
          int inputDims[${v}];
          int kernelStrides[${S}];
          int strides[${S}];
          ${N}
          ${I}
          ${E}
          ${L}

          float value = ${y};
          int pad = 0;
          bool isPad = false;
          for (int i = 0; i < ${T}; i++) {
            offsetToIndices(i, kernelStrides, offset);
            isPad = false;
            for (int j = ${v} - ${S}; j < ${v}; j++) {
              x[j] = indices[j] * strides[j - ${v} + ${S}]
                + offset[j - ${v} + ${S}] - pads[j - 2];
              ${M}
          }
          ${b}

          return value;
        }
      `}},l=(g,m)=>{let _="";for(let b=0;b<g.length;b++)_+=`
      ${m}[${b}] = ${g[b]};
    `;return _},u=g=>`
  void offsetToIndices(int offset, int[${g}] strides, out int[${g}] indices) {
    if (${g} == 0) {
      return;
    }
    for (int i = 0; i < ${g} - 1; ++i) {
      indices[i] = offset / strides[i];
      offset -= indices[i] * strides[i];
    }
    indices[${g} - 1] = offset;
  }`},1010:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.reduceLogSumSquare=e.reduceLogSum=e.reduceProd=e.reduceMin=e.reduceMax=e.reduceMean=e.reduceSum=e.parseReduceAttributes=void 0;const r=n(4910),i=n(6145),o=n(7273),a=n(5639),d=(p,s,t,l,u)=>{h(s);const g={name:l,inputNames:["A"],inputTypes:[a.TextureType.unpacked]};return[p.run(Object.assign(Object.assign({},g),{cacheHint:t.cacheKey,get:()=>f(p,s,t,l,u,g)}),s)]};e.parseReduceAttributes=p=>{const s=p.attributes.getInts("axes",[]),t=p.attributes.getInt("keepdims",1)===1;return(0,r.createAttributeWithCacheKey)({axes:s,keepDims:t})};const f=(p,s,t,l,u,g)=>{const m=[],_=s[0].dims.length||1,b=[],y=o.ShapeUtil.normalizeAxes(t.axes,s[0].dims.length),v=u(s,y);let T=v[1];for(let S=0;S<s[0].dims.length;S++)y.indexOf(S)>=0||y.length===0?(t.keepDims&&m.push(1),T=`
          for(int j${S} = 0; j${S} < ${s[0].dims[S]}; j${S}++) {
            inputIdx[${S}] = j${S};
            ${T}
          }`):(b.push(`inputIdx[${S}] = outputIdx[${m.length}];`),m.push(s[0].dims[S]));const w=`
      float process(int outputIdx[${m.length||1}]) {
        float value;                 // final result
        int inputIdx[${_}];      // addressing input data
        ${b.join(`
`)}
        ${v[0]}       // init ops for reduce max/min
        ${T}
        ${v[2]}       // final computation for reduce mean
        return value;
      }`;return Object.assign(Object.assign({},g),{output:{dims:m,type:s[0].type,textureType:a.TextureType.unpacked},shaderSource:w})},h=p=>{if(!p||p.length!==1)throw new Error("Reduce op requires 1 input.");if(i.NUMBER_TYPES.indexOf(p[0].type)===-1)throw new Error("Invalid input type.")};e.reduceSum=(p,s,t)=>d(p,s,t,"ReduceSum",()=>["value = 0.0;","value += _A(inputIdx);",""]),e.reduceMean=(p,s,t)=>d(p,s,t,"ReduceMean",(l,u)=>{let g=1;for(let m=0;m<l[0].dims.length;m++)(u.indexOf(m)>=0||u.length===0)&&(g*=l[0].dims[m]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${g}.;`]}),e.reduceMax=(p,s,t)=>d(p,s,t,"ReduceMax",(l,u)=>{const g=[];for(let m=0;m<l[0].dims.length;m++)(u.indexOf(m)>=0||u.length===0)&&g.push(`inputIdx[${m}] = 0;`);return[`${g.join(`
`)}
value = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]}),e.reduceMin=(p,s,t)=>d(p,s,t,"ReduceMin",(l,u)=>{const g=[];for(let m=0;m<l[0].dims.length;m++)(u.indexOf(m)>=0||u.length===0)&&g.push(`inputIdx[${m}] = 0;`);return[`${g.join(`
`)}
value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),e.reduceProd=(p,s,t)=>d(p,s,t,"ReduceProd",()=>["value = 1.0;","value *= _A(inputIdx);",""]),e.reduceLogSum=(p,s,t)=>d(p,s,t,"ReduceLogSum",()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"]),e.reduceLogSumSquare=(p,s,t)=>d(p,s,t,"ReduceLogSumSquare",()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""])},7379:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isReshapeCheap=e.processDims3D=e.createPackedReshape3DProgramInfoLoader=void 0;const r=n(7273),i=n(6757),o=n(5639),a=n(5614);e.createPackedReshape3DProgramInfoLoader=(d,f,h)=>{const p=(s=>({name:"Reshape (packed)",inputTypes:[o.TextureType.packed],inputNames:["A"],cacheHint:`${s}`}))(h);return Object.assign(Object.assign({},p),{get:()=>((s,t,l,u)=>{const g=t.dims,m=u;let _="";for(let v=0;v<4;v++){let T="";switch(v){case 0:T="outputCoords = rc;";break;case 1:T="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:T="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:T="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}_+=`
        ${T}
        ${v>0?"if(outputCoords.y < rows && outputCoords.z < cols){":""}
          int flattenedIndex = getFlattenedIndex(outputCoords);

          ivec3 inputRC = inputCoordsFromReshapedOutCoords(flattenedIndex);
          vec2 innerDims = vec2(float(inputRC.y),float(inputRC.z));

          result[${v}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims);

        ${v>0?"}":""}
      `}const b=(0,i.getGlsl)(s.session.backend.glContext.version),y=`
      ${function(v){const T=r.ShapeUtil.computeStrides(v),w=["b","r","c"],S="index";return`
    ivec3 inputCoordsFromReshapedOutCoords(int index) {
      ${T.map((x,P)=>`int ${w[P]} = ${S} / ${x}; ${P===T.length-1?`int ${w[P+1]} = ${S} - ${w[P]} * ${x}`:`index -= ${w[P]} * ${x}`};`).join("")}
      return ivec3(b, r, c);
    }
  `}(g)}
      ${function(v){const T=r.ShapeUtil.computeStrides(v);return`
  int getFlattenedIndex(ivec3 coords) {
    // reverse y, z order
    return coords.x * ${T[0]} + coords.z * ${T[1]} + coords.y;
  }
`}(m)}
      ${(0,a.unpackFromChannel)()}

      void main() {
        ivec3 rc = getOutputCoords();

        vec4 result = vec4(0.0);

        ivec3 outputCoords;
        int rows = ${m[2]};
        int cols = ${m[1]};

        ${_}
        ${b.output} = result;
      }
    `;return Object.assign(Object.assign({},l),{output:{dims:m,type:t.type,textureType:o.TextureType.packed},shaderSource:y,hasMain:!0})})(d,f,p,h)})},e.processDims3D=function(d){if(d.length===0)return[1,1,1];let f=1;for(let h=0;h<d.length-2;++h)f*=d[h];return[f,d.length>1?d[d.length-2]:1,d[d.length-1]]},e.isReshapeCheap=function(d,f){let h=!1;return h=d.length===0||f.length===0||(d.length<2||f.length<2?d[d.length-1]===f[f.length-1]:d[d.length-1]===f[f.length-1]&&d[d.length-2]===f[f.length-2]),h}},8126:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.reshape=void 0;const r=n(7273);e.reshape=(i,o)=>{const a=r.ShapeUtil.calculateReshapedDims(o[0].dims,o[1].integerData);return i.session.pack?[i.reshapePacked(o[0],a)]:[i.reshapeUnpacked(o[0],a)]}},2801:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseResizeAttributesV11=e.parseResizeAttributesV10=e.resize=void 0;const r=n(6757),i=n(5639),o=n(432),a=n(5614),d=n(3980),f={name:"Resize",inputNames:["A"],inputTypes:[i.TextureType.packed]};e.resize=(l,u,g)=>((0,d.validateInputs)(u,g),[l.run(Object.assign(Object.assign({},f),{cacheHint:g.cacheKey,get:()=>h(l,u,g)}),u)]),e.parseResizeAttributesV10=l=>(0,d.parseUpsampleAttributes)(l,10),e.parseResizeAttributesV11=l=>(0,d.parseUpsampleAttributes)(l,11);const h=(l,u,g)=>{const m=(0,r.getGlsl)(l.session.backend.glContext.version),[_,b]=p(u,g);if(_.every(M=>M===1)&&g.coordinateTransformMode!=="tf_crop_and_resize")return Object.assign(Object.assign({},f),{output:{dims:b,type:u[0].type,textureType:i.TextureType.packed},hasMain:!0,shaderSource:`void main() {
                    vec4 v = ${m.texture2D}(X, TexCoords);
                    ${m.output} = v;
                }`});const y=b.length;if(y<2)throw new Error(`output dimension should be at least 2, but got ${y}`);const v=b[y-2],T=b[y-1],w=u[0].dims;if(y!==w.length)throw new Error(`output dimension should match input ${w.length}, but got ${y}`);const S=w[y-2],x=w[y-1],P=_[y-2],I=_[y-1];let N="";if(g.mode!=="linear")throw new Error(`resize (packed) does not support mode: '${g.mode}'`);switch(g.coordinateTransformMode){case"asymmetric":N=`
                    vec4 getSourceFracIndex(ivec4 coords) {
                        return vec4(coords) / scaleWHWH;
                    }
                `;break;case"half_pixel":N=`
                    vec4 getSourceFracIndex(ivec4 coords) {
                        return (vec4(coords) + 0.5) / scaleWHWH - 0.5;
                    }
                `;break;case"pytorch_half_pixel":N=`
                    vec4 getSourceFracIndex(ivec4 coords) {
                        vec4 fcoords = vec4(coords);
                        return vec4(
                            ${T}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0,
                            ${v}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0,
                            ${T}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0,
                            ${v}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0
                          );
                    }
                `;break;case"align_corners":N=`
                    vec4 getSourceFracIndex(ivec4 coords) {
                        vec4 resized = vec4(${T}.0 - 1.0, ${v}.0 - 1.0, ${T}.0 - 1.0,
                            ${v}.0 - 1.0);
                        vec4 original = vec4(${x}.0 - 1.0, ${S}.0 - 1.0, ${x}.0 - 1.0,
                            ${S}.0 - 1.0);
                        vec4 new_scale = original / resized;
                        return vec4(coords) * new_scale;
                    }
                `;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode:                                 '${g.coordinateTransformMode}'`)}const L=(0,o.getCoordsDataType)(y),E=`
            const vec2 inputWH = vec2(${S}.0, ${x}.0);
            const vec4 scaleWHWH = vec4(float(${P}), float(${I}), float(${P}), float(${I}));
            ${(0,a.unpackFromChannel)()}
            ${N}
            float getAValue(int x10, int r, int c, int d) {
                return getChannel(getA(x10, r, c, d), vec2(c, d));
            }
            void main() {
                ${L} rc = getOutputCoords();

                int batch = rc[0];
                int depth = rc[1];

                // retrieve the 4 coordinates that is used in the 4 packed output values.
                ivec4 coords = ivec4(rc.wz, rc.w + 1, rc.z + 1);

                // calculate the source index in fraction
                vec4 sourceFrac = getSourceFracIndex(coords);

                // get the lower and upper bound of the 4 values that will be packed into one texel.
                ivec4 x00 = ivec4(max(sourceFrac.xy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xy)));
                ivec4 x01 = ivec4(max(sourceFrac.xw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xw)));
                ivec4 x10 = ivec4(max(sourceFrac.zy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zy)));
                ivec4 x11 = ivec4(max(sourceFrac.zw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zw)));

                bool hasNextRow = rc.w < ${v-1};
                bool hasNextCol = rc.z < ${T-1};

                // pack x00, x01, x10, x11's top-left corner into one vec4 structure
                vec4 topLeft = vec4(
                    getAValue(batch, depth, x00.x, x00.y),
                    hasNextCol ? getAValue(batch, depth, x01.x, x01.y) : 0.0,
                    hasNextRow ? getAValue(batch, depth, x10.x, x10.y) : 0.0,
                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.y) : 0.0);

                // pack x00, x01, x10, x11's top-right corner into one vec4 structure
                vec4 topRight = vec4(
                    getAValue(batch, depth, x00.x, x00.w),
                    hasNextCol ? getAValue(batch, depth, x01.x, x01.w) : 0.0,
                    hasNextRow ? getAValue(batch, depth, x10.x, x10.w) : 0.0,
                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.w) : 0.0);

                // pack x00, x01, x10, x11's bottom-left corner into one vec4 structure
                vec4 bottomLeft = vec4(
                    getAValue(batch, depth, x00.z, x00.y),
                    hasNextCol ? getAValue(batch, depth, x01.z, x01.y) : 0.0,
                    hasNextRow ? getAValue(batch, depth, x10.z, x10.y) : 0.0,
                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.y) : 0.0);

                // pack x00, x01, x10, x11's bottom-right corner into one vec4 structure
                vec4 bottomRight = vec4(
                    getAValue(batch, depth, x00.z, x00.w),
                    hasNextCol ? getAValue(batch, depth, x01.z, x01.w) : 0.0,
                    hasNextRow ? getAValue(batch, depth, x10.z, x10.w) : 0.0,
                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.w) : 0.0);

                // calculate the interpolation fraction on u and v direction
                vec4 frac = vec4(sourceFrac) - floor(sourceFrac);
                vec4 clampFrac = clamp(frac, vec4(0.0), vec4(1.0));

                vec4 top = mix(topLeft, topRight, clampFrac.ywyw);
                vec4 bottom = mix(bottomLeft, bottomRight, clampFrac.ywyw);
                vec4 newValue = mix(top, bottom, clampFrac.xxzz);

                ${m.output} = vec4(newValue);
            }
        `;return Object.assign(Object.assign({},f),{output:{dims:b,type:u[0].type,textureType:i.TextureType.packed},hasMain:!0,shaderSource:E})},p=(l,u)=>{const g=l[0].dims;let m,_=u.scales;if(_.length===0){const y=l[u.scalesInputIdx];if(y&&y.size!==0){if(l[u.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");_=s(y,u.mode,u.isResize)}else{const v=l[u.sizesInputIdx];if(!v||v.size===0)throw new Error("Either scales or sizes MUST be provided as input.");m=Array.from(v.integerData),_=t(m,g,u.mode,u.isResize)}}else if(l[u.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");const b=m||g.map((y,v)=>Math.floor(y*_[v]));return[_,b]},s=(l,u,g)=>{const m=Array.from(l.floatData);return(0,d.scalesValidation)(m,u,g),m},t=(l,u,g,m)=>{const _=u.length,b=new Array(_);for(let y=0,v=_;y<v;y++)if(u[y]===0){if(l[y]!==0)throw new Error("Input dim is zero but required output dim is non-zero.");b[y]=1}else b[y]=l[y]/u[y];return(0,d.scalesValidation)(b,g,m),b}},565:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.shape=void 0;const r=n(9240);e.shape=(o,a)=>(i(a),[new r.Tensor([a[0].dims.length],"int32",void 0,void 0,new Int32Array(a[0].dims))]);const i=o=>{if(!o||o.length!==1)throw new Error("Shape requires 1 input.")}},2444:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sliceV10=e.parseSliceAttributes=e.slice=void 0;const r=n(4910),i=n(6145),o=n(7273),a=n(5639),d={name:"Slice",inputNames:["A"],inputTypes:[a.TextureType.unpacked]};e.slice=(t,l,u)=>(h(l),[t.run(Object.assign(Object.assign({},d),{cacheHint:u.cacheKey,get:()=>f(t,l[0],u)}),l)]),e.parseSliceAttributes=t=>{const l=t.attributes.getInts("starts"),u=t.attributes.getInts("ends"),g=t.attributes.getInts("axes",[]);return(0,r.createAttributeWithCacheKey)({starts:l,ends:u,axes:g})};const f=(t,l,u)=>{const g=u.axes.length===0?l.dims.slice(0).map((w,S)=>S):u.axes,m=o.ShapeUtil.normalizeAxes(g,l.dims.length),_=u.starts.map((w,S)=>w>l.dims[m[S]]-1?l.dims[m[S]]:o.ShapeUtil.normalizeAxis(w,l.dims[m[S]])),b=u.ends.map((w,S)=>w>l.dims[m[S]]-1?l.dims[m[S]]:o.ShapeUtil.normalizeAxis(w,l.dims[m[S]])),y=l.dims.slice(),v=[];for(let w=0;w<m.length;w++)y[m[w]]=b[w]-_[w],_[w]>0&&v.push(`outputIdx[${m[w]}] += ${_[w]};`);const T=`
      float process(int outputIdx[${y.length}]) {
        ${v.join(`
      `)}
        return _A(outputIdx);
      }`;return Object.assign(Object.assign({},d),{output:{dims:y,type:l.type,textureType:a.TextureType.unpacked},shaderSource:T})},h=t=>{if(!t||t.length!==1)throw new Error("Slice requires 1 input.");if(i.NUMBER_TYPES.indexOf(t[0].type)===-1)throw new Error("Invalid input type.")};e.sliceV10=(t,l)=>{s(l);const u=p(t,l);return[t.run(Object.assign(Object.assign({},d),{cacheHint:u.cacheKey,get:()=>f(t,l[0],u)}),[l[0]])]};const p=(t,l)=>{if(!t.session.isInitializer(l[1].dataId)||!t.session.isInitializer(l[2].dataId)||l.length>=4&&!t.session.isInitializer(l[3].dataId)||l.length>=5&&!t.session.isInitializer(l[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(l.length>=5&&l[4].integerData.some(_=>_!==1))throw new Error("currently non-1 steps is not supported for Slice");const u=Array.from(l[1].integerData),g=Array.from(l[2].integerData),m=l.length>=4?Array.from(l[3].integerData):[];return{starts:u,ends:g,axes:m,cacheKey:`${m};${u};${g}`}},s=t=>{if(!t||t.length<3||t.length>5)throw new Error("Invalid input number.");if(t[1].type!=="int32"||t[1].dims.length!==1)throw new Error("Invalid input type.");if(t[2].type!=="int32"||t[2].dims.length!==1)throw new Error("Invalid input type.");if(t.length>=4&&(t[3].type!=="int32"||t[3].dims.length!==1))throw new Error("Invalid input type.");if(t.length>=5&&(t[4].type!=="int32"||t[4].dims.length!==1))throw new Error("Invalid input type.")}},815:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.softmaxV13=e.parseSoftmaxAttributesV13=e.parseSoftmaxAttributes=e.softmax=void 0;const r=n(4910),i=n(7273),o=n(6757),a=n(5639),d=n(5707),f={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[a.TextureType.unpacked]},h={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[a.TextureType.unpacked,a.TextureType.unpacked]},p={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[a.TextureType.unpacked,a.TextureType.unpacked,a.TextureType.unpacked]};e.softmax=(m,_,b)=>{g(_);const y=_[0].dims.slice(),v=i.ShapeUtil.normalizeAxis(b.axis,y.length),T=i.ShapeUtil.sizeToDimension(y,v),w=i.ShapeUtil.sizeFromDimension(y,v);return s(m,_,b,T,w)},e.parseSoftmaxAttributes=m=>(0,r.createAttributeWithCacheKey)({axis:m.attributes.getInt("axis",1)}),e.parseSoftmaxAttributesV13=m=>(0,r.createAttributeWithCacheKey)({axis:m.attributes.getInt("axis",-1)}),e.softmaxV13=(m,_,b)=>{g(_);const y=_[0].dims.slice(),v=i.ShapeUtil.normalizeAxis(b.axis,y.length),T=y.length,w=v!==T-1,S=[];let x,P=[],I=[];w&&(P=Array.from({length:T}).map((M,k)=>k),P[v]=T-1,P[T-1]=v,P.map(M=>S.push(y[M])),x=(0,r.createAttributeWithCacheKey)({perm:P}),I=(0,d.transpose)(m,_,x));const N=w?i.ShapeUtil.sizeToDimension(S,T-1):i.ShapeUtil.sizeToDimension(y,T-1),L=w?i.ShapeUtil.sizeFromDimension(S,T-1):i.ShapeUtil.sizeFromDimension(y,T-1),E=s(m,w?I:_,b,N,L);return w?(0,d.transpose)(m,E,x):E};const s=(m,_,b,y,v)=>{const T=t(m,_[0],y,v,[y]),w=m.run(Object.assign(Object.assign({},f),{cacheHint:b.cacheKey,get:()=>T}),_),S=l(m,_[0],y,v,T.output.dims,[y]),x=m.run(Object.assign(Object.assign({},h),{cacheHint:b.cacheKey,get:()=>S}),[_[0],w]),P=u(m,_[0],y,v,T.output.dims,S.output.dims);return[m.run(Object.assign(Object.assign({},p),{cacheHint:b.cacheKey,get:()=>P}),[_[0],w,x])]},t=(m,_,b,y,v)=>{const[T,w]=m.calculateTextureWidthAndHeight(_.dims,a.TextureType.unpacked),S=v.length;if(b<1||y<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(v.length!==1)throw new Error("Dimensionality of the output should be 1");if(v[0]!==b)throw new Error("Shape of the output should be equal to logical row count");const x=(0,o.getGlsl)(m.session.backend.glContext.version),P=`
      float process(int[${S}] indices) {
        int logical_row_start_offset = indices[0] * ${y};

        float max = getColorAsFloat(${x.texture2D}(A, offsetToCoords(logical_row_start_offset, ${T},
        ${w} )));
        for(int i=1; i<${y}; ++i)
        {
          float current = getColorAsFloat(${x.texture2D}(A, offsetToCoords(logical_row_start_offset + i,
            ${T}, ${w})));
          if(current > max)
          max = current;
        }

        return max;
      }`;return Object.assign(Object.assign({},f),{output:{dims:v,type:_.type,textureType:a.TextureType.unpacked},shaderSource:P})},l=(m,_,b,y,v,T)=>{const[w,S]=m.calculateTextureWidthAndHeight(_.dims,a.TextureType.unpacked),x=T.length;if(b<1||y<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(T.length!==1)throw new Error("Dimensionality of the output should be 1");if(T[0]!==b)throw new Error("Shape of the output should be equal to logical row count");if(v.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(v[0]!==b)throw new Error("Shape of the intermediate results should be equal to logical row count");const P=`
      float process(int[${x}] indices) {
        int logical_row_start_offset = indices[0] * ${y};

        float norm_factor = 0.0;
        float max = _Max(indices);
        for(int i=0; i<${y}; ++i)
        {
          norm_factor += exp(getColorAsFloat(${(0,o.getGlsl)(m.session.backend.glContext.version).texture2D}(A, offsetToCoords(logical_row_start_offset + i,
            ${w}, ${S}))) - max);
        }

        return norm_factor;
      }`;return Object.assign(Object.assign({},h),{output:{dims:T,type:_.type,textureType:a.TextureType.unpacked},shaderSource:P})},u=(m,_,b,y,v,T)=>{const[w,S]=m.calculateTextureWidthAndHeight(_.dims,a.TextureType.unpacked),x=_.dims.length;if(b<1||y<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(v.length!==1||T.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(v[0]!==b||T[0]!==b)throw new Error("Shape of the intermediate results should be equal to logical row count");const P=`
      float process(int[${x}] indices) {

      // get offset of current logical tensor index from the 2-D texture coordinates (TexCoords)
      int offset = coordsToOffset(TexCoords, ${w}, ${S});

      //determine the logical row for this index
      int logical_row_index[1];
      logical_row_index[0] = offset / ${y};

      float norm_factor = _Norm(logical_row_index);

      // avoid possible division by 0
      // if norm_facor is 0, all elements are zero
      // if so, return 0
      if(norm_factor == 0.0)
        return 0.0;

      return exp(_A(indices) - _Max(logical_row_index)) / norm_factor;
    }`;return Object.assign(Object.assign({},p),{output:{dims:_.dims,type:_.type,textureType:a.TextureType.unpacked},shaderSource:P})},g=m=>{if(!m||m.length!==1)throw new Error("Softmax requires 1 input.");if(m[0].type!=="float32"&&m[0].type!=="float64")throw new Error("Invalid input type")}},564:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseSplitAttributes=e.split=void 0;const r=n(4910),i=n(7273),o=n(5639),a={name:"Split",inputNames:["A"],inputTypes:[o.TextureType.unpacked]};e.split=(p,s,t)=>{h(s);const l=i.ShapeUtil.normalizeAxis(t.axis,s[0].dims.length),u=d(p,s,l,t),g=[];for(let m=0;m<u;++m)g.push(p.run(Object.assign(Object.assign({},a),{cacheHint:`${t.cacheKey};${m}`,get:()=>f(p,s[0],t,l,m)}),s));return g},e.parseSplitAttributes=p=>{const s=p.attributes.getInt("axis",0),t=p.attributes.getInts("split",[]),l=p.outputs.length;return(0,r.createAttributeWithCacheKey)({axis:s,split:t,numOutputs:l})};const d=(p,s,t,l)=>{const[,u]=i.SplitUtil.splitShape(s[0].dims,t,l.split,l.numOutputs);return u.length},f=(p,s,t,l,u)=>{const[g,m]=i.SplitUtil.splitShape(s.dims,l,t.split,t.numOutputs),_=m[u],b=g[u],y=`
      float process(int indices[${b.length}]) {
        indices[${l}] += ${_};
        return _A(indices);
      }
    `;return Object.assign(Object.assign({},a),{cacheHint:`${t.cacheKey}:${u}`,output:{dims:b,type:s.type,textureType:o.TextureType.unpacked},shaderSource:y})},h=p=>{if(!p||p.length!==1)throw new Error("Split requires one input.");if(p[0].type!=="int8"&&p[0].type!=="uint8"&&p[0].type!=="int16"&&p[0].type!=="uint16"&&p[0].type!=="int32"&&p[0].type!=="uint32"&&p[0].type!=="float32"&&p[0].type!=="float64"&&p[0].type!=="bool")throw new Error("Invalid input type.")}},5416:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseSqueezeAttributes=e.squeezeV13=e.squeeze=void 0;const r=n(7273);e.squeeze=(a,d,f)=>{i(d);const h=r.ShapeUtil.squeezeShape(d[0].dims,f);return[a.reshapeUnpacked(d[0],h)]},e.squeezeV13=(a,d)=>(o(d),(0,e.squeeze)(a,[d[0]],Array.from(d[1].integerData))),e.parseSqueezeAttributes=a=>a.attributes.getInts("axes");const i=a=>{if(!a||a.length!==1)throw new Error("Squeeze requires 1 input.");if(a[0].type==="string")throw new Error("invalid input tensor types.")},o=a=>{if(!a||a.length!==2)throw new Error("Squeeze requires 2 inputs.");if(a[1].type!=="int32")throw new Error("Invalid input type.")}},1240:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sum=void 0;const r=n(6757),i=n(5639);e.sum=(d,f)=>{a(f);const h={name:"Sum",inputNames:f.map((p,s)=>`X${s}`),inputTypes:new Array(f.length).fill(i.TextureType.unpacked)};return[d.run(Object.assign(Object.assign({},h),{get:()=>o(d,f,h)}),f)]};const o=(d,f,h)=>{const p=(0,r.getGlsl)(d.session.backend.glContext.version),s=f[0].dims.slice(),t=`
      void main() {
        vec4 result = ${f.map((l,u)=>`${p.texture2D}(X${u},TexCoords)`).join(" + ")};
        ${p.output} = result;
      }
    `;return Object.assign(Object.assign({},h),{output:{dims:s,type:f[0].type,textureType:i.TextureType.unpacked},hasMain:!0,shaderSource:t})},a=d=>{if(!d||d.length===0)throw new Error("Sum requires inputs.");const f=d[0].dims.length;for(let h=1;h<d.length;h++){if(f!==d[h].dims.length)throw new Error("Input shapes are mismatched.");for(let p=0;p<f;p++)if(d[0].dims[p]!==d[h].dims[p])throw new Error("Input shapes are not matched.")}if(d[0].type!=="float32"&&d[0].type!=="float64")throw new Error("Invalid input type.");for(let h=1;h<d.length;h++)if(d[0].type!==d[h].type)throw new Error("Input types are not matched.")}},5944:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tile=void 0;const r=n(6145),i=n(5639);e.tile=(d,f)=>{a(f);const h={name:"Tile",inputNames:["A"],inputTypes:[i.TextureType.unpacked]};return[d.run(Object.assign(Object.assign({},h),{get:()=>o(d,f,h)}),f)]};const o=(d,f,h)=>{const p=f[0].dims.slice(),s=new Array(p.length),t=[];for(let g=0;g<p.length;g++)s[g]=p[g]*f[1].numberData[g],t.push(`inputIdx[${g}] = int(mod(float(outputIdx[${g}]), ${p[g]}.));`);const l=s.length,u=`
      float process(int outputIdx[${l}]) {
        int inputIdx[${l}];
        ${t.join(`
`)}
        return _A(inputIdx);
      }
    `;return Object.assign(Object.assign({},h),{output:{dims:s,type:f[0].type,textureType:i.TextureType.unpacked},shaderSource:u})},a=d=>{if(!d||d.length!==2)throw new Error("Tile requires 2 input.");if(d[1].dims.length!==1)throw new Error("The second input shape must 1 dimension.");if(d[1].dims[0]!==d[0].dims.length)throw new Error("Invalid input shape.");if(r.NUMBER_TYPES.indexOf(d[0].type)===-1)throw new Error("Invalid input type.");if(d[1].type!=="int32"&&d[1].type!=="int16")throw new Error("Invalid repeat type.")}},5707:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseTransposeAttributes=e.transpose=void 0;const r=n(4910),i=n(7273),o=n(5639),a={name:"Transpose",inputNames:["A"],inputTypes:[o.TextureType.unpacked]};e.transpose=(t,l,u)=>(s(l),[t.run(Object.assign(Object.assign({},a),{cacheHint:u.cacheKey,get:()=>d(t,l[0],u.perm)}),l)]),e.parseTransposeAttributes=t=>(0,r.createAttributeWithCacheKey)({perm:t.attributes.getInts("perm",[])});const d=(t,l,u)=>{const g=l.dims;u=f(g,u);const m=h(g,u),_=g.length,b=`
      ${p("perm",u,_)}
      float process(int indices[${_}]) {
        int a[${_}];
        perm(a, indices);
        return _A(a);
      }`;return Object.assign(Object.assign({},a),{output:{dims:m,type:l.type,textureType:o.TextureType.unpacked},shaderSource:b})},f=(t,l)=>(l&&l.length!==t.length&&(l=[...t.keys()].reverse()),l),h=(t,l)=>(l=f(t,l),i.ShapeUtil.sortBasedOnPerm(t,l)),p=(t,l,u)=>{const g=[];g.push(`void ${t}(out int a[${u}], int src[${u}]) {`);for(let m=0;m<u;++m)g.push(`	a[${l[m]}]=src[${m}];`);return g.push("	}"),g.join(`
`)},s=t=>{if(!t||t.length!==1)throw new Error("Transpose requires 1 input.");if(t[0].type!=="float32"&&t[0].type!=="float64")throw new Error("input should be float tensor")}},2488:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.encodeAsUint8=void 0;const r=n(6757),i=n(5639);e.encodeAsUint8=(o,a)=>{const d=a.shape,f=(0,r.getGlsl)(o.session.backend.glContext.version),h=`
    const float FLOAT_MAX = 1.70141184e38;
    const float FLOAT_MIN = 1.17549435e-38;

    bool isNaN(float val) {
      return (val < 1.0 || 0.0 < val || val == 0.0) ? false : true;
    }

    highp vec4 encodeAsUint8(highp float v) {
      if (isNaN(v)) {
        return vec4(255, 255, 255, 255);
      }

      highp float av = abs(v);

      if(av < FLOAT_MIN) {
        return vec4(0.0, 0.0, 0.0, 0.0);
      } else if(v > FLOAT_MAX) {
        return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;
      } else if(v < -FLOAT_MAX) {
        return vec4(0.0, 0.0,  128.0, 255.0) / 255.0;
      }

      highp vec4 c = vec4(0,0,0,0);

      highp float e = floor(log2(av));
      highp float m = exp2(fract(log2(av))) - 1.0;

      c[2] = floor(128.0 * m);
      m -= c[2] / 128.0;
      c[1] = floor(32768.0 * m);
      m -= c[1] / 32768.0;
      c[0] = floor(8388608.0 * m);

      highp float ebias = e + 127.0;
      c[3] = floor(ebias / 2.0);
      ebias -= c[3] * 2.0;
      c[2] += floor(ebias) * 128.0;

      c[3] += 128.0 * step(0.0, -v);

      return c / 255.0;
    }

    void main() {
      float value = ${f.texture2D}(X,TexCoords).r;
      ${f.output} = encodeAsUint8(value);
    }`,p={name:"Uint8Encode",inputTypes:[i.TextureType.unpacked],inputNames:["X"],output:{dims:d,type:a.tensor.type,textureType:i.TextureType.downloadUint8AsFloat},shaderSource:h,hasMain:!0};return o.executeProgram(p,[a.tensor])}},9087:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tanh=e.tan=e.sqrt=e.sin=e.sigmoid=e.relu=e.not=e.neg=e.log=e.parseLeakyReluAttributes=e.leakyRelu=e.identity=e.floor=e.exp=e.parseEluAttributes=e.elu=e.cos=e.ceil=e.clipV11=e.parseClipAttributes=e.clip=e.atan=e.asin=e.acos=e.abs=e.glslTanh=e.glslTan=e.glslSqrt=e.glslSigmoid=e.glslRelu=e.glslSin=e.glslNot=e.glslNeg=e.glslLog=e.glslLeakyRelu=e.glslIdentity=e.glslClip=e.glslFloor=e.glslExp=e.glslElu=e.glslCos=e.glslCeil=e.glslAtan=e.glslAsin=e.glslAcos=e.glslAbs=void 0;const r=n(4910),i=n(7273),o=n(1997),a=n(6757),d=n(5639);function f(){return E("abs")}function h(){return E("acos")}function p(){return E("asin")}function s(){return E("atan")}function t(){return E("ceil")}function l(){return E("cos")}function u(A){const R="elu";return{body:`
  const float alpha = float(${A});

  float ${R}_(float a) {
    return a >= 0.0 ? a: (exp(a) - 1.0) * alpha;
  }
  vec4 ${R}_(vec4 v) {
    return vec4(${R}_(v.x), ${R}_(v.y), ${R}_(v.z), ${R}_(v.w));
  }
  `,name:R,type:o.FunctionType.ValueBased}}function g(){return E("exp")}function m(){return E("floor")}function _(A,R){const K="clip";return{body:`
  const float min = float(${A});
  const float max = float(${R});

  float ${K}_(float a) {
    return clamp(a, min, max);
  }
  vec4 ${K}_(vec4 v) {
    return clamp(v, min, max);
  }
  `,name:K,type:o.FunctionType.ValueBased}}function b(){const A="indentity";return{body:`
  float ${A}_(float a) {
    return a;
  }
  vec4 ${A}_(vec4 v) {
    return v;
  }
  `,name:A,type:o.FunctionType.ValueBased}}function y(A){const R="leakyRelu";return{body:`
  const float alpha = float(${A});

  float ${R}_(float a) {
    return a < 0.0 ? a * alpha : a;
  }
  vec4 ${R}_(vec4 v) {
    return vec4(${R}_(v.x), ${R}_(v.y), ${R}_(v.z), ${R}_(v.w));
  }
  `,name:R,type:o.FunctionType.ValueBased}}function v(){return E("log")}function T(){const A="neg";return{body:`
  float ${A}_(float a) {
    return -a;
  }
  vec4 ${A}_(vec4 v) {
    return -v;
  }
  `,name:A,type:o.FunctionType.ValueBased}}function w(){const A="not";return{body:`
  float ${A}_(float a) {
    return float( ! bool(a) );
  }
  bool ${A}_(bool a) {
    return !a;
  }
  vec4 ${A}_(vec4 v) {
    return vec4(!bool(v.x), !bool(v.y), !bool(v.z), !bool(v.w));
  }
  bvec4 ${A}_(bvec4 v) {
    return bvec4(!v.x, !v.y, !v.z, !v.w);
  }
  `,name:A,type:o.FunctionType.ValueBased}}function S(){return E("sin")}function x(){const A="relu";return{body:`
  float ${A}_(float a) {
    return max( a, 0.0 );
  }
  vec4 ${A}_(vec4 v) {
    return max( v, 0.0 );
  }
  `,name:A,type:o.FunctionType.ValueBased}}function P(){const A="sigmoid";return{body:`
  float ${A}_(float a) {
    return 1.0 / (1.0 + exp(-a));
  }
  vec4 ${A}_(vec4 v) {
    return 1.0 / (1.0 + exp(-v));
  }
  `,name:A,type:o.FunctionType.ValueBased}}function I(){return E("sqrt")}function N(){return E("tan")}function L(){const A="tanh";return{body:`
  float ${A}_(float a) {
    a = clamp(a, -10., 10.);
    a = exp(2.*a);
    return (a - 1.) / (a + 1.);
  }
  vec4 ${A}_(vec4 v) {
    v = clamp(v, -10., 10.);
    v = exp(2.*v);
    return (v - 1.) / (v + 1.);
  }
  `,name:A,type:o.FunctionType.ValueBased}}function E(A){return{body:`
  float ${A}_(float a) {
    return ${A}(a);
  }
  vec4 ${A}_(vec4 v) {
    return ${A}(v);
  }
  `,name:A,type:o.FunctionType.ValueBased}}e.glslAbs=f,e.glslAcos=h,e.glslAsin=p,e.glslAtan=s,e.glslCeil=t,e.glslCos=l,e.glslElu=u,e.glslExp=g,e.glslFloor=m,e.glslClip=_,e.glslIdentity=b,e.glslLeakyRelu=y,e.glslLog=v,e.glslNeg=T,e.glslNot=w,e.glslSin=S,e.glslRelu=x,e.glslSigmoid=P,e.glslSqrt=I,e.glslTan=N,e.glslTanh=L;const M=(A,R,K,Z)=>{const J=A.session.pack?d.TextureType.packed:d.TextureType.unpacked,X={name:K.name,inputTypes:[J],inputNames:["A"],cacheHint:Z};return Object.assign(Object.assign({},X),{get:()=>((te,oe,ae,ce)=>{const fe=te.session.pack?d.TextureType.packed:d.TextureType.unpacked,he=(0,a.getGlsl)(te.session.backend.glContext.version);return Object.assign(Object.assign({},oe),{output:{dims:ae.dims,type:ae.type,textureType:fe},shaderSource:`
     ${ce.body}
     void main() {
       vec4 v = ${he.texture2D}(A, TexCoords);
       v = ${ce.name}_(v);
       ${he.output} = v;
     }
     `,hasMain:!0})})(A,X,R,K)})};e.abs=(A,R)=>[A.run(M(A,R[0],f()),R)],e.acos=(A,R)=>[A.run(M(A,R[0],h()),R)],e.asin=(A,R)=>[A.run(M(A,R[0],p()),R)],e.atan=(A,R)=>[A.run(M(A,R[0],s()),R)],e.clip=(A,R,K)=>[A.run(M(A,R[0],_(K.min,K.max),K.cacheKey),R)],e.parseClipAttributes=A=>(0,r.createAttributeWithCacheKey)({min:A.attributes.getFloat("min",i.MIN_CLIP),max:A.attributes.getFloat("max",i.MAX_CLIP)}),e.clipV11=(A,R)=>{const K=k(A,R);return(0,e.clip)(A,[R[0]],K)};const k=(A,R)=>{if(R.length>=3&&(!A.session.isInitializer(R[1].dataId)||!A.session.isInitializer(R[2].dataId)))throw new Error("dynamic clip attributes are not allowed");const K=R.length>=3?R[1].numberData[0]:i.MIN_CLIP,Z=R.length>=3?R[2].numberData[0]:i.MAX_CLIP;return(0,r.createAttributeWithCacheKey)({min:K,max:Z})};e.ceil=(A,R)=>[A.run(M(A,R[0],t()),R)],e.cos=(A,R)=>[A.run(M(A,R[0],l()),R)],e.elu=(A,R,K)=>[A.run(M(A,R[0],u(K.alpha),K.cacheKey),R)],e.parseEluAttributes=A=>(0,r.createAttributeWithCacheKey)({alpha:A.attributes.getFloat("alpha",1)}),e.exp=(A,R)=>[A.run(M(A,R[0],g()),R)],e.floor=(A,R)=>[A.run(M(A,R[0],m()),R)],e.identity=(A,R)=>[A.run(M(A,R[0],b()),R)],e.leakyRelu=(A,R,K)=>[A.run(M(A,R[0],y(K.alpha),K.cacheKey),R)],e.parseLeakyReluAttributes=A=>(0,r.createAttributeWithCacheKey)({alpha:A.attributes.getFloat("alpha",.01)}),e.log=(A,R)=>[A.run(M(A,R[0],v()),R)],e.neg=(A,R)=>[A.run(M(A,R[0],T()),R)],e.not=(A,R)=>[A.run(M(A,R[0],w()),R)],e.relu=(A,R)=>[A.run(M(A,R[0],x()),R)],e.sigmoid=(A,R)=>[A.run(M(A,R[0],P()),R)],e.sin=(A,R)=>[A.run(M(A,R[0],S()),R)],e.sqrt=(A,R)=>[A.run(M(A,R[0],I()),R)],e.tan=(A,R)=>[A.run(M(A,R[0],N()),R)],e.tanh=(A,R)=>[A.run(M(A,R[0],L()),R)]},540:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createUnpackProgramInfoLoader=e.createUnpackProgramInfo=void 0;const r=n(6757),i=n(5639),o=n(432),a=n(5614),d={name:"unpack",inputNames:["A"],inputTypes:[i.TextureType.packed]};e.createUnpackProgramInfo=(f,h)=>{const p=h.dims.length,s=(0,a.getChannels)("rc",p),t=s.slice(-2),l=(0,o.getCoordsDataType)(p),u=(0,a.unpackFromChannel)(),g=h.dims.length===0?"":function(b,y){if(b===1)return"rc";let v="";for(let T=0;T<b;T++)v+=y[T],T<b-1&&(v+=",");return v}(p,s),m=p<=1?"rc":`vec2(${t.join(",")})`,_=`
    ${u}
    void main() {
      ${l} rc = getOutputCoords();

       // Sample the texture with the coords to get the rgba channel value.
       vec4 packedInput = getA(${g});

       ${(0,r.getGlsl)(f.session.backend.glContext.version).output} = vec4(getChannel(packedInput, ${m}), 0, 0, 0);
     }
   `;return Object.assign(Object.assign({},d),{hasMain:!0,output:{dims:h.dims,type:h.type,textureType:i.TextureType.unpacked},shaderSource:_})},e.createUnpackProgramInfoLoader=(f,h)=>Object.assign(Object.assign({},d),{get:()=>(0,e.createUnpackProgramInfo)(f,h)})},7862:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseUnsqueezeAttributes=e.unsqueezeV13=e.unsqueeze=void 0;const r=n(7273);e.unsqueeze=(a,d,f)=>{i(d);const h=r.ShapeUtil.unsqueezeShape(d[0].dims,f);return[a.reshapeUnpacked(d[0],h)]},e.unsqueezeV13=(a,d)=>(o(d),(0,e.unsqueeze)(a,[d[0]],Array.from(d[1].integerData))),e.parseUnsqueezeAttributes=a=>a.attributes.getInts("axes");const i=a=>{if(!a||a.length!==1)throw new Error("Unsqueeze requires 1 input.");if(a[0].type==="string")throw new Error("invalid input tensor types.")},o=a=>{if(!a||a.length!==2)throw new Error("Unsqueeze requires 2 inputs.");if(a[1].type!=="int32")throw new Error("Invalid input type.")}},3980:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.scalesValidation=e.validateInputs=e.parseUpsampleAttributes=e.parseUpsampleAttributesV9=e.parseUpsampleAttributesV7=e.upsample=void 0;const r=n(4910),i=n(6757),o=n(5639),a={name:"Upsample",inputNames:["X"],inputTypes:[o.TextureType.unpacked]};e.upsample=(f,h,p)=>((0,e.validateInputs)(h,p),[f.run(Object.assign(Object.assign({},a),{cacheHint:p.cacheKey,get:()=>d(f,h,p)}),h)]),e.parseUpsampleAttributesV7=f=>(0,e.parseUpsampleAttributes)(f,7),e.parseUpsampleAttributesV9=f=>(0,e.parseUpsampleAttributes)(f,9),e.parseUpsampleAttributes=(f,h)=>{const p=h>=10,s=f.attributes.getString("mode","nearest");if(s!=="nearest"&&s!=="linear"&&(h<11||s!=="cubic"))throw new Error(`unrecognized mode: ${s}`);let t=[];h<9&&(t=f.attributes.getFloats("scales"),(0,e.scalesValidation)(t,s,p));const l=f.attributes.getFloat("extrapolation_value",0),u=h>10?f.attributes.getString("coordinate_transformation_mode","half_pixel"):"asymmetric";if(["asymmetric","pytorch_half_pixel","tf_half_pixel_for_nn","align_corners","tf_crop_and_resize","half_pixel"].indexOf(u)===-1)throw new Error(`coordinate_transform_mode '${u}' is not supported`);const g=u==="tf_crop_and_resize",m=g,_=s==="nearest"&&h>=11?f.attributes.getString("nearest_mode","round_prefer_floor"):"";if(["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(_)===-1)throw new Error(`nearest_mode '${_}' is not supported`);const b=f.attributes.getFloat("cubic_coeff_a",-.75),y=f.attributes.getInt("exclude_outside",0)!==0;if(y&&s!=="cubic")throw new Error("exclude_outside can be set to 1 only when mode is CUBIC.");const v=h<11||s==="nearest"&&u==="asymmetric"&&_==="floor";let T=0,w=0,S=0;return h>10?f.inputs.length>2?(T=1,w=2,S=3):(w=1,S=2):h===9&&(w=1),(0,r.createAttributeWithCacheKey)({opset:h,isResize:p,mode:s,scales:t,extrapolationValue:l,coordinateTransformMode:u,useExtrapolation:m,needRoiInput:g,nearestMode:_,cubicCoefficientA:b,excludeOutside:y,useNearest2xOptimization:v,roiInputIdx:T,scalesInputIdx:w,sizesInputIdx:S})};const d=(f,h,p)=>{const s=(0,i.getGlsl)(f.session.backend.glContext.version),[t,l]=f.calculateTextureWidthAndHeight(h[0].dims,o.TextureType.unpacked),u=h[0].dims.map((S,x)=>Math.floor(S*p.scales[x])),[g,m]=f.calculateTextureWidthAndHeight(u,o.TextureType.unpacked),_=u.length,b=new Array(_),y=new Array(_);let v=`
      int output_pitches[${_}];
      int input_pitches[${_}];
      `;for(let S=_-1;S>=0;S--)b[S]=S===_-1?1:b[S+1]*u[S+1],y[S]=S===_-1?1:y[S+1]*h[0].dims[S+1],v+=`
        output_pitches[${S}] = ${b[S]};
        input_pitches[${S}] = ${y[S]};
        `;const T=`
      float getInputFloat(int index) {
        vec2 coords = offsetToCoords(index, ${t}, ${l});
        float value = getColorAsFloat(${s.texture2D}(X, coords));
        return value;
      }
      `,w=p.mode==="nearest"?`
    ${T}
    float process(int indices[${_}]) {
      int input_index = 0;
      int output_index = coordsToOffset(TexCoords, ${g}, ${m});

      ${v}

      int d, m;
      for (int dim = 0; dim < ${_}; ++dim) {
        d = output_index / output_pitches[dim];
        m = output_index - d * output_pitches[dim];
        output_index = m;

        if (scales[dim] != 1 && d > 0) {
          int d2 = d / scales[dim];
          m = d - d2 * scales[dim];
          d = d2;
        }
        input_index += input_pitches[dim] * d;
      }

      return getInputFloat(input_index);
    }`:_===4?`
    ${T}
    float process(int indices[4]) {
      int input_index = 0;
      int output_index = coordsToOffset(TexCoords, ${g}, ${m});

      ${v}

      int m;
      int index_of_dim0, index_of_dim1, index_of_dim2, index_of_dim3;
      index_of_dim0 = output_index / output_pitches[0];
      m = output_index - index_of_dim0 * output_pitches[0];
      index_of_dim1 = m / output_pitches[1];
      m = m - index_of_dim1 * output_pitches[1];
      index_of_dim2 = m / output_pitches[2];
      m = m - index_of_dim2 * output_pitches[2];
      index_of_dim3 = m;

      int index_of_input_dim2, index_of_input_dim3, x_offset, y_offset;
      index_of_input_dim2 = index_of_dim2 / scales[2];
      y_offset = index_of_dim2 - index_of_input_dim2 * scales[2];
      index_of_input_dim3 = index_of_dim3 / scales[3];
      x_offset = index_of_dim3 - index_of_input_dim3 * scales[3];

      input_index = index_of_dim0 * input_pitches[0] +
            index_of_dim1 * input_pitches[1] +
            index_of_input_dim2 * input_pitches[2] +
            index_of_input_dim3;

      float x00 = getInputFloat(input_index);
      float x10, x01, x11;

      bool end_of_dim2 = false;
      if (index_of_input_dim2 == (${h[0].dims[2]} - 1)) {
        // It's the end in dimension 2
        x01 = x00;
        end_of_dim2 = true;
      } else {
        x01 = getInputFloat(input_index + input_pitches[2]);
      }

      if (index_of_input_dim3 == (input_pitches[2] - 1)) {
        // It's the end in dimension 3
        x10 = x00;
        x11 = x01;
      }
      else {
        x10 = getInputFloat(input_index + 1);
        x11 = end_of_dim2 ? x10 : getInputFloat(input_index + input_pitches[2] + 1);
      }

      float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[2]);
      float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[2]);
      return y0 + float(x_offset) * (y1 - y0) / float(scales[3]);
    }`:`
    ${T}
    float process(int indices[2]) {
      int input_index = 0;
      int output_index = coordsToOffset(TexCoords, ${g}, ${m});

      ${v}

      int m;
      int index_of_dim0, index_of_dim1;
      index_of_dim0 = output_index / output_pitches[0];
      m = output_index - index_of_dim0 * output_pitches[0];
      index_of_dim1 = m;

      int index_of_input_dim0, index_of_input_dim1, x_offset, y_offset;
      index_of_input_dim0 = index_of_dim0 / scales[0];
      y_offset = index_of_dim0 - index_of_input_dim0 * scales[0];
      index_of_input_dim1 = index_of_dim1 / scales[1];
      x_offset = index_of_dim1 - index_of_input_dim1 * scales[1];

      input_index = index_of_input_dim0 * input_pitches[0] + index_of_input_dim1;

      float x00 = getInputFloat(input_index);
      float x10, x01, x11;

      bool end_of_dim0 = false;
      if (index_of_input_dim0 == (${h[0].dims[0]} - 1)) {
        // It's the end in dimension 0
        x01 = x00;
        end_of_dim0 = true;
      } else {
        x01 = getInputFloat(input_index + input_pitches[0]);
      }

      if (index_of_input_dim1 == (input_pitches[0] - 1)) {
        // It's the end in dimension 1
        x10 = x00;
        x11 = x01;
      }
      else {
        x10 = getInputFloat(input_index + 1);
        x11 = end_of_dim0 ? x10 : getInputFloat(input_index + input_pitches[0] + 1);
      }

      float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[0]);
      float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[0]);
      return y0 + float(x_offset) * (y1 - y0) / float(scales[1]);
    }`;return Object.assign(Object.assign({},a),{output:{dims:u,type:h[0].type,textureType:o.TextureType.unpacked},shaderSource:w,variables:[{name:"scales",type:"int",arrayLength:p.scales.length,data:p.scales.map(S=>Math.ceil(S))}]})};e.validateInputs=(f,h)=>{if(!f||h.opset<9&&f.length!==1||h.opset>=9&&h.opset<11&&f.length!==2||h.opset>=11&&f.length<2)throw new Error("invalid inputs.");if(h.scales.length>0&&f[0].dims.length!==h.scales.length)throw new Error("Invalid input shape.");if(f[0].type==="string")throw new Error("Invalid input tensor types.")},e.scalesValidation=(f,h,p)=>{if(p){for(const s of f)if(s<=0)throw new Error("Scale value should be greater than 0.")}else for(const s of f)if(s<1)throw new Error("Scale value should be greater than or equal to 1.");if(!(h!=="linear"&&h!=="cubic"||f.length===2||f.length===4&&f[0]===1&&f[1]===1))throw new Error(`'Linear' mode and 'Cubic' mode only support 2-D inputs ('Bilinear', 'Bicubic')         or 4-D inputs with the corresponding outermost 2 scale values being 1         in the ${p?"Resize":"Upsample"} opeartor.`)}},2757:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ProgramManager=void 0;const r=n(2235),i=n(1315),o=n(8897),a=n(6757);e.ProgramManager=class{constructor(d,f,h){this.profiler=d,this.glContext=f,this.textureLayoutStrategy=h,this.repo=new Map,this.attributesBound=!1}getArtifact(d){return this.repo.get(d)}setArtifact(d,f){this.repo.set(d,f)}run(d,f,h){var p;this.profiler.event("op",`ProgramManager.run ${(p=d.programInfo.name)!==null&&p!==void 0?p:"unknown kernel"}`,()=>{var s;const t=this.glContext.gl,l=d.program;t.useProgram(l);try{this.bindOutput(h),this.attributesBound||this.bindAttributes(d.attribLocations),this.bindUniforms(d.uniformLocations,(s=d.programInfo.variables)!==null&&s!==void 0?s:[],f)}catch(u){throw i.Logger.error("ProgramManager",d.programInfo.shaderSource),u}this.profiler.event("backend","GlContext.draw()",()=>{this.glContext.draw()})},this.glContext)}dispose(){this.vertexShader&&this.glContext.deleteShader(this.vertexShader),this.repo.forEach(d=>this.glContext.deleteProgram(d.program))}build(d,f,h){return this.profiler.event("backend","ProgramManager.build",()=>{const p=new o.GlslPreprocessor(this.glContext,d,f,h),s=p.preprocess(),t=this.compile(s);return{programInfo:d,program:t,uniformLocations:this.getUniformLocations(t,p.context.programInfo.inputNames,p.context.programInfo.variables),attribLocations:this.getAttribLocations(t)}})}compile(d){if(!this.vertexShader){i.Logger.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");const p=(0,a.getVertexShaderSource)(this.glContext.version);this.vertexShader=this.glContext.compileShader(p,this.glContext.gl.VERTEX_SHADER)}r.env.debug&&i.Logger.verbose("ProrgramManager",`FragShader:
${d}
`);const f=this.glContext.compileShader(d,this.glContext.gl.FRAGMENT_SHADER),h=this.glContext.createProgram(this.vertexShader,f);return this.glContext.deleteShader(f),h}bindOutput(d){const f=d.width,h=d.height;i.Logger.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${f}/${h}, shape=${d.shape}, type=${d.tensor.type}`),this.glContext.attachFramebuffer(d.texture,f,h)}bindAttributes(d){const f=d.position,h=d.textureCoord;this.glContext.setVertexAttributes(f,h),this.attributesBound=!0}bindUniforms(d,f,h){var p;const s=this.glContext.gl;let t=0;for(const{name:l,type:u,location:g,arrayLength:m}of d){const _=(p=f.find(b=>b.name===l))===null||p===void 0?void 0:p.data;if(u!=="sampler2D"&&!_)throw new Error(`variable '${l}' does not have data defined in program info`);switch(u){case"sampler2D":this.bindTexture(h[t],g,t),t++;break;case"float":m?s.uniform1fv(g,_):s.uniform1f(g,_);break;case"int":m?s.uniform1iv(g,_):s.uniform1i(g,_);break;default:throw new Error(`Uniform not implemented: ${u}`)}}}bindTexture(d,f,h){this.glContext.bindTextureToUniform(d.texture,h,f)}getAttribLocations(d){return{position:this.getAttribLocation(d,"position"),textureCoord:this.getAttribLocation(d,"textureCoord")}}getUniformLocations(d,f,h){const p=[];if(f)for(const s of f)p.push({name:s,type:"sampler2D",location:this.getUniformLocation(d,s)});if(h)for(const s of h)p.push(Object.assign(Object.assign({},s),{location:this.getUniformLocation(d,s.name)}));return p}getUniformLocation(d,f){const h=this.glContext.gl.getUniformLocation(d,f);if(h===null)throw new Error(`Uniform ${f} not found.`);return h}getAttribLocation(d,f){return this.glContext.gl.getAttribLocation(d,f)}}},2171:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLSessionHandler=void 0;const r=n(1315),i=n(5881),o=n(7860),a=n(4110),d=n(2757),f=n(7618),h=n(5243);e.WebGLSessionHandler=class{constructor(p,s){this.backend=p,this.context=s,this.layoutStrategy=new f.PreferLogicalStrategy(p.glContext.maxTextureSize),this.programManager=new d.ProgramManager(this.context.profiler,p.glContext,this.layoutStrategy),this.textureManager=new h.TextureManager(p.glContext,this.layoutStrategy,this.context.profiler,{reuseTextures:p.textureCacheMode==="full"}),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map,this.pack=p.pack,this.pack2unpackMap=new Map,this.unpack2packMap=new Map}createInferenceHandler(){return new o.WebGLInferenceHandler(this)}onGraphInitialized(p){const s=p.getValues().filter(t=>t.from===-1&&t.tensor).map(t=>t.tensor.dataId);this.initializers=new Set(s)}isInitializer(p){return!!this.initializers&&this.initializers.has(p)}addInitializer(p){this.initializers.add(p)}getTextureData(p,s){return s?this.packedTextureDataCache.get(p):this.unpackedTextureDataCache.get(p)}setTextureData(p,s,t=!1){r.Logger.verbose("WebGLSessionHandler","Storing Texture data in cache"),t?this.packedTextureDataCache.set(p,s):this.unpackedTextureDataCache.set(p,s)}dispose(){this.programManager.dispose(),this.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(p=>this.textureManager.releaseTexture(p,!0)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(p=>this.textureManager.releaseTexture(p,!0)),this.unpackedTextureDataCache=new Map}resolve(p,s,t){const l=(0,i.resolveOperator)(p,s,a.WEBGL_OP_RESOLVE_RULES);return{impl:l.opImpl,context:l.opInit?l.opInit(p,t):p}}}},9622:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Uint8DataEncoder=e.RGBAFloatDataEncoder=e.RedFloat32DataEncoder=void 0;const r=n(1315);e.RedFloat32DataEncoder=class{constructor(i,o=1){if(o===1)this.internalFormat=i.R32F,this.format=i.RED,this.textureType=i.FLOAT,this.channelSize=o;else{if(o!==4)throw new Error(`Invalid number of channels: ${o}`);this.internalFormat=i.RGBA32F,this.format=i.RGBA,this.textureType=i.FLOAT,this.channelSize=o}}encode(i,o){let a,d;return i.constructor!==Float32Array&&(r.Logger.warning("Encoder","data was not of type Float32; creating new Float32Array"),d=new Float32Array(i)),o*this.channelSize>i.length?(r.Logger.warning("Encoder","Source data too small. Allocating larger array"),d=i,a=this.allocate(o*this.channelSize),d.forEach((f,h)=>a[h]=f)):(d=i,a=d),a}allocate(i){return new Float32Array(4*i)}decode(i,o){return this.channelSize===1?i.filter((a,d)=>d%4==0).subarray(0,o):i.subarray(0,o)}},e.RGBAFloatDataEncoder=class{constructor(i,o=1,a){if(o!==1&&o!==4)throw new Error(`Invalid number of channels: ${o}`);this.internalFormat=i.RGBA,this.format=i.RGBA,this.channelSize=o,this.textureType=a||i.FLOAT}encode(i,o){let a=i;return this.channelSize===1&&(r.Logger.verbose("Encoder","Exploding into a larger array"),a=this.allocate(o),i.forEach((d,f)=>a[4*f]=d)),a}allocate(i){return new Float32Array(4*i)}decode(i,o){return this.channelSize===1?i.filter((a,d)=>d%4==0).subarray(0,o):i.subarray(0,o)}},e.Uint8DataEncoder=class{constructor(i,o=1){if(this.channelSize=4,o===1)this.internalFormat=i.ALPHA,this.format=i.ALPHA,this.textureType=i.UNSIGNED_BYTE,this.channelSize=o;else{if(o!==4)throw new Error(`Invalid number of channels: ${o}`);this.internalFormat=i.RGBA,this.format=i.RGBA,this.textureType=i.UNSIGNED_BYTE,this.channelSize=o}}encode(i,o){return new Uint8Array(i.buffer,i.byteOffset,i.byteLength)}allocate(i){return new Uint8Array(i*this.channelSize)}decode(i,o){if(i instanceof Uint8Array)return i.subarray(0,o);throw new Error(`Invalid array type: ${i.constructor}`)}}},7618:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getBatchDim=e.sizeToSquarishShape=e.getRowsCols=e.sizeFromShape=e.isInt=e.parseAxisParam=e.squeezeShape=e.PreferLogicalStrategy=e.AlwaysKeepOriginalSizeStrategy=void 0;const r=n(1315),i=n(7273);function o(p,s){const t=[],l=[],u=s!=null&&Array.isArray(s)&&s.length===0,g=s==null||u?null:a(s,p).sort();let m=0;for(let _=0;_<p.length;++_){if(g!=null){if(g[m]===_&&p[_]!==1)throw new Error(`Can't squeeze axis ${_} since its dim '${p[_]}' is not 1`);(g[m]==null||g[m]>_)&&p[_]===1&&(t.push(p[_]),l.push(_)),g[m]<=_&&m++}p[_]!==1&&(t.push(p[_]),l.push(_))}return{newShape:t,keptDims:l}}function a(p,s){const t=s.length;return p=p==null?s.map((l,u)=>u):[].concat(p),(0,i.assert)(p.every(l=>l>=-t&&l<t),()=>`All values in axis param must be in range [-${t}, ${t}) but got axis ${p}`),(0,i.assert)(p.every(d),()=>`All values in axis param must be integers but got axis ${p}`),p.map(l=>l<0?t+l:l)}function d(p){return p%1==0}function f(p){if(p.length===0)return 1;let s=p[0];for(let t=1;t<p.length;t++)s*=p[t];return s}function h(p){const s=Math.ceil(Math.sqrt(p));return[s,Math.ceil(p/s)]}e.AlwaysKeepOriginalSizeStrategy=class{constructor(p){this.maxTextureSize=p}computeTextureWH(p,s){if(p.length===0)return[1,1];const t=this.maxTextureSize;if(s&&s.breakAxis!==void 0){const g=s.breakAxis>=p.length?1:p.slice(s.breakAxis).reduce((_,b)=>_*b),m=s.breakAxis<=0?1:p.slice(0,s.breakAxis).reduce((_,b)=>_*b);if(!(g>t||m>t))return[g,m];r.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${p}, breakAxis:${s.breakAxis}`)}const l=p.reduce((g,m)=>g*m);let u=Math.floor(Math.sqrt(l));for(;u<t&&u<l&&l%u!=0;u++);if(u>=t||l%u!=0)throw new Error(`The given dimensions are outside this GPU's boundaries: ${p}`);return[u,l/u]}},e.PreferLogicalStrategy=class{constructor(p){this.maxTextureSize=p}computeTextureWH(p,s){const t=this.computeTexture(p,s);return s&&s.isPacked&&(t[0]/=2,t[1]/=2),s&&s.reverseWH?[t[1],t[0]]:t}computeTexture(p,s){const t=s&&s.isPacked;if(p.length===0)return t?[2,2]:[1,1];let l=this.maxTextureSize;if(s&&s.breakAxis!==void 0){const m=s.breakAxis>=p.length?1:p.slice(s.breakAxis).reduce((b,y)=>b*y),_=s.breakAxis<=0?1:p.slice(0,s.breakAxis).reduce((b,y)=>b*y);if(!(m>l||_>l))return[m,_];r.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${p}, breakAxis:${s.breakAxis}`)}let u=p.slice(0);t&&(l*=2,u=u.map((m,_)=>_>=u.length-2?u[_]%2==0?u[_]:u[_]+1:u[_]),u.length===1&&(u=[2,u[0]])),u.length!==2&&(u=o(u).newShape);const g=f(u);return u.length<=1&&g<=l?[1,g]:u.length===2&&u[0]<=l&&u[1]<=l?u:u.length===3&&u[0]*u[1]<=l&&u[2]<=l?[u[0]*u[1],u[2]]:u.length===3&&u[0]<=l&&u[1]*u[2]<=l?[u[0],u[1]*u[2]]:u.length===4&&u[0]*u[1]*u[2]<=l&&u[3]<=l?[u[0]*u[1]*u[2],u[3]]:u.length===4&&u[0]<=l&&u[1]*u[2]*u[3]<=l?[u[0],u[1]*u[2]*u[3]]:t?h(g/4).map(m=>2*m):h(g)}},e.squeezeShape=o,e.parseAxisParam=a,e.isInt=d,e.sizeFromShape=f,e.getRowsCols=function(p){if(p.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[p.length>1?p[p.length-2]:1,p[p.length-1]]},e.sizeToSquarishShape=h,e.getBatchDim=function(p,s=2){return f(p.slice(0,p.length-s))}},3314:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createTextureLayoutFromShape=e.calculateTextureWidthAndHeight=e.createTextureLayoutFromTextureType=void 0;const r=n(7273),i=n(5639);e.createTextureLayoutFromTextureType=(o,a,d)=>{const f=d===i.TextureType.unpacked||d===i.TextureType.unpackedReversed?1:4,h=d===i.TextureType.packed,p=d===i.TextureType.unpackedReversed||d===i.TextureType.packed,s=d===i.TextureType.packedLastDimension?a.length-1:void 0,t=d===i.TextureType.packedLastDimension?a.map((l,u)=>u===a.length-1?4*l:l):void 0;return(0,e.createTextureLayoutFromShape)(o,a,f,t,{isPacked:h,reverseWH:p,breakAxis:s})},e.calculateTextureWidthAndHeight=(o,a,d)=>{const f=(0,e.createTextureLayoutFromTextureType)(o,a,d);return[f.width,f.height]},e.createTextureLayoutFromShape=(o,a,d=1,f,h)=>{const p=!(!h||!h.isPacked),[s,t]=o.computeTextureWH(p&&f||a,h),l=a.length;let u=a.slice(0);if(l===0&&(u=[1]),d===1)f=a;else if(p){if(d!==4)throw new Error("a packed texture must be 4-channel");f=a,l>0&&(u[l-1]=Math.ceil(u[l-1]/2)),l>1&&(u[l-2]=Math.ceil(u[l-2]/2))}else if(!f)throw new Error("Unpacked shape is needed when using channels > 1");return{width:s,height:t,channels:d,isPacked:p,shape:u,strides:r.ShapeUtil.computeStrides(u),unpackedShape:f,reversedWH:h&&h.reverseWH}}},5243:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TextureManager=void 0;const r=n(1315);e.TextureManager=class{constructor(i,o,a,d){this.glContext=i,this.layoutStrategy=o,this.profiler=a,this.config=d,this.pendingRead=new Map,d.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(i,o,a,d){const f=this.toEncoderType(i),h=this.glContext.getEncoder(f,o.channels||1,d);if(o.isPacked&&d===1)throw new Error("not implemented");const p=o.width,s=o.height;let t,l;if(this.config.reuseTextures){t=`${p}x${s}_${h.format}_${h.internalFormat}_${h.textureType}`,l=this.inUseTextures.get(t),l||(l=[],this.inUseTextures.set(t,l));const g=this.idleTextures.get(t);if(g&&g.length>0){const m=g.pop();return l.push(m),d===1&&this.glContext.updateTexture(m,p,s,h,this.toTextureData(i,a)),m}}r.Logger.verbose("TextureManager",`Creating new texture of size ${o.width}x${o.height}`);const u=this.glContext.allocateTexture(p,s,h,this.toTextureData(i,a));return this.config.reuseTextures&&(l.push(u),this.textureLookup.set(u,t)),u}readTexture(i,o,a){return a||(a=1),this.profiler.event("backend","TextureManager.readTexture",()=>{const d=i.shape.reduce((h,p)=>h*p)*a,f=this.glContext.readTexture(i.texture,i.width,i.height,d,this.toEncoderType(o),a);return this.toTensorData(o,f)})}async readTextureAsync(i,o,a){const d=i.tensor.dataId;if(a||(a=1),this.pendingRead.has(d)){const f=this.pendingRead.get(d);return new Promise(h=>f==null?void 0:f.push(h))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(d,[]);const f=i.shape.reduce((t,l)=>t*l)*a;await this.glContext.createAndWaitForFence();const h=this.glContext.readTexture(i.texture,i.width,i.height,f,this.toEncoderType(o),a),p=this.toTensorData(o,h),s=this.pendingRead.get(d);return this.pendingRead.delete(d),s==null||s.forEach(t=>t(p)),p})}readUint8TextureAsFloat(i){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{const o=i.shape.reduce((d,f)=>d*f),a=this.glContext.readTexture(i.texture,i.width,i.height,4*o,"byte",4);return new Float32Array(a.buffer,a.byteOffset,o)})}releaseTexture(i,o){let a;if(this.config.reuseTextures&&(a=this.textureLookup.get(i.texture),a)){o&&this.textureLookup.delete(a);const d=this.inUseTextures.get(a);if(d){const f=d.indexOf(i.texture);if(f!==-1){d.splice(f,1);let h=this.idleTextures.get(a);h||(h=[],this.idleTextures.set(a,h)),h.push(i.texture)}}}a&&!o||(r.Logger.verbose("TextureManager",`Deleting texture of size ${i.width}x${i.height}`),this.glContext.deleteTexture(i.texture))}toTensorData(i,o){switch(i){case"int16":return o instanceof Int16Array?o:Int16Array.from(o);case"int32":return o instanceof Int32Array?o:Int32Array.from(o);case"int8":return o instanceof Int8Array?o:Int8Array.from(o);case"uint16":return o instanceof Uint16Array?o:Uint16Array.from(o);case"uint32":return o instanceof Uint32Array?o:Uint32Array.from(o);case"uint8":case"bool":return o instanceof Uint8Array?o:Uint8Array.from(o);case"float32":return o instanceof Float32Array?o:Float32Array.from(o);case"float64":return o instanceof Float64Array?o:Float64Array.from(o);default:throw new Error(`TensorData type ${i} is not supported`)}}toTextureData(i,o){if(o)return o instanceof Float32Array?o:new Float32Array(o)}toEncoderType(i){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}},5639:(c,e)=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.TextureType=void 0,(n=e.TextureType||(e.TextureType={}))[n.unpacked=0]="unpacked",n[n.unpackedReversed=1]="unpackedReversed",n[n.packed=2]="packed",n[n.downloadUint8AsFloat=3]="downloadUint8AsFloat",n[n.packedLastDimension=4]="packedLastDimension"},432:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getGlChannels=e.getCoordsDataType=e.getSqueezedParams=e.squeezeInputShape=e.generateShaderFuncNameFromInputSamplerNameAtOutCoords=e.generateShaderFuncNameFromInputSamplerName=e.repeatedTry=e.getPackedShape=void 0;const r=n(7273);e.getPackedShape=function(i){const o=i.length;return i.slice(0,o-1).concat(i[o-1]/4)},e.repeatedTry=async function(i,o=d=>0,a){return new Promise((d,f)=>{let h=0;const p=()=>{if(i())return void d();h++;const s=o(h);a!=null&&h>=a?f():setTimeout(p,s)};p()})},e.generateShaderFuncNameFromInputSamplerName=function(i){return(0,r.assert)(i!==void 0&&i.length!==0,()=>"empty string found for sampler name"),"get"+i.charAt(0).toUpperCase()+i.slice(1)},e.generateShaderFuncNameFromInputSamplerNameAtOutCoords=function(i){return(0,r.assert)(i!==void 0&&i.length!==0,()=>"empty string found for sampler name"),"get"+i.charAt(0).toUpperCase()+i.slice(1)+"AtOutCoords"},e.squeezeInputShape=function(i,o){let a=JSON.parse(JSON.stringify(i));return a=o,a},e.getSqueezedParams=function(i,o){return o.map(a=>i[a]).join(", ")},e.getCoordsDataType=function(i){if(i<=1)return"int";if(i===2)return"ivec2";if(i===3)return"ivec3";if(i===4)return"ivec4";if(i===5)return"ivec5";if(i===6)return"ivec6";throw Error(`GPU for rank ${i} is not yet supported`)},e.getGlChannels=function(i=6){return["x","y","z","w","u","v"].slice(0,i)}},3389:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createNewWebGLContext=e.createWebGLContext=void 0;const r=n(1315),i=n(3524),o={};function a(d,f){let h;const p={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1};if((!f||f==="webgl2")&&(h=d.getContext("webgl2",p),h))try{return new i.WebGLContext(h,2)}catch(s){r.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${s}`)}if((!f||f==="webgl")&&(h=d.getContext("webgl",p)||d.getContext("experimental-webgl",p),h))try{return new i.WebGLContext(h,1)}catch(s){r.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${s}`)}throw new Error("WebGL is not supported")}e.createWebGLContext=function d(f){let h;if(f&&f!=="webgl2"||!("webgl2"in o)?f&&f!=="webgl"||!("webgl"in o)||(h=o.webgl):h=o.webgl2,!h)try{h=a(function(){if(typeof OffscreenCanvas>"u")throw new TypeError("failed to create offscreen canvas: OffscreenCanvas is not supported");return new OffscreenCanvas(1,1)}(),f)}catch{h=a(function(){if(typeof document>"u")throw new TypeError("failed to create canvas: document is not supported");const t=document.createElement("canvas");return t.width=1,t.height=1,t}(),f)}f=f||h.version===1?"webgl":"webgl2";const p=h.gl;return o[f]=h,p.isContextLost()?(delete o[f],d(f)):(p.disable(p.DEPTH_TEST),p.disable(p.STENCIL_TEST),p.disable(p.BLEND),p.disable(p.DITHER),p.disable(p.POLYGON_OFFSET_FILL),p.disable(p.SAMPLE_COVERAGE),p.enable(p.SCISSOR_TEST),p.enable(p.CULL_FACE),p.cullFace(p.BACK),h)},e.createNewWebGLContext=a},3524:function(c,e,n){var r=this&&this.__createBinding||(Object.create?function(p,s,t,l){l===void 0&&(l=t);var u=Object.getOwnPropertyDescriptor(s,t);u&&!("get"in u?!s.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return s[t]}}),Object.defineProperty(p,l,u)}:function(p,s,t,l){l===void 0&&(l=t),p[l]=s[t]}),i=this&&this.__setModuleDefault||(Object.create?function(p,s){Object.defineProperty(p,"default",{enumerable:!0,value:s})}:function(p,s){p.default=s}),o=this&&this.__importStar||function(p){if(p&&p.__esModule)return p;var s={};if(p!=null)for(var t in p)t!=="default"&&Object.prototype.hasOwnProperty.call(p,t)&&r(s,p,t);return i(s,p),s};Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLContext=e.linearSearchLastTrue=void 0;const a=n(2235),d=o(n(9622)),f=n(432);function h(p){let s=0;for(;s<p.length&&p[s]();++s);return s-1}e.linearSearchLastTrue=h,e.WebGLContext=class{constructor(p,s){this.frameBufferBound=!1,this.itemsToPoll=[],this.gl=p,this.version=s,this.getExtensions(),this.vertexbuffer=this.createVertexbuffer(),this.framebuffer=this.createFramebuffer(),this.queryVitalParameters()}allocateTexture(p,s,t,l){const u=this.gl,g=u.createTexture();u.bindTexture(u.TEXTURE_2D,g),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,u.NEAREST),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,u.NEAREST),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE);const m=l?t.encode(l,p*s):null;return u.texImage2D(u.TEXTURE_2D,0,t.internalFormat,p,s,0,t.format,t.textureType,m),this.checkError(),g}updateTexture(p,s,t,l,u){const g=this.gl;g.bindTexture(g.TEXTURE_2D,p);const m=l.encode(u,s*t);g.texSubImage2D(g.TEXTURE_2D,0,0,0,s,t,l.format,l.textureType,m),this.checkError()}attachFramebuffer(p,s,t){const l=this.gl;l.bindTexture(l.TEXTURE_2D,p),l.bindFramebuffer(l.FRAMEBUFFER,this.framebuffer),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,p,0),this.checkError(),l.viewport(0,0,s,t),l.scissor(0,0,s,t)}readTexture(p,s,t,l,u,g){const m=this.gl;g||(g=1),this.frameBufferBound||this.attachFramebuffer(p,s,t);const _=this.getEncoder(u,g),b=_.allocate(s*t);return m.bindTexture(m.TEXTURE_2D,p),m.framebufferTexture2D(m.FRAMEBUFFER,m.COLOR_ATTACHMENT0,m.TEXTURE_2D,p,0),m.readPixels(0,0,s,t,m.RGBA,_.textureType,b),this.checkError(),_.decode(b,l)}isFramebufferReady(){return!0}getActiveTexture(){const p=this.gl;return"TEXTURE"+(p.getParameter(this.gl.ACTIVE_TEXTURE)-p.TEXTURE0)}getTextureBinding(){return this.gl.getParameter(this.gl.TEXTURE_BINDING_2D)}getFramebufferBinding(){return this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING)}setVertexAttributes(p,s){const t=this.gl;t.vertexAttribPointer(p,3,t.FLOAT,!1,20,0),t.enableVertexAttribArray(p),s!==-1&&(t.vertexAttribPointer(s,2,t.FLOAT,!1,20,12),t.enableVertexAttribArray(s)),this.checkError()}createProgram(p,s){const t=this.gl,l=t.createProgram();return t.attachShader(l,p),t.attachShader(l,s),t.linkProgram(l),l}compileShader(p,s){const t=this.gl,l=t.createShader(s);if(!l)throw new Error(`createShader() returned null with type ${s}`);if(t.shaderSource(l,p),t.compileShader(l),t.getShaderParameter(l,t.COMPILE_STATUS)===!1)throw new Error(`Failed to compile shader: ${t.getShaderInfoLog(l)}
Shader source:
${p}`);return l}deleteShader(p){this.gl.deleteShader(p)}bindTextureToUniform(p,s,t){const l=this.gl;l.activeTexture(l.TEXTURE0+s),this.checkError(),l.bindTexture(l.TEXTURE_2D,p),this.checkError(),l.uniform1i(t,s),this.checkError()}draw(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.checkError()}checkError(){if(a.env.debug){const p=this.gl,s=p.getError();let t="";switch(s){case p.NO_ERROR:return;case p.INVALID_ENUM:t="INVALID_ENUM";break;case p.INVALID_VALUE:t="INVALID_VALUE";break;case p.INVALID_OPERATION:t="INVALID_OPERATION";break;case p.INVALID_FRAMEBUFFER_OPERATION:t="INVALID_FRAMEBUFFER_OPERATION";break;case p.OUT_OF_MEMORY:t="OUT_OF_MEMORY";break;case p.CONTEXT_LOST_WEBGL:t="CONTEXT_LOST_WEBGL";break;default:t=`Unknown WebGL Error: ${s.toString(16)}`}throw new Error(t)}}deleteTexture(p){this.gl.deleteTexture(p)}deleteProgram(p){this.gl.deleteProgram(p)}getEncoder(p,s,t=0){if(this.version===2)return new d.RedFloat32DataEncoder(this.gl,s);switch(p){case"float":return t===1||this.isRenderFloat32Supported?new d.RGBAFloatDataEncoder(this.gl,s):new d.RGBAFloatDataEncoder(this.gl,s,this.textureHalfFloatExtension.HALF_FLOAT_OES);case"int":throw new Error("not implemented");case"byte":return new d.Uint8DataEncoder(this.gl,s);default:throw new Error(`Invalid dataType: ${p}`)}}clearActiveTextures(){const p=this.gl;for(let s=0;s<this.maxTextureImageUnits;++s)p.activeTexture(p.TEXTURE0+s),p.bindTexture(p.TEXTURE_2D,null)}dispose(){if(this.disposed)return;const p=this.gl;p.bindFramebuffer(p.FRAMEBUFFER,null),p.deleteFramebuffer(this.framebuffer),p.bindBuffer(p.ARRAY_BUFFER,null),p.deleteBuffer(this.vertexbuffer),p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,null),p.finish(),this.disposed=!0}createDefaultGeometry(){return new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0])}createVertexbuffer(){const p=this.gl,s=p.createBuffer();if(!s)throw new Error("createBuffer() returned null");const t=this.createDefaultGeometry();return p.bindBuffer(p.ARRAY_BUFFER,s),p.bufferData(p.ARRAY_BUFFER,t,p.STATIC_DRAW),this.checkError(),s}createFramebuffer(){const p=this.gl.createFramebuffer();if(!p)throw new Error("createFramebuffer returned null");return p}queryVitalParameters(){const p=this.gl;if(this.isFloatTextureAttachableToFrameBuffer=this.checkFloatTextureAttachableToFrameBuffer(),this.isRenderFloat32Supported=this.checkRenderFloat32(),this.isFloat32DownloadSupported=this.checkFloat32Download(),this.version===1&&!this.textureHalfFloatExtension&&!this.isRenderFloat32Supported)throw new Error("both float32 and float16 TextureType are not supported");this.isBlendSupported=!this.isRenderFloat32Supported||this.checkFloat32Blend(),this.maxTextureSize=p.getParameter(p.MAX_TEXTURE_SIZE),this.maxTextureImageUnits=p.getParameter(p.MAX_TEXTURE_IMAGE_UNITS),this.version}getExtensions(){this.version===2?(this.colorBufferFloatExtension=this.gl.getExtension("EXT_color_buffer_float"),this.disjointTimerQueryWebgl2Extension=this.gl.getExtension("EXT_disjoint_timer_query_webgl2")):(this.textureFloatExtension=this.gl.getExtension("OES_texture_float"),this.textureHalfFloatExtension=this.gl.getExtension("OES_texture_half_float"))}checkFloatTextureAttachableToFrameBuffer(){const p=this.gl,s=p.createTexture();p.bindTexture(p.TEXTURE_2D,s);const t=this.version===2?p.RGBA32F:p.RGBA;p.texImage2D(p.TEXTURE_2D,0,t,1,1,0,p.RGBA,p.FLOAT,null);const l=p.createFramebuffer();p.bindFramebuffer(p.FRAMEBUFFER,l),p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,s,0);const u=p.checkFramebufferStatus(p.FRAMEBUFFER)===p.FRAMEBUFFER_COMPLETE;return p.bindTexture(p.TEXTURE_2D,null),p.bindFramebuffer(p.FRAMEBUFFER,null),p.deleteTexture(s),p.deleteFramebuffer(l),u}checkRenderFloat32(){if(this.version===2){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension)return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Download(){if(this.version===2){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension||!this.gl.getExtension("WEBGL_color_buffer_float"))return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Blend(){const p=this.gl;let s,t,l,u,g;try{s=p.createTexture(),t=p.createFramebuffer(),p.bindTexture(p.TEXTURE_2D,s);const m=this.version===2?p.RGBA32F:p.RGBA;return p.texImage2D(p.TEXTURE_2D,0,m,1,1,0,p.RGBA,p.FLOAT,null),p.bindFramebuffer(p.FRAMEBUFFER,t),p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,s,0),p.enable(p.BLEND),l=p.createShader(p.VERTEX_SHADER),!!l&&(p.shaderSource(l,"void main(){}"),p.compileShader(l),u=p.createShader(p.FRAGMENT_SHADER),!!u&&(p.shaderSource(u,"precision highp float;void main(){gl_FragColor=vec4(0.5);}"),p.compileShader(u),g=p.createProgram(),!!g&&(p.attachShader(g,l),p.attachShader(g,u),p.linkProgram(g),p.useProgram(g),p.drawArrays(p.POINTS,0,1),p.getError()===p.NO_ERROR)))}finally{p.disable(p.BLEND),g&&p.deleteProgram(g),l&&p.deleteShader(l),u&&p.deleteShader(u),t&&(p.bindFramebuffer(p.FRAMEBUFFER,null),p.deleteFramebuffer(t)),s&&(p.bindTexture(p.TEXTURE_2D,null),p.deleteTexture(s))}}beginTimer(){if(this.version===2&&this.disjointTimerQueryWebgl2Extension){const p=this.gl,s=this.disjointTimerQueryWebgl2Extension,t=p.createQuery();return p.beginQuery(s.TIME_ELAPSED_EXT,t),t}throw new Error("WebGL1 profiling currently not supported.")}endTimer(){if(this.version!==2||!this.disjointTimerQueryWebgl2Extension)throw new Error("WebGL1 profiling currently not supported");{const p=this.gl,s=this.disjointTimerQueryWebgl2Extension;p.endQuery(s.TIME_ELAPSED_EXT)}}isTimerResultAvailable(p){let s=!1,t=!1;if(this.version!==2||!this.disjointTimerQueryWebgl2Extension)throw new Error("WebGL1 profiling currently not supported");{const l=this.gl,u=this.disjointTimerQueryWebgl2Extension;s=l.getQueryParameter(p,l.QUERY_RESULT_AVAILABLE),t=l.getParameter(u.GPU_DISJOINT_EXT)}return s&&!t}getTimerResult(p){let s=0;if(this.version!==2)throw new Error("WebGL1 profiling currently not supported");{const t=this.gl;s=t.getQueryParameter(p,t.QUERY_RESULT),t.deleteQuery(p)}return s/1e6}async waitForQueryAndGetTime(p){return await(0,f.repeatedTry)(()=>this.isTimerResultAvailable(p)),this.getTimerResult(p)}async createAndWaitForFence(){const p=this.createFence(this.gl);return this.pollFence(p)}createFence(p){let s;const t=p,l=t.fenceSync(t.SYNC_GPU_COMMANDS_COMPLETE,0);return p.flush(),s=l===null?()=>!0:()=>{const u=t.clientWaitSync(l,0,0);return u===t.ALREADY_SIGNALED||u===t.CONDITION_SATISFIED},{query:l,isFencePassed:s}}async pollFence(p){return new Promise(s=>{this.addItemToPoll(()=>p.isFencePassed(),()=>s())})}pollItems(){const p=h(this.itemsToPoll.map(s=>s.isDoneFn));for(let s=0;s<=p;++s){const{resolveFn:t}=this.itemsToPoll[s];t()}this.itemsToPoll=this.itemsToPoll.slice(p+1)}async addItemToPoll(p,s){this.itemsToPoll.push({isDoneFn:p,resolveFn:s}),this.itemsToPoll.length>1||await(0,f.repeatedTry)(()=>(this.pollItems(),this.itemsToPoll.length===0))}}},6496:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ExecutionPlan=void 0;const r=n(1315);class i{constructor(a,d){this.op=a,this.node=d}}e.ExecutionPlan=class{constructor(o,a,d){this.graph=o,this.profiler=d,this.initialize(a)}initialize(o){this.profiler.event("session","ExecutionPlan.initialize",()=>{const a=this.graph.getNodes();if(a.length!==o.length)throw new Error("The size of nodes and OPs do not match.");this._ops=o.map((d,f)=>new i(d,a[f])),this.reset(),this._starter=[],this._ops.forEach((d,f)=>{let h=!0;for(const p of d.node.inputs)if(!this._values[p]&&this.graph.getInputIndices().indexOf(p)===-1){h=!1;break}h&&this._starter.push(f)})})}reset(){this._values=this.graph.getValues().map(o=>o.tensor)}async execute(o,a){return this.profiler.event("session","ExecutionPlan.execute",async()=>{this.reset();const d=o.createInferenceHandler(),f=this.graph.getInputIndices();if(a.length!==f.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${a.length} expected: ${f.length}`);a.forEach((u,g)=>{const m=f[g];this._values[m]=u});const h=this._starter.slice(0),p=this.graph.getValues(),s=this.graph.getNodes();let t=0;for(;t<h.length;){const u=h[t++],g=this._ops[u],m=g.node.inputs.map(v=>this._values[v]);if(m.indexOf(void 0)!==-1)throw new Error(`unresolved input detected: op: ${g.node}`);const _=m;r.Logger.verbose("ExecPlan",`Runing op:${g.node.name} (${_.map((v,T)=>`'${g.node.inputs[T]}': ${v.type}[${v.dims.join(",")}]`).join(", ")})`);const b=await this.profiler.event("node",g.node.name,async()=>g.op.impl(d,_,g.op.context));if(b.length!==g.node.outputs.length)throw new Error("the size of output does not match model definition.");b.forEach((v,T)=>{const w=g.node.outputs[T];if(this._values[w])throw new Error(`output [${w}] already has value: op:${g.node.name}`);this._values[w]=v});const y=new Set;b.forEach((v,T)=>{const w=g.node.outputs[T];for(const S of p[w].to){const x=s[S];let P=!0;for(const I of x.inputs)if(!this._values[I]){P=!1;break}P&&y.add(S)}}),h.push(...y)}const l=[];for(let u=0;u<this.graph.getOutputIndices().length;u++){const g=this.graph.getOutputIndices()[u],m=this._values[g];if(m===void 0)throw new Error(`required output [${g}] does not have value`);g===0?await m.getData():m.data,l.push(m)}return r.Logger.verbose("ExecPlan","disposing of inferenceHandler"),d.dispose(),l})}}},4662:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Graph=void 0;const r=n(6874),i=n(5127),o=n(2446),a=n(9240),d=n(7273);var f=i.onnxruntime.experimental.fbs;e.Graph={from:(t,l)=>new s(t,l)};class h{constructor(l){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,l&&(this.type=d.ProtoUtil.tensorValueTypeFromProto(l.type.tensorType))}get from(){return this._from}get to(){return this._to}}class p{constructor(l,u){l instanceof o.onnx.NodeProto?(this.name=l.name,this.opType=l.opType,this.attributes=new r.Attribute(l.attribute)):l instanceof f.Node&&(this.name=u??l.name(),this.opType=l.opType(),this.attributes=new r.Attribute(d.ProtoUtil.tensorAttributesFromORTFormat(l))),this.inputs=[],this.outputs=[],this.executeNode=!0}}class s{constructor(l,u){if(!l)throw new TypeError("graph is empty");this.buildGraph(l),this.transformGraph(u),this.checkIsAcyclic()}getInputIndices(){return this._allInputIndices}getInputNames(){return this._allInputNames}getOutputIndices(){return this._allOutputIndices}getOutputNames(){return this._allOutputNames}getValues(){return this._allData}getNodes(){return this._nodes}buildGraph(l){if(l instanceof o.onnx.GraphProto)this.buildGraphFromOnnxFormat(l);else{if(!(l instanceof f.Graph))throw new TypeError("Graph type is not supported.");this.buildGraphFromOrtFormat(l)}}buildGraphFromOnnxFormat(l){const u=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];const g=new Map;if(!l.input)throw new Error("missing information in graph: input");const m=[];for(const _ of l.input){if(u.has(_.name))throw new Error(`duplicated input name: ${_.name}`);const b=this._allData.push(new h(_))-1;u.set(_.name,b),m.push(_.name)}if(!l.initializer)throw new Error("missing information in graph: initializer");for(const _ of l.initializer){let b=u.get(_.name);if(b===void 0){const y=new h;y.type={shape:{dims:d.ProtoUtil.tensorDimsFromProto(_.dims)},tensorType:d.ProtoUtil.tensorDataTypeFromProto(_.dataType)},b=this._allData.push(y)-1,u.set(_.name,b)}this._allData[b]._from=-1,this._allData[b].tensor=a.Tensor.fromProto(_)}for(let _=0;_<this._allData.length;_++)this._allData[_].tensor||(this._allInputIndices.push(_),this._allInputNames.push(m[_]));if(!l.output)throw new Error("missing information in graph: output");for(const _ of l.output){if(u.has(_.name))throw new Error(`duplicated output name: ${_.name}`);const b=this._allData.push(new h(_))-1;u.set(_.name,b),this._allOutputIndices.push(b),this._allOutputNames.push(_.name)}if(!l.node)throw new Error("missing information in graph: node");for(const _ of l.node){if(!_.name)for(let y=0;;y++){const v=`unnamed_${_.opType}_${y}`;if(!g.has(v)){_.name=v;break}}if(g.has(_.name))throw new Error(`duplicated node name: ${_.name}`);const b=this._nodes.push(new p(_))-1;g.set(_.name,b)}for(let _=0;_<this._nodes.length;_++){const b=this._nodes[_],y=l.node[_];if(!y.output)throw new Error(`missing output for node: ${y.name}`);for(const v of y.output){let T=u.get(v);if(T===void 0&&(T=this._allData.push(new h)-1,u.set(v,T)),b.outputs.push(T),this._allData[T]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${T}`);if(this._allData[T]._from=_,y.opType==="Constant"){if(!y.attribute||y.attribute.length!==1||!y.attribute[0].t)throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(!y.output||y.output.length!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");b.outputs.pop(),b.executeNode=!1,this._allData[T]._from=-1,this._allData[T].tensor=a.Tensor.fromProto(y.attribute[0].t)}}}for(let _=0;_<this._nodes.length;_++){const b=this._nodes[_],y=l.node[_];if(!y.input)throw new Error(`missing input for node: ${y.name}`);for(const v of y.input){const T=u.get(v);if(T===void 0){if(v===""&&(y.input.length===3||y.input.length===4)&&y.opType==="Resize")continue;throw new Error(`unrecognized input '${v}' for node: ${y.name}`)}b.inputs.push(T),this._allData[T]._to.push(_)}}return!0}buildGraphFromOrtFormat(l){var u,g,m;const _=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];const b=new Map,y=[];for(let v=0;v<l.inputsLength();v++){const T=l.inputs(v);if(_.has(T))throw new Error(`duplicated input name: ${T}`);for(let w=0;w<l.nodeArgsLength();w++)if(((u=l.nodeArgs(w))===null||u===void 0?void 0:u.name())===T){const S=new h;if(((m=(g=l.nodeArgs(w))===null||g===void 0?void 0:g.type())===null||m===void 0?void 0:m.valueType())!==f.TypeInfoValue.tensor_type)throw new Error("Unexpected value type for the nodeArg.");const x=l.nodeArgs(w).type().value(new f.TensorTypeAndShape),P=d.ProtoUtil.tensorDataTypeFromProto(x.elemType()),I=x.shape(),N=[];for(let E=0;E<I.dimLength();E++)N.push(d.LongUtil.longToNumber(I.dim(E).value().dimValue()));S.type={shape:{dims:N},tensorType:P};const L=this._allData.push(S)-1;_.set(T,L),y.push(T)}}for(let v=0;v<l.initializersLength();v++){const T=l.initializers(v);let w=_.get(T.name());if(w===void 0){const S=new h,x=d.ProtoUtil.tensorDimsFromORTFormat(T),P=d.ProtoUtil.tensorDataTypeFromProto(T.dataType());S.type={shape:{dims:x},tensorType:P},w=this._allData.push(S)-1,_.set(T.name(),w)}this._allData[w]._from=-1,this._allData[w].tensor=a.Tensor.fromOrtTensor(T)}for(let v=0;v<this._allData.length;v++)this._allData[v].tensor||(this._allInputIndices.push(v),this._allInputNames.push(y[v]));for(let v=0;v<l.outputsLength();v++){const T=l.outputs(v);if(_.has(T))throw new Error(`duplicated output name: ${T}`);const w=this._allData.push(new h)-1;_.set(T,w),this._allOutputIndices.push(w),this._allOutputNames.push(T)}if(!l.nodes)throw new Error("missing information in graph: node");for(let v=0;v<l.nodesLength();v++){const T=l.nodes(v);let w=T.name();if(!w)for(let x=0;w=`unnamed_${T.opType()}_${x}`,b.has(w);x++);if(b.has(w))throw new Error(`duplicated node name: ${w}`);const S=this._nodes.push(new p(T,w))-1;b.set(w,S)}for(let v=0;v<this._nodes.length;v++){const T=this._nodes[v],w=l.nodes(v);if(w==null)throw new Error(`No node exists at index ${v}`);if((w==null?void 0:w.outputsLength())===0)throw new Error(`missing output for node: ${w.name}`);for(let S=0;S<(w==null?void 0:w.outputsLength());S++){const x=w==null?void 0:w.outputs(S);let P=_.get(x);if(P===void 0&&(P=this._allData.push(new h)-1,_.set(x,P)),T.outputs.push(P),this._allData[P]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${P}`);if(this._allData[P]._from=v,w.opType()==="Constant"){if(w.attributesLength()!==1||!w.attributes(0).t())throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(w.outputsLength()!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");T.outputs.pop(),T.executeNode=!1,this._allData[P]._from=-1,this._allData[P].tensor=a.Tensor.fromOrtTensor(w.attributes(0).t())}}}for(let v=0;v<this._nodes.length;v++){const T=this._nodes[v],w=l.nodes(v);if(w.inputsLength()===0)throw new Error(`missing input for node: ${w.name}`);for(let S=0;S<w.inputsLength();S++){const x=w.inputs(S),P=_.get(x);if(P===void 0)throw new Error(`unrecognized input '${x}' for node: ${w.name()}`);T.inputs.push(P),this._allData[P]._to.push(v)}}}checkIsAcyclic(){const l=new Set;this._allInputIndices.forEach(m=>{this._allData[m]._to.forEach(_=>{l.add(_)})});const u=Array.from(l),g=new Array(this._nodes.length).fill("white");for(;u.length>0;){const m=u.pop();g[m]==="gray"?g[m]="black":(u.push(m),g[m]="gray",this._nodes[m].outputs.forEach(_=>{const b=this._allData[_];if(b.tensor!==void 0)throw new Error("node outputs should not be initialized");if(b._from!==m)throw new Error("from property of the Value object doesn't match index of Node being processed");b._to.forEach(y=>{if(g[y]==="gray")throw new Error("model graph is cyclic");g[y]==="white"&&u.push(y)})}))}}transformGraph(l){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),l&&l.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let l=0;const u=new Array(this._nodes.length,0);let g=0;for(let m=0;m<this._nodes.length;m++)u[m]=g,this._nodes[m].executeNode?(g!==m&&(this._nodes[g]=this._nodes[m]),g++):this._nodes[m].outputs.forEach(_=>{this._allData[_]._from=-2});this._nodes.splice(g,this._nodes.length-g);for(let m=0;m<this._allData.length;m++){const _=this._allData[m];_._from!==void 0&&_._from!==-1&&_._from!==-2&&(_._from=u[_._from]);for(let b=0;b<_._to.length;b++){if(!(_._to[b]>=0))throw new Error("Trying to update a removed node");_._to[b]=u[_._to[b]]}}l=0;for(let m=0;m<this._allData.length;m++)if(this._allData[m].from!==-2||this._allOutputIndices.indexOf(m+l)!==-1){if(l>0){let _=-1;this._allData[m].from!==void 0&&this._allData[m].from!==-1?(_=this._nodes[this._allData[m].from].outputs.indexOf(m+l),_!==-1&&(this._nodes[this._allData[m].from].outputs[_]=m)):(_=this._allInputIndices.indexOf(m+l),_!==-1&&(this._allInputIndices[_]=m)),this._allData[m].to.forEach(b=>{_=this._nodes[b].inputs.indexOf(m+l),_!==-1&&(this._nodes[b].inputs[_]=m)}),this._allData[m].to.length===0&&(_=this._allOutputIndices.indexOf(m+l),_!==-1&&(this._allOutputIndices[_]=m))}}else l++,this._allData.splice(m,1),m--}deleteNode(l){const u=this._nodes[l];if(u.outputs.length>1){for(let y=1;y<u.outputs.length;y++)if(this._allData[u.outputs[y]].to.length>0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ")}u.executeNode=!1;const g=u.inputs[0],m=u.outputs[0],_=this._allData[m].to;for(let y=0;y<u.inputs.length;y++){const v=this._allData[u.inputs[y]].to.indexOf(l);if(v===-1)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[u.inputs[y]].to.splice(v,1)}this._allData[m]._to=[];const b=this._allOutputIndices.indexOf(m);if(b!==-1&&(this._allOutputIndices[b]=g),_&&_.length>0)for(const y of _){const v=this._nodes[y].inputs.indexOf(m);if(v===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[y].inputs[v]=g,this._allData[g].to.push(y)}}removeAllDropoutNodes(){let l=0;for(const u of this._nodes){if(u.opType==="Dropout"){if(u.inputs.length!==1)throw new Error("Dropout nodes should only contain one input. ");if(u.outputs.length!==1&&u.outputs.length!==2)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(u.outputs.length===2&&this._allData[u.outputs[1]]._to.length!==0)throw new Error("Dropout nodes's second output should not be referenced by other nodes");this.deleteNode(l)}l++}}removeAllIdentityNodes(){let l=0;for(const u of this._nodes)u.opType==="Identity"&&this.deleteNode(l),l++}isActivation(l){switch(l.opType){case"Relu":case"Sigmoid":case"Clip":return!0;default:return!1}}fuseConvActivationNodes(){for(const l of this._nodes)if(l.opType==="Conv"){const u=this._allData[l.outputs[0]]._to;if(u.length===1&&this.isActivation(this._nodes[u[0]])){const g=this._nodes[u[0]];if(g.opType==="Clip")if(g.inputs.length===1)try{l.attributes.set("activation_params","floats",[g.attributes.getFloat("min"),g.attributes.getFloat("max")])}catch{l.attributes.set("activation_params","floats",[d.MIN_CLIP,d.MAX_CLIP])}else{if(!(g.inputs.length>=3&&this._allData[g.inputs[1]].tensor!==void 0&&this._allData[g.inputs[2]].tensor!==void 0))continue;l.attributes.set("activation_params","floats",[this._allData[g.inputs[1]].tensor.floatData[0],this._allData[g.inputs[2]].tensor.floatData[0]])}l.attributes.set("activation","string",g.opType),this.deleteNode(u[0])}}}}},1315:(c,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.now=e.Profiler=e.Logger=void 0;const n={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},r={none:new class{log(p,s,t){}},console:new class{log(p,s,t){console.log(`${this.color(p)} ${t?"\x1B[35m"+t+"\x1B[0m ":""}${s}`)}color(p){switch(p){case"verbose":return"\x1B[34;40mv\x1B[0m";case"info":return"\x1B[32mi\x1B[0m";case"warning":return"\x1B[30;43mw\x1B[0m";case"error":return"\x1B[31;40me\x1B[0m";case"fatal":return"\x1B[101mf\x1B[0m";default:throw new Error(`unsupported severity: ${p}`)}}}},i={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1};let o={"":i};function a(p,s,t,l){if(s===void 0)return u=p,{verbose:a.verbose.bind(null,u),info:a.info.bind(null,u),warning:a.warning.bind(null,u),error:a.error.bind(null,u),fatal:a.fatal.bind(null,u)};if(t===void 0)d(p,s);else if(typeof t=="number"&&l===void 0)d(p,s);else if(typeof t=="string"&&l===void 0)d(p,t,0,s);else{if(typeof t!="string"||typeof l!="number")throw new TypeError("input is valid");d(p,t,0,s)}var u}function d(p,s,t,l){const u=o[l||""]||o[""];n[p]<n[u.minimalSeverity]||(u.logDateTime&&(s=`${new Date().toISOString()}|${s}`),u.logSourceLocation,r[u.provider].log(p,s,l))}(function(p){function s(l){o={},t("",l||{})}function t(l,u){if(l==="*")s(u);else{const g=o[l]||i;o[l]={provider:u.provider||g.provider,minimalSeverity:u.minimalSeverity||g.minimalSeverity,logDateTime:u.logDateTime===void 0?g.logDateTime:u.logDateTime,logSourceLocation:u.logSourceLocation===void 0?g.logSourceLocation:u.logSourceLocation}}}p.verbose=function(l,u){p("verbose",l,u)},p.info=function(l,u){p("info",l,u)},p.warning=function(l,u){p("warning",l,u)},p.error=function(l,u){p("error",l,u)},p.fatal=function(l,u){p("fatal",l,u)},p.reset=s,p.set=t,p.setWithEnv=function(l){const u={};l.logLevel&&(u.minimalSeverity=l.logLevel),t("",u)}})(a||(a={})),e.Logger=a;class f{constructor(s,t,l,u,g,m){this.category=s,this.name=t,this.startTime=l,this.endCallback=u,this.timer=g,this.ctx=m}async end(){return this.endCallback(this)}async checkTimer(){if(this.ctx===void 0||this.timer===void 0)throw new Error("No webgl timer found");return this.ctx.endTimer(),this.ctx.waitForQueryAndGetTime(this.timer)}}class h{constructor(s,t,l,u){this.category=s,this.name=t,this.startTime=l,this.endTime=u}}e.Profiler=class{static create(p){return p===void 0?new this:new this(p.maxNumberEvents,p.flushBatchSize,p.flushIntervalInMilliseconds)}constructor(p,s,t){this._started=!1,this._flushPointer=0,this._started=!1,this._maxNumberEvents=p===void 0?1e4:p,this._flushBatchSize=s===void 0?10:s,this._flushIntervalInMilliseconds=t===void 0?5e3:t}start(){this._started=!0,this._timingEvents=[],this._flushTime=(0,e.now)(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(p,s,t,l){const u=this._started?this.begin(p,s,l):void 0;let g=!1;const m=t();if(m&&typeof m.then=="function")return g=!0,new Promise((_,b)=>{m.then(async y=>{u&&await u.end(),_(y)},async y=>{u&&await u.end(),b(y)})});if(!g&&u){const _=u.end();if(_&&typeof _.then=="function")return new Promise((b,y)=>{_.then(()=>{b(m)},v=>{y(v)})})}return m}begin(p,s,t){if(!this._started)throw new Error("profiler is not started yet");if(t===void 0){const l=(0,e.now)();return this.flush(l),new f(p,s,l,u=>this.endSync(u))}{const l=t.beginTimer();return new f(p,s,0,async u=>this.end(u),l,t)}}async end(p){const s=await p.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new h(p.category,p.name,p.startTime,s)),this.flush(s))}endSync(p){const s=(0,e.now)();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new h(p.category,p.name,p.startTime,s)),this.flush(s))}logOneEvent(p){e.Logger.verbose(`Profiler.${p.category}`,`${(p.endTime-p.startTime).toFixed(2)}ms on event '${p.name}' at ${p.endTime.toFixed(2)}`)}flush(p){if(this._timingEvents.length-this._flushPointer>=this._flushBatchSize||p-this._flushTime>=this._flushIntervalInMilliseconds){for(const s=this._flushPointer;this._flushPointer<s+this._flushBatchSize&&this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer]);this._flushTime=(0,e.now)()}}get started(){return this._started}},e.now=typeof performance<"u"&&performance.now?()=>performance.now():Date.now},1745:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Model=void 0;const r=n(5686),i=n(4662),o=n(5127),a=n(2446),d=n(7273);var f=o.onnxruntime.experimental.fbs;e.Model=class{constructor(){}load(h,p,s){if(!s)try{return void this.loadFromOnnxFormat(h,p)}catch(t){if(s!==void 0)throw t}this.loadFromOrtFormat(h,p)}loadFromOnnxFormat(h,p){const s=a.onnx.ModelProto.decode(h);if(d.LongUtil.longToNumber(s.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=s.opsetImport.map(t=>({domain:t.domain,version:d.LongUtil.longToNumber(t.version)})),this._graph=i.Graph.from(s.graph,p)}loadFromOrtFormat(h,p){const s=new r.flatbuffers.ByteBuffer(h),t=f.InferenceSession.getRootAsInferenceSession(s).model();if(d.LongUtil.longToNumber(t.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let l=0;l<t.opsetImportLength();l++){const u=t.opsetImport(l);this._opsets.push({domain:u==null?void 0:u.domain(),version:d.LongUtil.longToNumber(u.version())})}this._graph=i.Graph.from(t.graph(),p)}get graph(){return this._graph}get opsets(){return this._opsets}}},6145:(c,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.FLOAT_TYPES=e.INT_TYPES=e.NUMBER_TYPES=void 0,e.NUMBER_TYPES=["float32","float64","int32","int16","int8","uint16","uint32","uint8"],e.INT_TYPES=["int32","int16","int8","uint16","uint32","uint8"],e.FLOAT_TYPES=["float32","float64"]},5881:(c,e)=>{function n(r,i){if(i.endsWith("+")){const o=Number.parseInt(i.substring(0,i.length-1),10);return!isNaN(o)&&o<=r}if(i.split("-").length===2){const o=i.split("-"),a=Number.parseInt(o[0],10),d=Number.parseInt(o[1],10);return!isNaN(a)&&!isNaN(d)&&a<=r&&r<=d}return Number.parseInt(i,10)===r}Object.defineProperty(e,"__esModule",{value:!0}),e.resolveOperator=void 0,e.resolveOperator=function(r,i,o){for(const a of o){const d=a[0],f=a[1],h=a[2],p=a[3],s=a[4];if(r.opType===d){for(const t of i)if((t.domain===f||t.domain==="ai.onnx"&&f==="")&&n(t.version,h))return{opImpl:p,opInit:s}}}throw new TypeError(`cannot resolve operator '${r.opType}' with opsets: ${i.map(a=>`${a.domain||"ai.onnx"} v${a.version}`).join(", ")}`)}},5127:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.onnxruntime=void 0;const r=n(5686);var i,o;i=e.onnxruntime||(e.onnxruntime={}),function(a){(function(d){d[d.UNDEFINED=0]="UNDEFINED",d[d.FLOAT=1]="FLOAT",d[d.INT=2]="INT",d[d.STRING=3]="STRING",d[d.TENSOR=4]="TENSOR",d[d.GRAPH=5]="GRAPH",d[d.FLOATS=6]="FLOATS",d[d.INTS=7]="INTS",d[d.STRINGS=8]="STRINGS",d[d.TENSORS=9]="TENSORS",d[d.GRAPHS=10]="GRAPHS",d[d.SPARSE_TENSOR=11]="SPARSE_TENSOR",d[d.SPARSE_TENSORS=12]="SPARSE_TENSORS"})(a.AttributeType||(a.AttributeType={}))}((o=i.experimental||(i.experimental={})).fbs||(o.fbs={})),function(a){(function(d){(function(f){(function(h){h[h.UNKNOWN=0]="UNKNOWN",h[h.VALUE=1]="VALUE",h[h.PARAM=2]="PARAM"})(f.DimensionValueType||(f.DimensionValueType={}))})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){(function(h){h[h.UNDEFINED=0]="UNDEFINED",h[h.FLOAT=1]="FLOAT",h[h.UINT8=2]="UINT8",h[h.INT8=3]="INT8",h[h.UINT16=4]="UINT16",h[h.INT16=5]="INT16",h[h.INT32=6]="INT32",h[h.INT64=7]="INT64",h[h.STRING=8]="STRING",h[h.BOOL=9]="BOOL",h[h.FLOAT16=10]="FLOAT16",h[h.DOUBLE=11]="DOUBLE",h[h.UINT32=12]="UINT32",h[h.UINT64=13]="UINT64",h[h.COMPLEX64=14]="COMPLEX64",h[h.COMPLEX128=15]="COMPLEX128",h[h.BFLOAT16=16]="BFLOAT16",h[h.FLOAT8E4M3FN=17]="FLOAT8E4M3FN",h[h.FLOAT8E4M3FNUZ=18]="FLOAT8E4M3FNUZ",h[h.FLOAT8E5M2=19]="FLOAT8E5M2",h[h.FLOAT8E5M2FNUZ=20]="FLOAT8E5M2FNUZ"})(f.TensorDataType||(f.TensorDataType={}))})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){(function(h){h[h.Primitive=0]="Primitive",h[h.Fused=1]="Fused"})(f.NodeType||(f.NodeType={}))})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){(function(h){h[h.NONE=0]="NONE",h[h.tensor_type=1]="tensor_type",h[h.sequence_type=2]="sequence_type",h[h.map_type=3]="map_type"})(f.TypeInfoValue||(f.TypeInfoValue={}))})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsShape(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsShape(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}dim(s,t){let l=this.bb.__offset(this.bb_pos,4);return l?(t||new a.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+4*s),this.bb):null}dimLength(){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__vector_len(this.bb_pos+s):0}static startShape(s){s.startObject(1)}static addDim(s,t){s.addFieldOffset(0,t,0)}static createDimVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addOffset(t[l]);return s.endVector()}static startDimVector(s,t){s.startVector(4,t,4)}static endShape(s){return s.endObject()}static createShape(s,t){return h.startShape(s),h.addDim(s,t),h.endShape(s)}}f.Shape=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsDimension(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsDimension(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}value(s){let t=this.bb.__offset(this.bb_pos,4);return t?(s||new a.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}denotation(s){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,s):null}static startDimension(s){s.startObject(2)}static addValue(s,t){s.addFieldOffset(0,t,0)}static addDenotation(s,t){s.addFieldOffset(1,t,0)}static endDimension(s){return s.endObject()}static createDimension(s,t,l){return h.startDimension(s),h.addValue(s,t),h.addDenotation(s,l),h.endDimension(s)}}f.Dimension=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsDimensionValue(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsDimensionValue(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}dimType(){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.readInt8(this.bb_pos+s):a.experimental.fbs.DimensionValueType.UNKNOWN}dimValue(){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.readInt64(this.bb_pos+s):this.bb.createLong(0,0)}dimParam(s){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__string(this.bb_pos+t,s):null}static startDimensionValue(s){s.startObject(3)}static addDimType(s,t){s.addFieldInt8(0,t,a.experimental.fbs.DimensionValueType.UNKNOWN)}static addDimValue(s,t){s.addFieldInt64(1,t,s.createLong(0,0))}static addDimParam(s,t){s.addFieldOffset(2,t,0)}static endDimensionValue(s){return s.endObject()}static createDimensionValue(s,t,l,u){return h.startDimensionValue(s),h.addDimType(s,t),h.addDimValue(s,l),h.addDimParam(s,u),h.endDimensionValue(s)}}f.DimensionValue=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsTensorTypeAndShape(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsTensorTypeAndShape(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}elemType(){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.readInt32(this.bb_pos+s):a.experimental.fbs.TensorDataType.UNDEFINED}shape(s){let t=this.bb.__offset(this.bb_pos,6);return t?(s||new a.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}static startTensorTypeAndShape(s){s.startObject(2)}static addElemType(s,t){s.addFieldInt32(0,t,a.experimental.fbs.TensorDataType.UNDEFINED)}static addShape(s,t){s.addFieldOffset(1,t,0)}static endTensorTypeAndShape(s){return s.endObject()}static createTensorTypeAndShape(s,t,l){return h.startTensorTypeAndShape(s),h.addElemType(s,t),h.addShape(s,l),h.endTensorTypeAndShape(s)}}f.TensorTypeAndShape=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsMapType(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsMapType(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}keyType(){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.readInt32(this.bb_pos+s):a.experimental.fbs.TensorDataType.UNDEFINED}valueType(s){let t=this.bb.__offset(this.bb_pos,6);return t?(s||new a.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}static startMapType(s){s.startObject(2)}static addKeyType(s,t){s.addFieldInt32(0,t,a.experimental.fbs.TensorDataType.UNDEFINED)}static addValueType(s,t){s.addFieldOffset(1,t,0)}static endMapType(s){return s.endObject()}static createMapType(s,t,l){return h.startMapType(s),h.addKeyType(s,t),h.addValueType(s,l),h.endMapType(s)}}f.MapType=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsSequenceType(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsSequenceType(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}elemType(s){let t=this.bb.__offset(this.bb_pos,4);return t?(s||new a.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}static startSequenceType(s){s.startObject(1)}static addElemType(s,t){s.addFieldOffset(0,t,0)}static endSequenceType(s){return s.endObject()}static createSequenceType(s,t){return h.startSequenceType(s),h.addElemType(s,t),h.endSequenceType(s)}}f.SequenceType=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(d.fbs||(d.fbs={})).EdgeEnd=class{constructor(){this.bb=null,this.bb_pos=0}__init(f,h){return this.bb_pos=f,this.bb=h,this}nodeIndex(){return this.bb.readUint32(this.bb_pos)}srcArgIndex(){return this.bb.readInt32(this.bb_pos+4)}dstArgIndex(){return this.bb.readInt32(this.bb_pos+8)}static createEdgeEnd(f,h,p,s){return f.prep(4,12),f.writeInt32(s),f.writeInt32(p),f.writeInt32(h),f.offset()}}})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsNodeEdge(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsNodeEdge(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}nodeIndex(){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.readUint32(this.bb_pos+s):0}inputEdges(s,t){let l=this.bb.__offset(this.bb_pos,6);return l?(t||new a.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+l)+12*s,this.bb):null}inputEdgesLength(){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__vector_len(this.bb_pos+s):0}outputEdges(s,t){let l=this.bb.__offset(this.bb_pos,8);return l?(t||new a.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+l)+12*s,this.bb):null}outputEdgesLength(){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__vector_len(this.bb_pos+s):0}static startNodeEdge(s){s.startObject(3)}static addNodeIndex(s,t){s.addFieldInt32(0,t,0)}static addInputEdges(s,t){s.addFieldOffset(1,t,0)}static startInputEdgesVector(s,t){s.startVector(12,t,4)}static addOutputEdges(s,t){s.addFieldOffset(2,t,0)}static startOutputEdgesVector(s,t){s.startVector(12,t,4)}static endNodeEdge(s){return s.endObject()}static createNodeEdge(s,t,l,u){return h.startNodeEdge(s),h.addNodeIndex(s,t),h.addInputEdges(s,l),h.addOutputEdges(s,u),h.endNodeEdge(s)}}f.NodeEdge=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsNode(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsNode(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}name(s){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,s):null}docString(s){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,s):null}domain(s){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__string(this.bb_pos+t,s):null}sinceVersion(){let s=this.bb.__offset(this.bb_pos,10);return s?this.bb.readInt32(this.bb_pos+s):0}index(){let s=this.bb.__offset(this.bb_pos,12);return s?this.bb.readUint32(this.bb_pos+s):0}opType(s){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__string(this.bb_pos+t,s):null}type(){let s=this.bb.__offset(this.bb_pos,16);return s?this.bb.readInt32(this.bb_pos+s):a.experimental.fbs.NodeType.Primitive}executionProviderType(s){let t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__string(this.bb_pos+t,s):null}inputs(s,t){let l=this.bb.__offset(this.bb_pos,20);return l?this.bb.__string(this.bb.__vector(this.bb_pos+l)+4*s,t):null}inputsLength(){let s=this.bb.__offset(this.bb_pos,20);return s?this.bb.__vector_len(this.bb_pos+s):0}outputs(s,t){let l=this.bb.__offset(this.bb_pos,22);return l?this.bb.__string(this.bb.__vector(this.bb_pos+l)+4*s,t):null}outputsLength(){let s=this.bb.__offset(this.bb_pos,22);return s?this.bb.__vector_len(this.bb_pos+s):0}attributes(s,t){let l=this.bb.__offset(this.bb_pos,24);return l?(t||new a.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+4*s),this.bb):null}attributesLength(){let s=this.bb.__offset(this.bb_pos,24);return s?this.bb.__vector_len(this.bb_pos+s):0}inputArgCounts(s){let t=this.bb.__offset(this.bb_pos,26);return t?this.bb.readInt32(this.bb.__vector(this.bb_pos+t)+4*s):0}inputArgCountsLength(){let s=this.bb.__offset(this.bb_pos,26);return s?this.bb.__vector_len(this.bb_pos+s):0}inputArgCountsArray(){let s=this.bb.__offset(this.bb_pos,26);return s?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+s),this.bb.__vector_len(this.bb_pos+s)):null}implicitInputs(s,t){let l=this.bb.__offset(this.bb_pos,28);return l?this.bb.__string(this.bb.__vector(this.bb_pos+l)+4*s,t):null}implicitInputsLength(){let s=this.bb.__offset(this.bb_pos,28);return s?this.bb.__vector_len(this.bb_pos+s):0}static startNode(s){s.startObject(13)}static addName(s,t){s.addFieldOffset(0,t,0)}static addDocString(s,t){s.addFieldOffset(1,t,0)}static addDomain(s,t){s.addFieldOffset(2,t,0)}static addSinceVersion(s,t){s.addFieldInt32(3,t,0)}static addIndex(s,t){s.addFieldInt32(4,t,0)}static addOpType(s,t){s.addFieldOffset(5,t,0)}static addType(s,t){s.addFieldInt32(6,t,a.experimental.fbs.NodeType.Primitive)}static addExecutionProviderType(s,t){s.addFieldOffset(7,t,0)}static addInputs(s,t){s.addFieldOffset(8,t,0)}static createInputsVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addOffset(t[l]);return s.endVector()}static startInputsVector(s,t){s.startVector(4,t,4)}static addOutputs(s,t){s.addFieldOffset(9,t,0)}static createOutputsVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addOffset(t[l]);return s.endVector()}static startOutputsVector(s,t){s.startVector(4,t,4)}static addAttributes(s,t){s.addFieldOffset(10,t,0)}static createAttributesVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addOffset(t[l]);return s.endVector()}static startAttributesVector(s,t){s.startVector(4,t,4)}static addInputArgCounts(s,t){s.addFieldOffset(11,t,0)}static createInputArgCountsVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addInt32(t[l]);return s.endVector()}static startInputArgCountsVector(s,t){s.startVector(4,t,4)}static addImplicitInputs(s,t){s.addFieldOffset(12,t,0)}static createImplicitInputsVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addOffset(t[l]);return s.endVector()}static startImplicitInputsVector(s,t){s.startVector(4,t,4)}static endNode(s){return s.endObject()}static createNode(s,t,l,u,g,m,_,b,y,v,T,w,S,x){return h.startNode(s),h.addName(s,t),h.addDocString(s,l),h.addDomain(s,u),h.addSinceVersion(s,g),h.addIndex(s,m),h.addOpType(s,_),h.addType(s,b),h.addExecutionProviderType(s,y),h.addInputs(s,v),h.addOutputs(s,T),h.addAttributes(s,w),h.addInputArgCounts(s,S),h.addImplicitInputs(s,x),h.endNode(s)}}f.Node=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsValueInfo(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsValueInfo(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}name(s){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,s):null}docString(s){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,s):null}type(s){let t=this.bb.__offset(this.bb_pos,8);return t?(s||new a.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}static startValueInfo(s){s.startObject(3)}static addName(s,t){s.addFieldOffset(0,t,0)}static addDocString(s,t){s.addFieldOffset(1,t,0)}static addType(s,t){s.addFieldOffset(2,t,0)}static endValueInfo(s){return s.endObject()}static createValueInfo(s,t,l,u){return h.startValueInfo(s),h.addName(s,t),h.addDocString(s,l),h.addType(s,u),h.endValueInfo(s)}}f.ValueInfo=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsTypeInfo(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsTypeInfo(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}denotation(s){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,s):null}valueType(){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.readUint8(this.bb_pos+s):a.experimental.fbs.TypeInfoValue.NONE}value(s){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__union(s,this.bb_pos+t):null}static startTypeInfo(s){s.startObject(3)}static addDenotation(s,t){s.addFieldOffset(0,t,0)}static addValueType(s,t){s.addFieldInt8(1,t,a.experimental.fbs.TypeInfoValue.NONE)}static addValue(s,t){s.addFieldOffset(2,t,0)}static endTypeInfo(s){return s.endObject()}static createTypeInfo(s,t,l,u){return h.startTypeInfo(s),h.addDenotation(s,t),h.addValueType(s,l),h.addValue(s,u),h.endTypeInfo(s)}}f.TypeInfo=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsOperatorSetId(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsOperatorSetId(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}domain(s){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,s):null}version(){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.readInt64(this.bb_pos+s):this.bb.createLong(0,0)}static startOperatorSetId(s){s.startObject(2)}static addDomain(s,t){s.addFieldOffset(0,t,0)}static addVersion(s,t){s.addFieldInt64(1,t,s.createLong(0,0))}static endOperatorSetId(s){return s.endObject()}static createOperatorSetId(s,t,l){return h.startOperatorSetId(s),h.addDomain(s,t),h.addVersion(s,l),h.endOperatorSetId(s)}}f.OperatorSetId=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsTensor(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsTensor(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}name(s){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,s):null}docString(s){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,s):null}dims(s){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+8*s):this.bb.createLong(0,0)}dimsLength(){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__vector_len(this.bb_pos+s):0}dataType(){let s=this.bb.__offset(this.bb_pos,10);return s?this.bb.readInt32(this.bb_pos+s):a.experimental.fbs.TensorDataType.UNDEFINED}rawData(s){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readUint8(this.bb.__vector(this.bb_pos+t)+s):0}rawDataLength(){let s=this.bb.__offset(this.bb_pos,12);return s?this.bb.__vector_len(this.bb_pos+s):0}rawDataArray(){let s=this.bb.__offset(this.bb_pos,12);return s?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+s),this.bb.__vector_len(this.bb_pos+s)):null}stringData(s,t){let l=this.bb.__offset(this.bb_pos,14);return l?this.bb.__string(this.bb.__vector(this.bb_pos+l)+4*s,t):null}stringDataLength(){let s=this.bb.__offset(this.bb_pos,14);return s?this.bb.__vector_len(this.bb_pos+s):0}static startTensor(s){s.startObject(6)}static addName(s,t){s.addFieldOffset(0,t,0)}static addDocString(s,t){s.addFieldOffset(1,t,0)}static addDims(s,t){s.addFieldOffset(2,t,0)}static createDimsVector(s,t){s.startVector(8,t.length,8);for(let l=t.length-1;l>=0;l--)s.addInt64(t[l]);return s.endVector()}static startDimsVector(s,t){s.startVector(8,t,8)}static addDataType(s,t){s.addFieldInt32(3,t,a.experimental.fbs.TensorDataType.UNDEFINED)}static addRawData(s,t){s.addFieldOffset(4,t,0)}static createRawDataVector(s,t){s.startVector(1,t.length,1);for(let l=t.length-1;l>=0;l--)s.addInt8(t[l]);return s.endVector()}static startRawDataVector(s,t){s.startVector(1,t,1)}static addStringData(s,t){s.addFieldOffset(5,t,0)}static createStringDataVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addOffset(t[l]);return s.endVector()}static startStringDataVector(s,t){s.startVector(4,t,4)}static endTensor(s){return s.endObject()}static createTensor(s,t,l,u,g,m,_){return h.startTensor(s),h.addName(s,t),h.addDocString(s,l),h.addDims(s,u),h.addDataType(s,g),h.addRawData(s,m),h.addStringData(s,_),h.endTensor(s)}}f.Tensor=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsSparseTensor(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsSparseTensor(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}values(s){let t=this.bb.__offset(this.bb_pos,4);return t?(s||new a.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}indices(s){let t=this.bb.__offset(this.bb_pos,6);return t?(s||new a.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}dims(s){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+8*s):this.bb.createLong(0,0)}dimsLength(){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__vector_len(this.bb_pos+s):0}static startSparseTensor(s){s.startObject(3)}static addValues(s,t){s.addFieldOffset(0,t,0)}static addIndices(s,t){s.addFieldOffset(1,t,0)}static addDims(s,t){s.addFieldOffset(2,t,0)}static createDimsVector(s,t){s.startVector(8,t.length,8);for(let l=t.length-1;l>=0;l--)s.addInt64(t[l]);return s.endVector()}static startDimsVector(s,t){s.startVector(8,t,8)}static endSparseTensor(s){return s.endObject()}static createSparseTensor(s,t,l,u){return h.startSparseTensor(s),h.addValues(s,t),h.addIndices(s,l),h.addDims(s,u),h.endSparseTensor(s)}}f.SparseTensor=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsAttribute(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsAttribute(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}name(s){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,s):null}docString(s){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,s):null}type(){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.readInt32(this.bb_pos+s):a.experimental.fbs.AttributeType.UNDEFINED}f(){let s=this.bb.__offset(this.bb_pos,10);return s?this.bb.readFloat32(this.bb_pos+s):0}i(){let s=this.bb.__offset(this.bb_pos,12);return s?this.bb.readInt64(this.bb_pos+s):this.bb.createLong(0,0)}s(s){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__string(this.bb_pos+t,s):null}t(s){let t=this.bb.__offset(this.bb_pos,16);return t?(s||new a.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}g(s){let t=this.bb.__offset(this.bb_pos,18);return t?(s||new a.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}floats(s){let t=this.bb.__offset(this.bb_pos,20);return t?this.bb.readFloat32(this.bb.__vector(this.bb_pos+t)+4*s):0}floatsLength(){let s=this.bb.__offset(this.bb_pos,20);return s?this.bb.__vector_len(this.bb_pos+s):0}floatsArray(){let s=this.bb.__offset(this.bb_pos,20);return s?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+s),this.bb.__vector_len(this.bb_pos+s)):null}ints(s){let t=this.bb.__offset(this.bb_pos,22);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+8*s):this.bb.createLong(0,0)}intsLength(){let s=this.bb.__offset(this.bb_pos,22);return s?this.bb.__vector_len(this.bb_pos+s):0}strings(s,t){let l=this.bb.__offset(this.bb_pos,24);return l?this.bb.__string(this.bb.__vector(this.bb_pos+l)+4*s,t):null}stringsLength(){let s=this.bb.__offset(this.bb_pos,24);return s?this.bb.__vector_len(this.bb_pos+s):0}tensors(s,t){let l=this.bb.__offset(this.bb_pos,26);return l?(t||new a.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+4*s),this.bb):null}tensorsLength(){let s=this.bb.__offset(this.bb_pos,26);return s?this.bb.__vector_len(this.bb_pos+s):0}graphs(s,t){let l=this.bb.__offset(this.bb_pos,28);return l?(t||new a.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+4*s),this.bb):null}graphsLength(){let s=this.bb.__offset(this.bb_pos,28);return s?this.bb.__vector_len(this.bb_pos+s):0}static startAttribute(s){s.startObject(13)}static addName(s,t){s.addFieldOffset(0,t,0)}static addDocString(s,t){s.addFieldOffset(1,t,0)}static addType(s,t){s.addFieldInt32(2,t,a.experimental.fbs.AttributeType.UNDEFINED)}static addF(s,t){s.addFieldFloat32(3,t,0)}static addI(s,t){s.addFieldInt64(4,t,s.createLong(0,0))}static addS(s,t){s.addFieldOffset(5,t,0)}static addT(s,t){s.addFieldOffset(6,t,0)}static addG(s,t){s.addFieldOffset(7,t,0)}static addFloats(s,t){s.addFieldOffset(8,t,0)}static createFloatsVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addFloat32(t[l]);return s.endVector()}static startFloatsVector(s,t){s.startVector(4,t,4)}static addInts(s,t){s.addFieldOffset(9,t,0)}static createIntsVector(s,t){s.startVector(8,t.length,8);for(let l=t.length-1;l>=0;l--)s.addInt64(t[l]);return s.endVector()}static startIntsVector(s,t){s.startVector(8,t,8)}static addStrings(s,t){s.addFieldOffset(10,t,0)}static createStringsVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addOffset(t[l]);return s.endVector()}static startStringsVector(s,t){s.startVector(4,t,4)}static addTensors(s,t){s.addFieldOffset(11,t,0)}static createTensorsVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addOffset(t[l]);return s.endVector()}static startTensorsVector(s,t){s.startVector(4,t,4)}static addGraphs(s,t){s.addFieldOffset(12,t,0)}static createGraphsVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addOffset(t[l]);return s.endVector()}static startGraphsVector(s,t){s.startVector(4,t,4)}static endAttribute(s){return s.endObject()}static createAttribute(s,t,l,u,g,m,_,b,y,v,T,w,S,x){return h.startAttribute(s),h.addName(s,t),h.addDocString(s,l),h.addType(s,u),h.addF(s,g),h.addI(s,m),h.addS(s,_),h.addT(s,b),h.addG(s,y),h.addFloats(s,v),h.addInts(s,T),h.addStrings(s,w),h.addTensors(s,S),h.addGraphs(s,x),h.endAttribute(s)}}f.Attribute=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsGraph(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsGraph(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}initializers(s,t){let l=this.bb.__offset(this.bb_pos,4);return l?(t||new a.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+4*s),this.bb):null}initializersLength(){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__vector_len(this.bb_pos+s):0}nodeArgs(s,t){let l=this.bb.__offset(this.bb_pos,6);return l?(t||new a.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+4*s),this.bb):null}nodeArgsLength(){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__vector_len(this.bb_pos+s):0}nodes(s,t){let l=this.bb.__offset(this.bb_pos,8);return l?(t||new a.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+4*s),this.bb):null}nodesLength(){let s=this.bb.__offset(this.bb_pos,8);return s?this.bb.__vector_len(this.bb_pos+s):0}maxNodeIndex(){let s=this.bb.__offset(this.bb_pos,10);return s?this.bb.readUint32(this.bb_pos+s):0}nodeEdges(s,t){let l=this.bb.__offset(this.bb_pos,12);return l?(t||new a.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+4*s),this.bb):null}nodeEdgesLength(){let s=this.bb.__offset(this.bb_pos,12);return s?this.bb.__vector_len(this.bb_pos+s):0}inputs(s,t){let l=this.bb.__offset(this.bb_pos,14);return l?this.bb.__string(this.bb.__vector(this.bb_pos+l)+4*s,t):null}inputsLength(){let s=this.bb.__offset(this.bb_pos,14);return s?this.bb.__vector_len(this.bb_pos+s):0}outputs(s,t){let l=this.bb.__offset(this.bb_pos,16);return l?this.bb.__string(this.bb.__vector(this.bb_pos+l)+4*s,t):null}outputsLength(){let s=this.bb.__offset(this.bb_pos,16);return s?this.bb.__vector_len(this.bb_pos+s):0}sparseInitializers(s,t){let l=this.bb.__offset(this.bb_pos,18);return l?(t||new a.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+4*s),this.bb):null}sparseInitializersLength(){let s=this.bb.__offset(this.bb_pos,18);return s?this.bb.__vector_len(this.bb_pos+s):0}static startGraph(s){s.startObject(8)}static addInitializers(s,t){s.addFieldOffset(0,t,0)}static createInitializersVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addOffset(t[l]);return s.endVector()}static startInitializersVector(s,t){s.startVector(4,t,4)}static addNodeArgs(s,t){s.addFieldOffset(1,t,0)}static createNodeArgsVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addOffset(t[l]);return s.endVector()}static startNodeArgsVector(s,t){s.startVector(4,t,4)}static addNodes(s,t){s.addFieldOffset(2,t,0)}static createNodesVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addOffset(t[l]);return s.endVector()}static startNodesVector(s,t){s.startVector(4,t,4)}static addMaxNodeIndex(s,t){s.addFieldInt32(3,t,0)}static addNodeEdges(s,t){s.addFieldOffset(4,t,0)}static createNodeEdgesVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addOffset(t[l]);return s.endVector()}static startNodeEdgesVector(s,t){s.startVector(4,t,4)}static addInputs(s,t){s.addFieldOffset(5,t,0)}static createInputsVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addOffset(t[l]);return s.endVector()}static startInputsVector(s,t){s.startVector(4,t,4)}static addOutputs(s,t){s.addFieldOffset(6,t,0)}static createOutputsVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addOffset(t[l]);return s.endVector()}static startOutputsVector(s,t){s.startVector(4,t,4)}static addSparseInitializers(s,t){s.addFieldOffset(7,t,0)}static createSparseInitializersVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addOffset(t[l]);return s.endVector()}static startSparseInitializersVector(s,t){s.startVector(4,t,4)}static endGraph(s){return s.endObject()}static createGraph(s,t,l,u,g,m,_,b,y){return h.startGraph(s),h.addInitializers(s,t),h.addNodeArgs(s,l),h.addNodes(s,u),h.addMaxNodeIndex(s,g),h.addNodeEdges(s,m),h.addInputs(s,_),h.addOutputs(s,b),h.addSparseInitializers(s,y),h.endGraph(s)}}f.Graph=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsModel(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsModel(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}irVersion(){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.readInt64(this.bb_pos+s):this.bb.createLong(0,0)}opsetImport(s,t){let l=this.bb.__offset(this.bb_pos,6);return l?(t||new a.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+4*s),this.bb):null}opsetImportLength(){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__vector_len(this.bb_pos+s):0}producerName(s){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__string(this.bb_pos+t,s):null}producerVersion(s){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__string(this.bb_pos+t,s):null}domain(s){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__string(this.bb_pos+t,s):null}modelVersion(){let s=this.bb.__offset(this.bb_pos,14);return s?this.bb.readInt64(this.bb_pos+s):this.bb.createLong(0,0)}docString(s){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__string(this.bb_pos+t,s):null}graph(s){let t=this.bb.__offset(this.bb_pos,18);return t?(s||new a.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}graphDocString(s){let t=this.bb.__offset(this.bb_pos,20);return t?this.bb.__string(this.bb_pos+t,s):null}static startModel(s){s.startObject(9)}static addIrVersion(s,t){s.addFieldInt64(0,t,s.createLong(0,0))}static addOpsetImport(s,t){s.addFieldOffset(1,t,0)}static createOpsetImportVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addOffset(t[l]);return s.endVector()}static startOpsetImportVector(s,t){s.startVector(4,t,4)}static addProducerName(s,t){s.addFieldOffset(2,t,0)}static addProducerVersion(s,t){s.addFieldOffset(3,t,0)}static addDomain(s,t){s.addFieldOffset(4,t,0)}static addModelVersion(s,t){s.addFieldInt64(5,t,s.createLong(0,0))}static addDocString(s,t){s.addFieldOffset(6,t,0)}static addGraph(s,t){s.addFieldOffset(7,t,0)}static addGraphDocString(s,t){s.addFieldOffset(8,t,0)}static endModel(s){return s.endObject()}static createModel(s,t,l,u,g,m,_,b,y,v){return h.startModel(s),h.addIrVersion(s,t),h.addOpsetImport(s,l),h.addProducerName(s,u),h.addProducerVersion(s,g),h.addDomain(s,m),h.addModelVersion(s,_),h.addDocString(s,b),h.addGraph(s,y),h.addGraphDocString(s,v),h.endModel(s)}}f.Model=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsKernelCreateInfos(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsKernelCreateInfos(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}nodeIndices(s){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint32(this.bb.__vector(this.bb_pos+t)+4*s):0}nodeIndicesLength(){let s=this.bb.__offset(this.bb_pos,4);return s?this.bb.__vector_len(this.bb_pos+s):0}nodeIndicesArray(){let s=this.bb.__offset(this.bb_pos,4);return s?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+s),this.bb.__vector_len(this.bb_pos+s)):null}kernelDefHashes(s){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint64(this.bb.__vector(this.bb_pos+t)+8*s):this.bb.createLong(0,0)}kernelDefHashesLength(){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__vector_len(this.bb_pos+s):0}static startKernelCreateInfos(s){s.startObject(2)}static addNodeIndices(s,t){s.addFieldOffset(0,t,0)}static createNodeIndicesVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addInt32(t[l]);return s.endVector()}static startNodeIndicesVector(s,t){s.startVector(4,t,4)}static addKernelDefHashes(s,t){s.addFieldOffset(1,t,0)}static createKernelDefHashesVector(s,t){s.startVector(8,t.length,8);for(let l=t.length-1;l>=0;l--)s.addInt64(t[l]);return s.endVector()}static startKernelDefHashesVector(s,t){s.startVector(8,t,8)}static endKernelCreateInfos(s){return s.endObject()}static createKernelCreateInfos(s,t,l){return h.startKernelCreateInfos(s),h.addNodeIndices(s,t),h.addKernelDefHashes(s,l),h.endKernelCreateInfos(s)}}f.KernelCreateInfos=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsSubGraphSessionState(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsSubGraphSessionState(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}graphId(s){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,s):null}sessionState(s){let t=this.bb.__offset(this.bb_pos,6);return t?(s||new a.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}static startSubGraphSessionState(s){s.startObject(2)}static addGraphId(s,t){s.addFieldOffset(0,t,0)}static addSessionState(s,t){s.addFieldOffset(1,t,0)}static endSubGraphSessionState(s){let t=s.endObject();return s.requiredField(t,4),t}static createSubGraphSessionState(s,t,l){return h.startSubGraphSessionState(s),h.addGraphId(s,t),h.addSessionState(s,l),h.endSubGraphSessionState(s)}}f.SubGraphSessionState=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsSessionState(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsSessionState(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}kernels(s){let t=this.bb.__offset(this.bb_pos,4);return t?(s||new a.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}subGraphSessionStates(s,t){let l=this.bb.__offset(this.bb_pos,6);return l?(t||new a.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+l)+4*s),this.bb):null}subGraphSessionStatesLength(){let s=this.bb.__offset(this.bb_pos,6);return s?this.bb.__vector_len(this.bb_pos+s):0}static startSessionState(s){s.startObject(2)}static addKernels(s,t){s.addFieldOffset(0,t,0)}static addSubGraphSessionStates(s,t){s.addFieldOffset(1,t,0)}static createSubGraphSessionStatesVector(s,t){s.startVector(4,t.length,4);for(let l=t.length-1;l>=0;l--)s.addOffset(t[l]);return s.endVector()}static startSubGraphSessionStatesVector(s,t){s.startVector(4,t,4)}static endSessionState(s){return s.endObject()}static createSessionState(s,t,l){return h.startSessionState(s),h.addKernels(s,t),h.addSubGraphSessionStates(s,l),h.endSessionState(s)}}f.SessionState=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(d){(function(f){class h{constructor(){this.bb=null,this.bb_pos=0}__init(s,t){return this.bb_pos=s,this.bb=t,this}static getRootAsInferenceSession(s,t){return(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static getSizePrefixedRootAsInferenceSession(s,t){return s.setPosition(s.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new h).__init(s.readInt32(s.position())+s.position(),s)}static bufferHasIdentifier(s){return s.__has_identifier("ORTM")}ortVersion(s){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,s):null}model(s){let t=this.bb.__offset(this.bb_pos,6);return t?(s||new a.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}sessionState(s){let t=this.bb.__offset(this.bb_pos,8);return t?(s||new a.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}static startInferenceSession(s){s.startObject(3)}static addOrtVersion(s,t){s.addFieldOffset(0,t,0)}static addModel(s,t){s.addFieldOffset(1,t,0)}static addSessionState(s,t){s.addFieldOffset(2,t,0)}static endInferenceSession(s){return s.endObject()}static finishInferenceSessionBuffer(s,t){s.finish(t,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(s,t){s.finish(t,"ORTM",!0)}static createInferenceSession(s,t,l,u){return h.startInferenceSession(s),h.addOrtVersion(s,t),h.addModel(s,l),h.addSessionState(s,u),h.endInferenceSession(s)}}f.InferenceSession=h})(d.fbs||(d.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={}))},1723:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OnnxjsSessionHandler=void 0;const r=n(2235),i=n(9240);e.OnnxjsSessionHandler=class{constructor(o){this.session=o,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(o,a,d){const f=new Map;for(const s in o)if(Object.hasOwnProperty.call(o,s)){const t=o[s];f.set(s,new i.Tensor(t.dims,t.type,void 0,void 0,t.data))}const h=await this.session.run(f),p={};return h.forEach((s,t)=>{p[t]=new r.Tensor(s.type,s.data,s.dims)}),p}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}},6027:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Session=void 0;const r=n(7067),i=n(1296),o=n(1975),a=n(6496),d=n(1315),f=n(1745);e.Session=class{constructor(h={}){this._initialized=!1,this.backendHint=h.backendHint,this.profiler=d.Profiler.create(h.profiler),this.context={profiler:this.profiler,graphInputTypes:[],graphInputDims:[]}}get inputNames(){return this._model.graph.getInputNames()}get outputNames(){return this._model.graph.getOutputNames()}startProfiling(){this.profiler.start()}endProfiling(){this.profiler.stop()}async loadModel(h,p,s){await this.profiler.event("session","Session.loadModel",async()=>{const t=await(0,o.resolveBackend)(this.backendHint);if(this.sessionHandler=t.createSessionHandler(this.context),this._model=new f.Model,typeof h=="string"){const l=h.endsWith(".ort");if(typeof process<"u"&&process.versions&&process.versions.node){const u=await(0,i.promisify)(r.readFile)(h);this.initialize(u,l)}else{const u=await fetch(h),g=await u.arrayBuffer();this.initialize(new Uint8Array(g),l)}}else if(ArrayBuffer.isView(h))this.initialize(h);else{const l=new Uint8Array(h,p||0,s||h.byteLength);this.initialize(l)}})}initialize(h,p){if(this._initialized)throw new Error("already initialized");this.profiler.event("session","Session.initialize",()=>{const s=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(h,s,p),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new a.ExecutionPlan(this._model.graph,this._ops,this.profiler)}),this._initialized=!0}async run(h){if(!this._initialized)throw new Error("session not initialized yet");return this.profiler.event("session","Session.run",async()=>{const p=this.normalizeAndValidateInputs(h),s=await this._executionPlan.execute(this.sessionHandler,p);return this.createOutput(s)})}normalizeAndValidateInputs(h){const p=this._model.graph.getInputNames();if(Array.isArray(h)){if(h.length!==p.length)throw new Error(`incorrect input array length: expected ${p.length} but got ${h.length}`)}else{if(h.size!==p.length)throw new Error(`incorrect input map size: expected ${p.length} but got ${h.size}`);const s=new Array(h.size);let t=0;for(let l=0;l<p.length;++l){const u=h.get(p[l]);if(!u)throw new Error(`missing input tensor for: '${name}'`);s[t++]=u}h=s}if(this.context.graphInputTypes&&this.context.graphInputTypes.length!==0&&this.context.graphInputDims&&this.context.graphInputDims.length!==0)this.validateInputTensorDims(this.context.graphInputDims,h,!1);else{const s=this._model.graph.getInputIndices(),t=this._model.graph.getValues(),l=new Array(s.length);for(let u=0;u<s.length;++u){const g=t[s[u]];l[u]=g.type.shape.dims,this.context.graphInputTypes.push(g.type.tensorType),this.context.graphInputDims.push(h[u].dims)}this.validateInputTensorDims(l,h,!0)}return this.validateInputTensorTypes(this.context.graphInputTypes,h),h}validateInputTensorTypes(h,p){for(let s=0;s<p.length;s++){const t=h[s],l=p[s].type;if(t!==l)throw new Error(`input tensor[${s}] check failed: expected type '${t}' but got ${l}`)}}validateInputTensorDims(h,p,s){for(let t=0;t<p.length;t++){const l=h[t],u=p[t].dims;if(!this.compareTensorDims(l,u,s))throw new Error(`input tensor[${t}] check failed: expected shape '[${l.join(",")}]' but got [${u.join(",")}]`)}}compareTensorDims(h,p,s){if(h.length!==p.length)return!1;for(let t=0;t<h.length;++t)if(h[t]!==p[t]&&(!s||h[t]!==0))return!1;return!0}createOutput(h){const p=this._model.graph.getOutputNames();if(h.length!==p.length)throw new Error("expected number of outputs do not match number of generated outputs");const s=new Map;for(let t=0;t<p.length;++t)s.set(p[t],h[t]);return s}initializeOps(h){const p=h.getNodes();this._ops=new Array(p.length);for(let s=0;s<p.length;s++)this._ops[s]=this.sessionHandler.resolve(p[s],this._model.opsets,h)}}},9240:function(c,e,n){var r=this&&this.__importDefault||function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(e,"__esModule",{value:!0}),e.Tensor=void 0;const i=n(3442),o=r(n(1583)),a=n(5127),d=n(2446),f=n(7273);var h=a.onnxruntime.experimental.fbs;class p{get data(){if(this.cache===void 0){const m=this.dataProvider(this.dataId);if(m.length!==this.size)throw new Error("Length of data provided by the Data Provider is inconsistent with the dims of this Tensor.");this.cache=m}return this.cache}get stringData(){if(this.type!=="string")throw new TypeError("data type is not string");return this.data}get integerData(){switch(this.type){case"uint8":case"int8":case"uint16":case"int16":case"int32":case"uint32":case"bool":return this.data;default:throw new TypeError("data type is not integer (uint8, int8, uint16, int16, int32, uint32, bool)")}}get floatData(){switch(this.type){case"float32":case"float64":return this.data;default:throw new TypeError("data type is not float (float32, float64)")}}get numberData(){if(this.type!=="string")return this.data;throw new TypeError("type cannot be non-number (string)")}get(m){return this.data[f.ShapeUtil.indicesToOffset(m,this.strides)]}set(m,_){this.data[f.ShapeUtil.indicesToOffset(m,this.strides)]=_}async getData(){return this.cache===void 0&&(this.cache=await this.asyncDataProvider(this.dataId)),this.cache}get strides(){return this._strides||(this._strides=f.ShapeUtil.computeStrides(this.dims)),this._strides}constructor(m,_,b,y,v,T=i.Guid.create()){this.dims=m,this.type=_,this.dataProvider=b,this.asyncDataProvider=y,this.cache=v,this.dataId=T,this.size=f.ShapeUtil.validateDimsAndCalcSize(m);const w=this.size,S=b===void 0&&y===void 0&&v===void 0;if(v!==void 0&&v.length!==w)throw new RangeError("Input dims doesn't match data length.");if(_==="string"){if(!(v===void 0||Array.isArray(v)&&v.every(x=>typeof x=="string")))throw new TypeError("cache should be a string array");S&&(this.cache=new Array(w))}else{if(v!==void 0){const x=t(_);if(!(v instanceof x))throw new TypeError(`cache should be type ${x.name}`)}if(S){const x=new ArrayBuffer(w*function(P){switch(P){case"bool":case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;case"float64":return 8;default:throw new Error(`cannot calculate sizeof() on type ${P}`)}}(_));this.cache=function(P,I){return new(t(I))(P)}(x,_)}}}static fromProto(m){if(!m)throw new Error("cannot construct Value from an empty tensor");const _=f.ProtoUtil.tensorDataTypeFromProto(m.dataType),b=f.ProtoUtil.tensorDimsFromProto(m.dims),y=new p(b,_);if(_==="string")m.stringData.forEach((v,T)=>{y.data[T]=(0,f.decodeUtf8String)(v)});else if(m.rawData&&typeof m.rawData.byteLength=="number"&&m.rawData.byteLength>0){const v=y.data,T=new DataView(m.rawData.buffer,m.rawData.byteOffset,m.rawData.byteLength),w=s(m.dataType),S=m.rawData.byteLength/w;if(m.rawData.byteLength%w!=0)throw new Error("invalid buffer length");if(v.length!==S)throw new Error("buffer length mismatch");for(let x=0;x<S;x++){const P=u(T,m.dataType,x*w);v[x]=P}}else{let v;switch(m.dataType){case d.onnx.TensorProto.DataType.FLOAT:v=m.floatData;break;case d.onnx.TensorProto.DataType.INT32:case d.onnx.TensorProto.DataType.INT16:case d.onnx.TensorProto.DataType.UINT16:case d.onnx.TensorProto.DataType.INT8:case d.onnx.TensorProto.DataType.UINT8:case d.onnx.TensorProto.DataType.BOOL:v=m.int32Data;break;case d.onnx.TensorProto.DataType.INT64:v=m.int64Data;break;case d.onnx.TensorProto.DataType.DOUBLE:v=m.doubleData;break;case d.onnx.TensorProto.DataType.UINT32:case d.onnx.TensorProto.DataType.UINT64:v=m.uint64Data;break;default:throw new Error("unspecific error")}if(v==null)throw new Error("failed to populate data from a tensorproto value");const T=y.data;if(T.length!==v.length)throw new Error("array length mismatch");for(let w=0;w<v.length;w++){const S=v[w];o.default.isLong(S)?T[w]=l(S,m.dataType):T[w]=S}}return y}static fromData(m,_,b){return new p(_,b,void 0,void 0,m)}static fromOrtTensor(m){if(!m)throw new Error("cannot construct Value from an empty tensor");const _=f.ProtoUtil.tensorDimsFromORTFormat(m),b=f.ProtoUtil.tensorDataTypeFromProto(m.dataType()),y=new p(_,b);if(b==="string")for(let v=0;v<m.stringDataLength();v++)y.data[v]=m.stringData(v);else if(m.rawDataArray()&&typeof m.rawDataLength()=="number"&&m.rawDataLength()>0){const v=y.data,T=new DataView(m.rawDataArray().buffer,m.rawDataArray().byteOffset,m.rawDataLength()),w=s(m.dataType()),S=m.rawDataLength()/w;if(m.rawDataLength()%w!=0)throw new Error("invalid buffer length");if(v.length!==S)throw new Error("buffer length mismatch");for(let x=0;x<S;x++){const P=u(T,m.dataType(),x*w);v[x]=P}}return y}}function s(g){switch(g){case d.onnx.TensorProto.DataType.UINT8:case d.onnx.TensorProto.DataType.INT8:case d.onnx.TensorProto.DataType.BOOL:return 1;case d.onnx.TensorProto.DataType.UINT16:case d.onnx.TensorProto.DataType.INT16:return 2;case d.onnx.TensorProto.DataType.FLOAT:case d.onnx.TensorProto.DataType.INT32:case d.onnx.TensorProto.DataType.UINT32:return 4;case d.onnx.TensorProto.DataType.INT64:case d.onnx.TensorProto.DataType.DOUBLE:case d.onnx.TensorProto.DataType.UINT64:return 8;default:throw new Error(`cannot calculate sizeof() on type ${d.onnx.TensorProto.DataType[g]}`)}}function t(g){switch(g){case"bool":case"uint8":return Uint8Array;case"int8":return Int8Array;case"int16":return Int16Array;case"uint16":return Uint16Array;case"int32":return Int32Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"float32":return Float32Array;case"float64":return Float64Array;default:throw new Error("unspecified error")}}function l(g,m){if(m===d.onnx.TensorProto.DataType.INT64||m===h.TensorDataType.INT64){if(g.greaterThanOrEqual(2147483648)||g.lessThan(-2147483648))throw new TypeError("int64 is not supported")}else{if(m!==d.onnx.TensorProto.DataType.UINT32&&m!==h.TensorDataType.UINT32&&m!==d.onnx.TensorProto.DataType.UINT64&&m!==h.TensorDataType.UINT64)throw new TypeError(`not a LONG type: ${d.onnx.TensorProto.DataType[m]}`);if(g.greaterThanOrEqual(4294967296)||g.lessThan(0))throw new TypeError("uint64 is not supported")}return g.toNumber()}function u(g,m,_){switch(m){case d.onnx.TensorProto.DataType.BOOL:case d.onnx.TensorProto.DataType.UINT8:return g.getUint8(_);case d.onnx.TensorProto.DataType.INT8:return g.getInt8(_);case d.onnx.TensorProto.DataType.UINT16:return g.getUint16(_,!0);case d.onnx.TensorProto.DataType.INT16:return g.getInt16(_,!0);case d.onnx.TensorProto.DataType.FLOAT:return g.getFloat32(_,!0);case d.onnx.TensorProto.DataType.INT32:return g.getInt32(_,!0);case d.onnx.TensorProto.DataType.UINT32:return g.getUint32(_,!0);case d.onnx.TensorProto.DataType.INT64:return l(o.default.fromBits(g.getUint32(_,!0),g.getUint32(_+4,!0),!1),m);case d.onnx.TensorProto.DataType.DOUBLE:return g.getFloat64(_,!0);case d.onnx.TensorProto.DataType.UINT64:return l(o.default.fromBits(g.getUint32(_,!0),g.getUint32(_+4,!0),!0),m);default:throw new Error(`cannot read from DataView for type ${d.onnx.TensorProto.DataType[m]}`)}}e.Tensor=p},7273:function(c,e,n){var r=this&&this.__importDefault||function(m){return m&&m.__esModule?m:{default:m}};Object.defineProperty(e,"__esModule",{value:!0}),e.decodeUtf8String=e.MAX_CLIP=e.MIN_CLIP=e.PoolConvUtil=e.ReduceUtil=e.SplitUtil=e.MathUtil=e.ShapeUtil=e.LongUtil=e.ProtoUtil=e.GemmUtil=e.arrayCopyHelper=e.BroadcastUtil=e.MatMulUtil=e.ArrayUtil=e.assert=e.checkInputsShape=void 0;const i=n(5686),o=r(n(1583)),a=n(2446),d=n(9240);e.checkInputsShape=function(m,..._){if(!m||m.length!==_.length)return!1;for(let b=0;b<m.length;b++)if(!m[b].dims||m[b].dims.length!==_[b])return!1;return!0},e.assert=function(m,_){if(!m)throw new Error(typeof _=="string"?_:_())},e.ArrayUtil=class{static arraysEqual(m,_){if(m.length!==_.length)return!1;for(let b=0;b<m.length;b++)if(m[b]!==_[b])return!1;return!0}};class f{static preprocessInputShapes(_,b){return[_.length===1?[1,_[0]]:_,b.length===1?[b[0],1]:b]}static postprocessOutputShape(_,b,y){b===1&&_.splice(_.length-2,1),y===1&&_.pop()}static calcMatMulShape(_,b){return _[1]!==b[0]?void 0:[_[0],b[1]]}}e.MatMulUtil=f;class h{static calcShape(_,b,y=!1){const v=_.length,T=b.length;if(v===0)return b;if(T===0)return _;const w=Math.max(_.length,b.length),S=new Array(w);if(y){if(v<2||T<2)return;const x=f.calcMatMulShape([_[v-2],_[v-1]],[b[T-2],b[T-1]]);if(x===void 0)return;[S[w-2],S[w-1]]=x}for(let x=y?3:1;x<=w;x++){const P=v-x<0?1:_[v-x],I=T-x<0?1:b[T-x];if(P!==I&&P>1&&I>1)return;S[w-x]=Math.max(P,I)}return S}static index(_,b){const y=new Array(b.length);return h.fillIndex(_,b,y),y}static fillIndex(_,b,y){const v=_.length-b.length;for(let T=0;T<b.length;T++)y[T]=_[v+T]%b[T]}static calc(_,b,y,v,T){const w=h.calcShape(_.dims,b.dims);if(w){if(v&&!t.areEqual(w,_.dims))return;const S=t.size(w),x=v?_:new d.Tensor(w,T||_.type);if(w.length===0)x.set([],y(_.get([]),b.get([])));else{const P=new Array(w.length),I=new Array(_.dims.length),N=new Array(b.dims.length);let L,E=0,M=0,k=!1,A=!1;_.dims.length===0&&(E=_.get([]),k=!0),b.dims.length===0&&(M=b.get([]),A=!0);for(let R=0;R<S;R++){L=R;for(let K=w.length-1;K>=0;K--)P[K]=L%w[K],L=Math.floor(L/w[K]);k||(h.fillIndex(P,_.dims,I),E=_.get(I)),A||(h.fillIndex(P,b.dims,N),M=b.get(N)),x.set(P,y(E,M))}}return x}}static isValidBroadcast(_,b){const y=_.length,v=b.length;if(y>v)return!1;for(let T=1;T<=y;T++)if(_[y-T]!==1&&_[y-T]!==b[v-T])return!1;return!0}static getBroadcastDims(_,b){const y=_.length,v=[];for(let T=0;T<y;T++){const w=y-1-T,S=_[w]||1;(b[b.length-1-T]||1)>1&&S===1&&v.unshift(w)}return v}}e.BroadcastUtil=h,e.arrayCopyHelper=function(m,_,b,y,v){if(y<0||y>=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(y+v>_.length)throw new Error("source indices to be copied are outside bounds");if(b+v>m.length)throw new Error("target array is too small to hold result");for(let T=0;T<v;T++)m[b+T]=_[y+T]},e.GemmUtil=class{static getShapeOfGemmResult(m,_,b,y,v){if(m.length!==2||b.length!==2)throw new Error("shape need to be of size 2");let T,w,S;_?(T=m[1],w=m[0]):(T=m[0],w=m[1]);let x=-1;if(y?(S=b[0],x=1):(S=b[1],x=0),b[x]!==w)throw new Error("dimension mismatch");if(T<=0||S<=0||w<=0)throw new Error("invalid shape specified");if(v&&!h.isValidBroadcast(v,[T,S]))throw new Error("gemm: invalid bias shape for broadcast");return[T,S,w]}};class p{static tensorDataTypeFromProto(_){switch(_){case a.onnx.TensorProto.DataType.INT8:return"int8";case a.onnx.TensorProto.DataType.UINT8:return"uint8";case a.onnx.TensorProto.DataType.BOOL:return"bool";case a.onnx.TensorProto.DataType.INT16:return"int16";case a.onnx.TensorProto.DataType.UINT16:return"uint16";case a.onnx.TensorProto.DataType.INT32:return"int32";case a.onnx.TensorProto.DataType.UINT32:return"uint32";case a.onnx.TensorProto.DataType.FLOAT:return"float32";case a.onnx.TensorProto.DataType.DOUBLE:return"float64";case a.onnx.TensorProto.DataType.STRING:return"string";case a.onnx.TensorProto.DataType.INT64:return"int32";case a.onnx.TensorProto.DataType.UINT64:return"uint32";default:throw new Error(`unsupported data type: ${a.onnx.TensorProto.DataType[_]}`)}}static tensorDataTypeStringToEnum(_){switch(_){case"int8":return a.onnx.TensorProto.DataType.INT8;case"uint8":return a.onnx.TensorProto.DataType.UINT8;case"bool":return a.onnx.TensorProto.DataType.BOOL;case"int16":return a.onnx.TensorProto.DataType.INT16;case"uint16":return a.onnx.TensorProto.DataType.UINT16;case"int32":return a.onnx.TensorProto.DataType.INT32;case"uint32":return a.onnx.TensorProto.DataType.UINT32;case"float32":return a.onnx.TensorProto.DataType.FLOAT;case"float64":return a.onnx.TensorProto.DataType.DOUBLE;case"string":return a.onnx.TensorProto.DataType.STRING;case"int64":return a.onnx.TensorProto.DataType.INT64;case"uint64":return a.onnx.TensorProto.DataType.UINT64;default:throw new Error(`unsupported data type: ${_}`)}}static tensorDimsFromProto(_){return _.map(b=>o.default.isLong(b)?b.toNumber():b)}static tensorValueTypeFromProto(_){return{tensorType:p.tensorDataTypeFromProto(_.elemType),shape:{dims:p.tensorDimsFromProto(_.shape.dim.map(b=>b.dimValue))}}}static tensorDimsFromORTFormat(_){const b=[];for(let y=0;y<_.dimsLength();y++)b.push(s.longToNumber(_.dims(y)));return b}static tensorAttributesFromORTFormat(_){const b=[];for(let y=0;y<_.attributesLength();y++)b.push(_.attributes(y));return b}}e.ProtoUtil=p;class s{static longToNumber(_,b){return o.default.isLong(_)?_.toNumber():_ instanceof i.flatbuffers.Long?o.default.fromValue({low:_.low,high:_.high,unsigned:b!=null&&b}).toNumber():_}static isLong(_){return o.default.isLong(_)||_ instanceof i.flatbuffers.Long}}e.LongUtil=s;class t{static size(_){return t.getSizeFromDimensionRange(_,0,_.length)}static sizeFromDimension(_,b){if(b<0||b>_.length)throw new Error(`invalid dimension of ${b} for sizeFromDimension as Tensor has ${_.length} dimensions.`);return t.getSizeFromDimensionRange(_,b,_.length)}static sizeToDimension(_,b){if(b<0||b>_.length)throw new Error(`invalid dimension of ${b} for sizeToDimension as Tensor has ${_.length} dimensions.`);return t.getSizeFromDimensionRange(_,0,b)}static getSizeFromDimensionRange(_,b,y){let v=1;for(let T=b;T<y;T++){if(_[T]<=0)throw new Error("cannot get valid size from specified dimension range. Most likely the range contains 0 or negative values in them.");v*=_[T]}return v}static computeStrides(_){const b=_.length;if(b===0)return[];if(b===1)return[1];const y=new Array(b);y[b-1]=1,y[b-2]=_[b-1];for(let v=b-3;v>=0;--v)y[v]=y[v+1]*_[v+1];return y}static transpose(_){return _.slice().reverse()}static indicesToOffset(_,b,y){y===void 0&&(y=_.length);let v=0;for(let T=0;T<y;++T)v+=b[T]*_[T];return v}static offsetToIndices(_,b){const y=b.length;if(y===0)return[];if(y===1)return[_*b[0]];const v=new Array(b.length);for(let T=0;T<v.length-1;++T)v[T]=Math.floor(_/b[T]),_-=v[T]*b[T];return v[v.length-1]=_,v}static normalizeAxis(_,b){if(_<-b&&_>=b)throw new Error("unsupported axis for this operation.");return _<0?_+b:_}static normalizeAxes(_,b){return _.map(y=>this.normalizeAxis(y,b))}static incrementIndex(_,b,y){if(b.length===0||_.length===0)throw new Error("Index incrementing unsupported for scalar Tensor");if(y===void 0)y=b.length;else if(y<=0||y>b.length)throw new Error("Incorrect axis to increment on");for(let v=y-1;v>=0&&(_[v]++,!(_[v]<b[v]));--v)_[v]=0}static calculateReshapedDims(_,b){if(b.length===0){if(_.length===0||t.size(_)===1)return[];throw new Error("cannot reshape to a scalar Tensor")}const y=b.length,v=new Array(y);let T=-1,w=1;for(let x=0;x<y;x++){if(b[x]<-1)throw new Error("a dimension in shape hints cannot be less than -1");if(b[x]===-1){if(T!==-1)throw new Error("at most one dimension in shape hints can be -1");T=x}else{if(b[x]===0){if(x>=_.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");v[x]=_[x]}else v[x]=b[x];w*=v[x]}}const S=t.size(_);if(T!==-1){if(S%w!=0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${_}] Output shape: [${b}]`);v[T]=S/w}else if(w!==S)throw new Error("reshapedDims and originalDims don't have matching sizes");return v}static sortBasedOnPerm(_,b){return b?b.map(y=>_[y]):_.slice().reverse()}static padShape(_,b){const y=_.length;return _.map((v,T)=>v+b[T]+b[T+y])}static areEqual(_,b){return _.length===b.length&&_.every((y,v)=>y===b[v])}static validateDimsAndCalcSize(_){if(_.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let b=1;for(const y of _){if(!Number.isInteger(y))throw new TypeError(`Invalid shape: ${y} is not an integer`);if(y<0||y>2147483647)throw new TypeError(`Invalid shape: length ${y} is not allowed`);b*=y}return b}static flattenShape(_,b){b<0&&(b+=_.length);const y=_.reduce((T,w)=>T*w,1),v=_.slice(b).reduce((T,w)=>T*w,1);return[y/v,v]}static squeezeShape(_,b){const y=new Array;b=t.normalizeAxes(b,_.length);for(let v=0;v<_.length;v++){const T=b.indexOf(v)>=0;if(T&&_[v]!==1)throw new Error("squeeze an axis of size different than 1");(b.length===0&&_[v]>1||b.length>0&&!T)&&y.push(_[v])}return y}static unsqueezeShape(_,b){const y=new Array(_.length+b.length);y.fill(0);for(let T=0;T<b.length;T++){const w=t.normalizeAxis(b[T],y.length);if(w>=y.length)throw new Error("'axes' has an out of range axis");if(y[w]!==0)throw new Error("'axes' has a duplicate axis");y[w]=1}let v=0;for(let T=0;T<y.length;T++)y[T]===0&&(y[T]=_[v++]);if(v!==_.length)throw new Error("the unsqueezed dimension could not be established");return y}}e.ShapeUtil=t,e.MathUtil=class{static sqr(m,_,b,y,v){if(y<0||y>=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(y+v>_.length)throw new Error("source indices to be copied are outside bounds");if(b+v>m.length)throw new Error("target array is too small to hold result");for(let T=0;T<v;T++)m[b+T]+=Math.pow(_[y+T],2)}static axpy(m,_,b,y,v,T){if(y<0||y>=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(y+v>_.length)throw new Error("source indices to be copied are outside bounds");if(b+v>m.length)throw new Error("target array is too small to hold result");for(let w=0;w<v;w++)m[b+w]+=T*_[y+w]}static powx(m,_,b,y,v,T){if(y<0||y>=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(y+v>_.length)throw new Error("source indices to be copied are outside bounds");if(b+v>m.length)throw new Error("target array is too small to hold result");for(let w=0;w<v;w++)m[b+w]=Math.pow(_[y+w],T)}static mul(m,_,b,y,v){if(y<0||y>=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(y+v>_.length)throw new Error("source indices to be copied are outside bounds");if(b+v>m.length)throw new Error("target array is too small to hold result");for(let T=0;T<v;T++)m[b+T]=_[y+T]*m[b+T]}};class l{static splitShape(_,b,y,v){if(y.length===0){if(!v)throw new Error("need to know number of outputs when the 'split' attribute is not specified");l.determineSplit(_[b],v,y)}const T=[],w=[0];for(let S=0;S<y.length;++S){S!==0&&w.push(w[S-1]+y[S-1]);const x=_.slice();x[b]=y[S],T.push(x)}return[T,w]}static determineSplit(_,b,y){if(_%b!=0)throw new Error("cannot split tensor to equal sized parts");for(let v=0;v<b;++v)y.push(_/b)}}e.SplitUtil=l;class u{static calcReduce(_,b,y,v,T){const w=_.dims.slice(0);b.length===0&&w.forEach((E,M)=>b.push(M));const S=u.calcReduceShape(w,b,!0),x=t.size(S),P=new d.Tensor(S,_.type),I=t.computeStrides(S),N=t.computeStrides(w),L=new Array(w.length);for(let E=0;E<x;E++){const M=t.offsetToIndices(E,I);h.fillIndex(M,w,L),P.set(M,u.calcReduceByAxis(_.numberData,b,w,0,t.indicesToOffset(L,N),v,T))}return y?P:new d.Tensor(u.calcReduceShape(w,b,y),P.type,void 0,void 0,P.data,P.dataId)}static calcReduceByAxis(_,b,y,v,T,w,S){let x=0;if(v>=b.length)return w(_[T]);const P=b[v],I=P>=y.length?1:t.size(y.slice(P+1));for(let N=0;N<y[P];N++)x=N===0?u.calcReduceByAxis(_,b,y,v+1,T,w,S):S(x,u.calcReduceByAxis(_,b,y,v+1,T,w,S)),T+=I;return x}static calcReduceShape(_,b,y){const v=_.slice();for(let T=0;T<b.length;T++)v[b[T]]=y?1:0;return v.filter(T=>T!==0)}}e.ReduceUtil=u;class g{static adjustPoolAttributes(_,b,y,v,T,w){if(!_&&y.length!==b.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(_)for(let S=0;S<b.length-2;S++)S>=y.length?y.push(b[S+2]):y[S]=b[S+2];for(let S=0;S<y.length;S++)if(S<v.length){if(v[S]<0)throw new Error("strides should be greater than or equal to 1")}else v.push(1);for(let S=0;S<y.length;S++)if(S<T.length){if(T[S]<0)throw new Error("dilations should be greater than or equal to 1")}else T.push(1);for(let S=0;S<2*y.length;S++)if(S<w.length){if(w[S]<0)throw new Error("pad should be greater than or equal to 1")}else w.push(0);for(let S=0;S<y.length;S++){if(y[S]<=0)throw new Error("kernel shapes need to be greater than 0");if(w[S]>=y[S]||w[S+y.length]>=y[S])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(_,b,y,v,T,w){if(w){if(T.length!==2*(_.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(b.length!==_.length-2)throw new Error("length of strides should be the length of data dimensions");if(v.length!==_.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let S=0;S<_.length-2;S++)g.adjustPadAndReturnShape(_[S+2],b[S],y[S],v[S],T,S,S+_.length-2,w)}}static computePoolOutputShape(_,b,y,v,T,w,S){if(b.length<=0)throw new Error("input shape must be of size greater than 0");const x=[b[0],b[1]];return g.computeShapeHelper(_,b,x,y,v,T,w,S),x}static computeConvOutputShape(_,b,y,v,T,w,S){if(_.length<=0||b.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");const x=[_[0],b[0]];return g.computeShapeHelper(!1,_,x,y,v,T,w,S),x}static computeShapeHelper(_,b,y,v,T,w,S,x){if(_)for(let P=0;P<b.length-2;P++)y.push(1);else for(let P=0;P<b.length-2;P++)y.push(g.adjustPadAndReturnShape(b[P+2],v[P],T[P],w[P],S,P,P+b.length-2,x))}static adjustPadAndReturnShape(_,b,y,v,T,w,S,x){const P=y*(v-1)+1;if(!x||x==="NOTSET")return Math.floor((_+T[w]+T[S]-P)/b+1);switch(x){case"VALID":return T[w]=0,T[S]=0,Math.floor((_-P)/b+1);case"SAME_LOWER":case"SAME_UPPER":if(y!==1)throw new Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{const I=((_+b-1)/b-1)*b+v-_;return T[w]=Math.floor(x==="SAME_LOWER"?(I+1)/2:I/2),T[S]=I-T[w],Math.floor((_+I-v)/b+1)}default:throw new Error("Unsupported AutoPad type")}}}e.PoolConvUtil=g,e.MIN_CLIP=-34028234663852886e22,e.MAX_CLIP=34028234663852886e22,e.decodeUtf8String=function(m){return new TextDecoder().decode(m)}},8408:(c,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.version=void 0,e.version="1.16.3"},9544:function(c,e,n){var r,i=this&&this.__createBinding||(Object.create?function(I,N,L,E){E===void 0&&(E=L);var M=Object.getOwnPropertyDescriptor(N,L);M&&!("get"in M?!N.__esModule:M.writable||M.configurable)||(M={enumerable:!0,get:function(){return N[L]}}),Object.defineProperty(I,E,M)}:function(I,N,L,E){E===void 0&&(E=L),I[E]=N[L]}),o=this&&this.__setModuleDefault||(Object.create?function(I,N){Object.defineProperty(I,"default",{enumerable:!0,value:N})}:function(I,N){I.default=N}),a=this&&this.__importStar||function(I){if(I&&I.__esModule)return I;var N={};if(I!=null)for(var L in I)L!=="default"&&Object.prototype.hasOwnProperty.call(I,L)&&i(N,I,L);return o(N,I),N};Object.defineProperty(e,"__esModule",{value:!0}),e.endProfiling=e.run=e.releaseSession=e.createSession=e.createSessionFinalize=e.createSessionAllocate=e.initializeRuntime=e.initializeWebAssemblyInstance=void 0;const d=n(2235),f=a(n(1259)),h=n(263),p=()=>!!d.env.wasm.proxy&&typeof document<"u";let s,t,l,u=!1,g=!1,m=!1;const _=[],b=[],y=[],v=[],T=[],w=[],S=()=>{if(u||!g||m||!s)throw new Error("worker not ready")},x=I=>{switch(I.data.type){case"init-wasm":u=!1,I.data.err?(m=!0,t[1](I.data.err)):(g=!0,t[0]());break;case"init-ort":I.data.err?l[1](I.data.err):l[0]();break;case"create_allocate":I.data.err?_.shift()[1](I.data.err):_.shift()[0](I.data.out);break;case"create_finalize":I.data.err?b.shift()[1](I.data.err):b.shift()[0](I.data.out);break;case"create":I.data.err?y.shift()[1](I.data.err):y.shift()[0](I.data.out);break;case"release":I.data.err?v.shift()[1](I.data.err):v.shift()[0]();break;case"run":I.data.err?T.shift()[1](I.data.err):T.shift()[0](I.data.out);break;case"end-profiling":I.data.err?w.shift()[1](I.data.err):w.shift()[0]()}},P=typeof document<"u"?(r=document==null?void 0:document.currentScript)===null||r===void 0?void 0:r.src:void 0;e.initializeWebAssemblyInstance=async()=>{if(p()){if(g)return;if(u)throw new Error("multiple calls to 'initWasm()' detected.");if(m)throw new Error("previous call to 'initWasm()' failed.");return u=!0,d.env.wasm.wasmPaths===void 0&&P&&P.indexOf("blob:")!==0&&(d.env.wasm.wasmPaths=P.substr(0,+P.lastIndexOf("/")+1)),new Promise((I,N)=>{s==null||s.terminate(),s=n(8050).Z(),s.onmessage=x,t=[I,N];const L={type:"init-wasm",in:d.env.wasm};s.postMessage(L)})}return(0,h.initializeWebAssembly)(d.env.wasm)},e.initializeRuntime=async I=>{if(p())return S(),new Promise((N,L)=>{l=[N,L];const E={type:"init-ort",in:I};s.postMessage(E)});await f.initRuntime(I)},e.createSessionAllocate=async I=>p()?(S(),new Promise((N,L)=>{_.push([N,L]);const E={type:"create_allocate",in:{model:I}};s.postMessage(E,[I.buffer])})):f.createSessionAllocate(I),e.createSessionFinalize=async(I,N)=>p()?(S(),new Promise((L,E)=>{b.push([L,E]);const M={type:"create_finalize",in:{modeldata:I,options:N}};s.postMessage(M)})):f.createSessionFinalize(I,N),e.createSession=async(I,N)=>p()?(S(),new Promise((L,E)=>{y.push([L,E]);const M={type:"create",in:{model:I,options:N}};s.postMessage(M,[I.buffer])})):f.createSession(I,N),e.releaseSession=async I=>{if(p())return S(),new Promise((N,L)=>{v.push([N,L]);const E={type:"release",in:I};s.postMessage(E)});f.releaseSession(I)},e.run=async(I,N,L,E,M)=>p()?(S(),new Promise((k,A)=>{T.push([k,A]);const R={type:"run",in:{sessionId:I,inputIndices:N,inputs:L,outputIndices:E,options:M}};s.postMessage(R,f.extractTransferableBuffers(L))})):f.run(I,N,L,E,M),e.endProfiling=async I=>{if(p())return S(),new Promise((N,L)=>{w.push([N,L]);const E={type:"end-profiling",in:I};s.postMessage(E)});f.endProfiling(I)}},7918:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.setRunOptions=void 0;const r=n(263),i=n(1497);e.setRunOptions=o=>{const a=(0,r.getInstance)();let d=0;const f=[],h=o||{};try{if((o==null?void 0:o.logSeverityLevel)===void 0)h.logSeverityLevel=2;else if(typeof o.logSeverityLevel!="number"||!Number.isInteger(o.logSeverityLevel)||o.logSeverityLevel<0||o.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${o.logSeverityLevel}`);if((o==null?void 0:o.logVerbosityLevel)===void 0)h.logVerbosityLevel=0;else if(typeof o.logVerbosityLevel!="number"||!Number.isInteger(o.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${o.logVerbosityLevel}`);(o==null?void 0:o.terminate)===void 0&&(h.terminate=!1);let p=0;return(o==null?void 0:o.tag)!==void 0&&(p=(0,i.allocWasmString)(o.tag,f)),d=a._OrtCreateRunOptions(h.logSeverityLevel,h.logVerbosityLevel,!!h.terminate,p),d===0&&(0,i.checkLastError)("Can't create run options."),(o==null?void 0:o.extra)!==void 0&&(0,i.iterateExtraOptions)(o.extra,"",new WeakSet,(s,t)=>{const l=(0,i.allocWasmString)(s,f),u=(0,i.allocWasmString)(t,f);a._OrtAddRunConfigEntry(d,l,u)!==0&&(0,i.checkLastError)(`Can't set a run config entry: ${s} - ${t}.`)}),[d,f]}catch(p){throw d!==0&&a._OrtReleaseRunOptions(d),f.forEach(s=>a._free(s)),p}}},6640:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OnnxruntimeWebAssemblySessionHandler=void 0;const r=n(2806),i=n(2235),o=n(2850),a=n(9544);let d;e.OnnxruntimeWebAssemblySessionHandler=class{async createSessionAllocate(f){const h=await fetch(f);if(h.status!==200)throw new Error(`failed to load model: ${f}`);const p=await h.arrayBuffer();return(0,a.createSessionAllocate)(new Uint8Array(p))}async loadModel(f,h){if(d||(await(0,a.initializeRuntime)(i.env),d=!0),typeof f=="string")if(typeof process<"u"&&process.versions&&process.versions.node){const p=await(0,o.promisify)(r.readFile)(f);[this.sessionId,this.inputNames,this.outputNames]=await(0,a.createSession)(p,h)}else{const p=await this.createSessionAllocate(f);[this.sessionId,this.inputNames,this.outputNames]=await(0,a.createSessionFinalize)(p,h)}else[this.sessionId,this.inputNames,this.outputNames]=await(0,a.createSession)(f,h)}async dispose(){return(0,a.releaseSession)(this.sessionId)}async run(f,h,p){const s=[],t=[];Object.entries(f).forEach(m=>{const _=m[0],b=m[1],y=this.inputNames.indexOf(_);if(y===-1)throw new Error(`invalid input '${_}'`);s.push(b),t.push(y)});const l=[];Object.entries(h).forEach(m=>{const _=m[0],b=this.outputNames.indexOf(_);if(b===-1)throw new Error(`invalid output '${_}'`);l.push(b)});const u=await(0,a.run)(this.sessionId,t,s.map(m=>[m.type,m.dims,m.data]),l,p),g={};for(let m=0;m<u.length;m++)g[this.outputNames[l[m]]]=new i.Tensor(u[m][0],u[m][2],u[m][1]);return g}startProfiling(){}endProfiling(){(0,a.endProfiling)(this.sessionId)}}},7622:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.setSessionOptions=void 0;const r=n(263),i=n(1497);e.setSessionOptions=o=>{var a,d,f,h;const p=(0,r.getInstance)();let s=0;const t=[],l=o||{};(u=>{u.extra||(u.extra={}),u.extra.session||(u.extra.session={});const g=u.extra.session;g.use_ort_model_bytes_directly||(g.use_ort_model_bytes_directly="1"),u.executionProviders&&u.executionProviders.some(m=>(typeof m=="string"?m:m.name)==="webgpu")&&(u.enableMemPattern=!1)})(l);try{const u=(v=>{switch(v){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${v}`)}})((a=l.graphOptimizationLevel)!==null&&a!==void 0?a:"all"),g=(v=>{switch(v){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${v}`)}})((d=l.executionMode)!==null&&d!==void 0?d:"sequential"),m=typeof l.logId=="string"?(0,i.allocWasmString)(l.logId,t):0,_=(f=l.logSeverityLevel)!==null&&f!==void 0?f:2;if(!Number.isInteger(_)||_<0||_>4)throw new Error(`log serverity level is not valid: ${_}`);const b=(h=l.logVerbosityLevel)!==null&&h!==void 0?h:0;if(!Number.isInteger(b)||b<0||b>4)throw new Error(`log verbosity level is not valid: ${b}`);const y=typeof l.optimizedModelFilePath=="string"?(0,i.allocWasmString)(l.optimizedModelFilePath,t):0;return s=p._OrtCreateSessionOptions(u,!!l.enableCpuMemArena,!!l.enableMemPattern,g,!!l.enableProfiling,0,m,_,b,y),s===0&&(0,i.checkLastError)("Can't create session options."),l.executionProviders&&((v,T,w)=>{for(const S of T){let x=typeof S=="string"?S:S.name;switch(x){case"xnnpack":x="XNNPACK";break;case"webnn":if(x="WEBNN",typeof S!="string"){const I=S;if(I!=null&&I.deviceType){const N=(0,i.allocWasmString)("deviceType",w),L=(0,i.allocWasmString)(I.deviceType,w);(0,r.getInstance)()._OrtAddSessionConfigEntry(v,N,L)!==0&&(0,i.checkLastError)(`Can't set a session config entry: 'deviceType' - ${I.deviceType}.`)}if(I!=null&&I.powerPreference){const N=(0,i.allocWasmString)("powerPreference",w),L=(0,i.allocWasmString)(I.powerPreference,w);(0,r.getInstance)()._OrtAddSessionConfigEntry(v,N,L)!==0&&(0,i.checkLastError)(`Can't set a session config entry: 'powerPreference' - ${I.powerPreference}.`)}}break;case"webgpu":x="JS";break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${x}`)}const P=(0,i.allocWasmString)(x,w);(0,r.getInstance)()._OrtAppendExecutionProvider(v,P)!==0&&(0,i.checkLastError)(`Can't append execution provider: ${x}.`)}})(s,l.executionProviders,t),l.extra!==void 0&&(0,i.iterateExtraOptions)(l.extra,"",new WeakSet,(v,T)=>{const w=(0,i.allocWasmString)(v,t),S=(0,i.allocWasmString)(T,t);p._OrtAddSessionConfigEntry(s,w,S)!==0&&(0,i.checkLastError)(`Can't set a session config entry: ${v} - ${T}.`)}),[s,t]}catch(u){throw s!==0&&p._OrtReleaseSessionOptions(s),t.forEach(g=>p._free(g)),u}}},7917:(c,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.logLevelStringToEnum=e.tensorTypeToTypedArrayConstructor=e.getTensorElementSize=e.tensorDataTypeEnumToString=e.tensorDataTypeStringToEnum=void 0,e.tensorDataTypeStringToEnum=n=>{switch(n){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${n}`)}},e.tensorDataTypeEnumToString=n=>{switch(n){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${n}`)}},e.getTensorElementSize=n=>[void 0,4,1,1,2,2,4,8,void 0,1,2,8,4,8,void 0,void 0,void 0][n],e.tensorTypeToTypedArrayConstructor=n=>{switch(n){case"float16":case"uint16":return Uint16Array;case"float32":return Float32Array;case"uint8":case"bool":return Uint8Array;case"int8":return Int8Array;case"int16":return Int16Array;case"int32":return Int32Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${n}`)}},e.logLevelStringToEnum=n=>{switch(n){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${n}`)}}},1259:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extractTransferableBuffers=e.endProfiling=e.run=e.releaseSession=e.createSession=e.createSessionFinalize=e.createSessionAllocate=e.initRuntime=void 0;const r=n(7918),i=n(7622),o=n(7917),a=n(263),d=n(1497);e.initRuntime=async h=>{var p,s;p=h.wasm.numThreads,s=(0,o.logLevelStringToEnum)(h.logLevel),(0,a.getInstance)()._OrtInit(p,s)!==0&&(0,d.checkLastError)("Can't initialize onnxruntime.")};const f=new Map;e.createSessionAllocate=h=>{const p=(0,a.getInstance)(),s=p._malloc(h.byteLength);if(s===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${h.byteLength}.`);return p.HEAPU8.set(h,s),[s,h.byteLength]},e.createSessionFinalize=(h,p)=>{const s=(0,a.getInstance)();let t=0,l=0,u=[];const g=[],m=[];try{[l,u]=(0,i.setSessionOptions)(p),t=s._OrtCreateSession(h[0],h[1],l),t===0&&(0,d.checkLastError)("Can't create a session.");const[_,b]=(T=>{const w=(0,a.getInstance)(),S=w.stackSave();try{const x=w.stackAlloc(8);return w._OrtGetInputOutputCount(T,x,x+4)!==0&&(0,d.checkLastError)("Can't get session input/output count."),[w.HEAP32[x/4],w.HEAP32[x/4+1]]}finally{w.stackRestore(S)}})(t),y=[],v=[];for(let T=0;T<_;T++){const w=s._OrtGetInputName(t,T);w===0&&(0,d.checkLastError)("Can't get an input name."),g.push(w),y.push(s.UTF8ToString(w))}for(let T=0;T<b;T++){const w=s._OrtGetOutputName(t,T);w===0&&(0,d.checkLastError)("Can't get an output name."),m.push(w),v.push(s.UTF8ToString(w))}return f.set(t,[t,g,m]),[t,y,v]}catch(_){throw g.forEach(b=>s._OrtFree(b)),m.forEach(b=>s._OrtFree(b)),t!==0&&s._OrtReleaseSession(t),_}finally{s._free(h[0]),l!==0&&s._OrtReleaseSessionOptions(l),u.forEach(_=>s._free(_))}},e.createSession=(h,p)=>{const s=(0,e.createSessionAllocate)(h);return(0,e.createSessionFinalize)(s,p)},e.releaseSession=h=>{const p=(0,a.getInstance)(),s=f.get(h);if(!s)throw new Error(`cannot release session. invalid session id: ${h}`);const[t,l,u]=s;l.forEach(g=>p._OrtFree(g)),u.forEach(g=>p._OrtFree(g)),p._OrtReleaseSession(t),f.delete(h)},e.run=async(h,p,s,t,l)=>{const u=(0,a.getInstance)(),g=f.get(h);if(!g)throw new Error(`cannot run inference. invalid session id: ${h}`);const[m,_,b]=g,y=p.length,v=t.length;let T=0,w=[];const S=[],x=[];try{[T,w]=(0,r.setRunOptions)(l);for(let M=0;M<y;M++){const k=s[M][0],A=s[M][1],R=s[M][2];let K,Z;if(Array.isArray(R)){Z=4*R.length,K=u._malloc(Z),x.push(K);let te=K/4;for(let oe=0;oe<R.length;oe++){if(typeof R[oe]!="string")throw new TypeError(`tensor data at index ${oe} is not a string`);u.HEAPU32[te++]=(0,d.allocWasmString)(R[oe],x)}}else Z=R.byteLength,K=u._malloc(Z),x.push(K),u.HEAPU8.set(new Uint8Array(R.buffer,R.byteOffset,Z),K);const J=u.stackSave(),X=u.stackAlloc(4*A.length);try{let te=X/4;A.forEach(ae=>u.HEAP32[te++]=ae);const oe=u._OrtCreateTensor((0,o.tensorDataTypeStringToEnum)(k),K,Z,X,A.length);oe===0&&(0,d.checkLastError)(`Can't create tensor for input[${M}].`),S.push(oe)}finally{u.stackRestore(J)}}const P=u.stackSave(),I=u.stackAlloc(4*y),N=u.stackAlloc(4*y),L=u.stackAlloc(4*v),E=u.stackAlloc(4*v);try{let M=I/4,k=N/4,A=L/4,R=E/4;for(let X=0;X<y;X++)u.HEAPU32[M++]=S[X],u.HEAPU32[k++]=_[p[X]];for(let X=0;X<v;X++)u.HEAPU32[A++]=0,u.HEAPU32[R++]=b[t[X]];let K=u._OrtRun(m,N,I,y,E,v,L,T);const Z=u.jsepRunPromise;Z&&Z.then!==void 0&&(K=await Z);const J=[];K!==0&&(0,d.checkLastError)("failed to call OrtRun().");for(let X=0;X<v;X++){const te=u.HEAPU32[L/4+X],oe=u.stackSave(),ae=u.stackAlloc(16);let ce,fe=0;try{K=u._OrtGetTensorData(te,ae,ae+4,ae+8,ae+12),K!==0&&(0,d.checkLastError)(`Can't access output tensor data on index ${X}.`);let he=ae/4;const xe=u.HEAPU32[he++];fe=u.HEAPU32[he++];const we=u.HEAPU32[he++],Re=u.HEAPU32[he++],be=[];for(let ge=0;ge<Re;ge++)be.push(u.HEAPU32[we/4+ge]);u._OrtFree(we);const Ne=be.length===0?1:be.reduce((ge,ye)=>ge*ye);if(ce=(0,o.tensorDataTypeEnumToString)(xe),ce==="string"){const ge=[];let ye=fe/4;for(let Oe=0;Oe<Ne;Oe++){const Pe=u.HEAPU32[ye++],Ae=Oe===Ne-1?void 0:u.HEAPU32[ye]-Pe;ge.push(u.UTF8ToString(Pe,Ae))}J.push([ce,be,ge])}else{const ge=new((0,o.tensorTypeToTypedArrayConstructor)(ce))(Ne);new Uint8Array(ge.buffer,ge.byteOffset,ge.byteLength).set(u.HEAPU8.subarray(fe,fe+ge.byteLength)),J.push([ce,be,ge])}}finally{u.stackRestore(oe),ce==="string"&&fe&&u._free(fe),u._OrtReleaseTensor(te)}}return J}finally{u.stackRestore(P)}}finally{S.forEach(P=>u._OrtReleaseTensor(P)),x.forEach(P=>u._free(P)),T!==0&&u._OrtReleaseRunOptions(T),w.forEach(P=>u._free(P))}},e.endProfiling=h=>{const p=(0,a.getInstance)(),s=f.get(h);if(!s)throw new Error("invalid session id");const t=s[0],l=p._OrtEndProfiling(t);l===0&&(0,d.checkLastError)("Can't get an profile file name."),p._OrtFree(l)},e.extractTransferableBuffers=h=>{const p=[];for(const s of h){const t=s[2];!Array.isArray(t)&&t.buffer&&p.push(t.buffer)}return p}},263:function(c,e,n){var r=this&&this.__createBinding||(Object.create?function(l,u,g,m){m===void 0&&(m=g);var _=Object.getOwnPropertyDescriptor(u,g);_&&!("get"in _?!u.__esModule:_.writable||_.configurable)||(_={enumerable:!0,get:function(){return u[g]}}),Object.defineProperty(l,m,_)}:function(l,u,g,m){m===void 0&&(m=g),l[m]=u[g]}),i=this&&this.__setModuleDefault||(Object.create?function(l,u){Object.defineProperty(l,"default",{enumerable:!0,value:u})}:function(l,u){l.default=u}),o=this&&this.__importStar||function(l){if(l&&l.__esModule)return l;var u={};if(l!=null)for(var g in l)g!=="default"&&Object.prototype.hasOwnProperty.call(l,g)&&r(u,l,g);return i(u,l),u};Object.defineProperty(e,"__esModule",{value:!0}),e.dispose=e.getInstance=e.initializeWebAssembly=void 0;const a=o(n(6449)),d=n(932),f=n(3474);let h,p=!1,s=!1,t=!1;e.initializeWebAssembly=async l=>{if(p)return Promise.resolve();if(s)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(t)throw new Error("previous call to 'initializeWebAssembly()' failed.");s=!0;const u=l.initTimeout,g=l.numThreads,m=l.simd,_=g>1&&(()=>{try{return typeof SharedArrayBuffer<"u"&&(typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])))}catch{return!1}})(),b=m&&(()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}})(),y=l.wasmPaths,v=typeof y=="string"?y:void 0,T=((P,I)=>I?P?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":P?"ort-wasm-simd.wasm":"ort-wasm.wasm")(b,_),w=typeof y=="object"?y[T]:void 0;let S=!1;const x=[];if(u>0&&x.push(new Promise(P=>{setTimeout(()=>{S=!0,P()},u)})),x.push(new Promise((P,I)=>{const N=_?f:d,L={locateFile:(E,M)=>_&&E.endsWith(".worker.js")&&typeof Blob<"u"?URL.createObjectURL(new Blob([n(4154)],{type:"text/javascript"})):E.endsWith(".wasm")?w||(v??M)+T:M+E};if(_)if(typeof Blob>"u")L.mainScriptUrlOrBlob=a.join(__dirname,"ort-wasm-threaded.js");else{const E=`var ortWasmThreaded=(function(){var _scriptDir;return ${N.toString()}})();`;L.mainScriptUrlOrBlob=new Blob([E],{type:"text/javascript"})}N(L).then(E=>{s=!1,p=!0,h=E,P()},E=>{s=!1,t=!0,I(E)})})),await Promise.race(x),S)throw new Error(`WebAssembly backend initializing failed due to timeout: ${u}ms`)},e.getInstance=()=>{if(p&&h)return h;throw new Error("WebAssembly is not initialized yet.")},e.dispose=()=>{var l;!p||s||t||(s=!0,(l=h.PThread)===null||l===void 0||l.terminateAllThreads(),h=void 0,s=!1,p=!1,t=!0)}},1497:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.checkLastError=e.iterateExtraOptions=e.allocWasmString=void 0;const r=n(263);e.allocWasmString=(i,o)=>{const a=(0,r.getInstance)(),d=a.lengthBytesUTF8(i)+1,f=a._malloc(d);return a.stringToUTF8(i,f,d),o.push(f),f},e.iterateExtraOptions=(i,o,a,d)=>{if(typeof i=="object"&&i!==null){if(a.has(i))throw new Error("Circular reference in options");a.add(i)}Object.entries(i).forEach(([f,h])=>{const p=o?o+f:f;if(typeof h=="object")(0,e.iterateExtraOptions)(h,p+".",a,d);else if(typeof h=="string"||typeof h=="number")d(p,h.toString());else{if(typeof h!="boolean")throw new Error("Can't handle extra config type: "+typeof h);d(p,h?"1":"0")}})},e.checkLastError=i=>{const o=(0,r.getInstance)(),a=o.stackSave();try{const d=o.stackAlloc(8);o._OrtGetLastError(d,d+4);const f=o.HEAP32[d/4],h=o.HEAPU32[d/4+1],p=h?o.UTF8ToString(h):"";throw new Error(`${i} ERROR_CODE: ${f}, ERROR_MESSAGE: ${p}`)}finally{o.stackRestore(a)}}},8050:(c,e,n)=>{n.d(e,{Z:()=>o});var r=n(6614),i=n.n(r);function o(){return i()('/*!\n* ONNX Runtime Web v1.16.3\n* Copyright (c) Microsoft Corporation. All rights reserved.\n* Licensed under the MIT License.\n*/\n(()=>{var e={918:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setRunOptions=void 0;const n=r(263),a=r(497);t.setRunOptions=e=>{const t=(0,n.getInstance)();let r=0;const o=[],i=e||{};try{if(void 0===(null==e?void 0:e.logSeverityLevel))i.logSeverityLevel=2;else if("number"!=typeof e.logSeverityLevel||!Number.isInteger(e.logSeverityLevel)||e.logSeverityLevel<0||e.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${e.logSeverityLevel}`);if(void 0===(null==e?void 0:e.logVerbosityLevel))i.logVerbosityLevel=0;else if("number"!=typeof e.logVerbosityLevel||!Number.isInteger(e.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${e.logVerbosityLevel}`);void 0===(null==e?void 0:e.terminate)&&(i.terminate=!1);let n=0;return void 0!==(null==e?void 0:e.tag)&&(n=(0,a.allocWasmString)(e.tag,o)),r=t._OrtCreateRunOptions(i.logSeverityLevel,i.logVerbosityLevel,!!i.terminate,n),0===r&&(0,a.checkLastError)("Can\'t create run options."),void 0!==(null==e?void 0:e.extra)&&(0,a.iterateExtraOptions)(e.extra,"",new WeakSet,((e,n)=>{const i=(0,a.allocWasmString)(e,o),s=(0,a.allocWasmString)(n,o);0!==t._OrtAddRunConfigEntry(r,i,s)&&(0,a.checkLastError)(`Can\'t set a run config entry: ${e} - ${n}.`)})),[r,o]}catch(e){throw 0!==r&&t._OrtReleaseRunOptions(r),o.forEach((e=>t._free(e))),e}}},622:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setSessionOptions=void 0;const n=r(263),a=r(497);t.setSessionOptions=e=>{var t,r,o,i;const s=(0,n.getInstance)();let u=0;const c=[],l=e||{};(e=>{e.extra||(e.extra={}),e.extra.session||(e.extra.session={});const t=e.extra.session;t.use_ort_model_bytes_directly||(t.use_ort_model_bytes_directly="1"),e.executionProviders&&e.executionProviders.some((e=>"webgpu"===("string"==typeof e?e:e.name)))&&(e.enableMemPattern=!1)})(l);try{const e=(e=>{switch(e){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${e}`)}})(null!==(t=l.graphOptimizationLevel)&&void 0!==t?t:"all"),f=(e=>{switch(e){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${e}`)}})(null!==(r=l.executionMode)&&void 0!==r?r:"sequential"),d="string"==typeof l.logId?(0,a.allocWasmString)(l.logId,c):0,p=null!==(o=l.logSeverityLevel)&&void 0!==o?o:2;if(!Number.isInteger(p)||p<0||p>4)throw new Error(`log serverity level is not valid: ${p}`);const g=null!==(i=l.logVerbosityLevel)&&void 0!==i?i:0;if(!Number.isInteger(g)||g<0||g>4)throw new Error(`log verbosity level is not valid: ${g}`);const h="string"==typeof l.optimizedModelFilePath?(0,a.allocWasmString)(l.optimizedModelFilePath,c):0;return u=s._OrtCreateSessionOptions(e,!!l.enableCpuMemArena,!!l.enableMemPattern,f,!!l.enableProfiling,0,d,p,g,h),0===u&&(0,a.checkLastError)("Can\'t create session options."),l.executionProviders&&((e,t,r)=>{for(const o of t){let t="string"==typeof o?o:o.name;switch(t){case"xnnpack":t="XNNPACK";break;case"webnn":if(t="WEBNN","string"!=typeof o){const t=o;if(null==t?void 0:t.deviceType){const o=(0,a.allocWasmString)("deviceType",r),i=(0,a.allocWasmString)(t.deviceType,r);0!==(0,n.getInstance)()._OrtAddSessionConfigEntry(e,o,i)&&(0,a.checkLastError)(`Can\'t set a session config entry: \'deviceType\' - ${t.deviceType}.`)}if(null==t?void 0:t.powerPreference){const o=(0,a.allocWasmString)("powerPreference",r),i=(0,a.allocWasmString)(t.powerPreference,r);0!==(0,n.getInstance)()._OrtAddSessionConfigEntry(e,o,i)&&(0,a.checkLastError)(`Can\'t set a session config entry: \'powerPreference\' - ${t.powerPreference}.`)}}break;case"webgpu":t="JS";break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${t}`)}const i=(0,a.allocWasmString)(t,r);0!==(0,n.getInstance)()._OrtAppendExecutionProvider(e,i)&&(0,a.checkLastError)(`Can\'t append execution provider: ${t}.`)}})(u,l.executionProviders,c),void 0!==l.extra&&(0,a.iterateExtraOptions)(l.extra,"",new WeakSet,((e,t)=>{const r=(0,a.allocWasmString)(e,c),n=(0,a.allocWasmString)(t,c);0!==s._OrtAddSessionConfigEntry(u,r,n)&&(0,a.checkLastError)(`Can\'t set a session config entry: ${e} - ${t}.`)})),[u,c]}catch(e){throw 0!==u&&s._OrtReleaseSessionOptions(u),c.forEach((e=>s._free(e))),e}}},917:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logLevelStringToEnum=t.tensorTypeToTypedArrayConstructor=t.getTensorElementSize=t.tensorDataTypeEnumToString=t.tensorDataTypeStringToEnum=void 0,t.tensorDataTypeStringToEnum=e=>{switch(e){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${e}`)}},t.tensorDataTypeEnumToString=e=>{switch(e){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${e}`)}},t.getTensorElementSize=e=>[void 0,4,1,1,2,2,4,8,void 0,1,2,8,4,8,void 0,void 0,void 0][e],t.tensorTypeToTypedArrayConstructor=e=>{switch(e){case"float16":case"uint16":return Uint16Array;case"float32":return Float32Array;case"uint8":case"bool":return Uint8Array;case"int8":return Int8Array;case"int16":return Int16Array;case"int32":return Int32Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${e}`)}},t.logLevelStringToEnum=e=>{switch(e){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${e}`)}}},259:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractTransferableBuffers=t.endProfiling=t.run=t.releaseSession=t.createSession=t.createSessionFinalize=t.createSessionAllocate=t.initRuntime=void 0;const n=r(918),a=r(622),o=r(917),i=r(263),s=r(497);t.initRuntime=async e=>{var t,r;t=e.wasm.numThreads,r=(0,o.logLevelStringToEnum)(e.logLevel),0!==(0,i.getInstance)()._OrtInit(t,r)&&(0,s.checkLastError)("Can\'t initialize onnxruntime.")};const u=new Map;t.createSessionAllocate=e=>{const t=(0,i.getInstance)(),r=t._malloc(e.byteLength);if(0===r)throw new Error(`Can\'t create a session. failed to allocate a buffer of size ${e.byteLength}.`);return t.HEAPU8.set(e,r),[r,e.byteLength]},t.createSessionFinalize=(e,t)=>{const r=(0,i.getInstance)();let n=0,o=0,c=[];const l=[],f=[];try{[o,c]=(0,a.setSessionOptions)(t),n=r._OrtCreateSession(e[0],e[1],o),0===n&&(0,s.checkLastError)("Can\'t create a session.");const[d,p]=(e=>{const t=(0,i.getInstance)(),r=t.stackSave();try{const r=t.stackAlloc(8);return 0!==t._OrtGetInputOutputCount(e,r,r+4)&&(0,s.checkLastError)("Can\'t get session input/output count."),[t.HEAP32[r/4],t.HEAP32[r/4+1]]}finally{t.stackRestore(r)}})(n),g=[],h=[];for(let e=0;e<d;e++){const t=r._OrtGetInputName(n,e);0===t&&(0,s.checkLastError)("Can\'t get an input name."),l.push(t),g.push(r.UTF8ToString(t))}for(let e=0;e<p;e++){const t=r._OrtGetOutputName(n,e);0===t&&(0,s.checkLastError)("Can\'t get an output name."),f.push(t),h.push(r.UTF8ToString(t))}return u.set(n,[n,l,f]),[n,g,h]}catch(e){throw l.forEach((e=>r._OrtFree(e))),f.forEach((e=>r._OrtFree(e))),0!==n&&r._OrtReleaseSession(n),e}finally{r._free(e[0]),0!==o&&r._OrtReleaseSessionOptions(o),c.forEach((e=>r._free(e)))}},t.createSession=(e,r)=>{const n=(0,t.createSessionAllocate)(e);return(0,t.createSessionFinalize)(n,r)},t.releaseSession=e=>{const t=(0,i.getInstance)(),r=u.get(e);if(!r)throw new Error(`cannot release session. invalid session id: ${e}`);const[n,a,o]=r;a.forEach((e=>t._OrtFree(e))),o.forEach((e=>t._OrtFree(e))),t._OrtReleaseSession(n),u.delete(e)},t.run=async(e,t,r,a,c)=>{const l=(0,i.getInstance)(),f=u.get(e);if(!f)throw new Error(`cannot run inference. invalid session id: ${e}`);const[d,p,g]=f,h=t.length,m=a.length;let y=0,v=[];const b=[],w=[];try{[y,v]=(0,n.setRunOptions)(c);for(let e=0;e<h;e++){const t=r[e][0],n=r[e][1],a=r[e][2];let i,u;if(Array.isArray(a)){u=4*a.length,i=l._malloc(u),w.push(i);let e=i/4;for(let t=0;t<a.length;t++){if("string"!=typeof a[t])throw new TypeError(`tensor data at index ${t} is not a string`);l.HEAPU32[e++]=(0,s.allocWasmString)(a[t],w)}}else u=a.byteLength,i=l._malloc(u),w.push(i),l.HEAPU8.set(new Uint8Array(a.buffer,a.byteOffset,u),i);const c=l.stackSave(),f=l.stackAlloc(4*n.length);try{let r=f/4;n.forEach((e=>l.HEAP32[r++]=e));const a=l._OrtCreateTensor((0,o.tensorDataTypeStringToEnum)(t),i,u,f,n.length);0===a&&(0,s.checkLastError)(`Can\'t create tensor for input[${e}].`),b.push(a)}finally{l.stackRestore(c)}}const e=l.stackSave(),i=l.stackAlloc(4*h),u=l.stackAlloc(4*h),f=l.stackAlloc(4*m),_=l.stackAlloc(4*m);try{let e=i/4,r=u/4,n=f/4,c=_/4;for(let n=0;n<h;n++)l.HEAPU32[e++]=b[n],l.HEAPU32[r++]=p[t[n]];for(let e=0;e<m;e++)l.HEAPU32[n++]=0,l.HEAPU32[c++]=g[a[e]];let v=l._OrtRun(d,u,i,h,_,m,f,y);const w=l.jsepRunPromise;w&&void 0!==w.then&&(v=await w);const O=[];0!==v&&(0,s.checkLastError)("failed to call OrtRun().");for(let e=0;e<m;e++){const t=l.HEAPU32[f/4+e],r=l.stackSave(),n=l.stackAlloc(16);let a,i=0;try{v=l._OrtGetTensorData(t,n,n+4,n+8,n+12),0!==v&&(0,s.checkLastError)(`Can\'t access output tensor data on index ${e}.`);let r=n/4;const u=l.HEAPU32[r++];i=l.HEAPU32[r++];const c=l.HEAPU32[r++],f=l.HEAPU32[r++],d=[];for(let e=0;e<f;e++)d.push(l.HEAPU32[c/4+e]);l._OrtFree(c);const p=0===d.length?1:d.reduce(((e,t)=>e*t));if(a=(0,o.tensorDataTypeEnumToString)(u),"string"===a){const e=[];let t=i/4;for(let r=0;r<p;r++){const n=l.HEAPU32[t++],a=r===p-1?void 0:l.HEAPU32[t]-n;e.push(l.UTF8ToString(n,a))}O.push([a,d,e])}else{const e=new((0,o.tensorTypeToTypedArrayConstructor)(a))(p);new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(l.HEAPU8.subarray(i,i+e.byteLength)),O.push([a,d,e])}}finally{l.stackRestore(r),"string"===a&&i&&l._free(i),l._OrtReleaseTensor(t)}}return O}finally{l.stackRestore(e)}}finally{b.forEach((e=>l._OrtReleaseTensor(e))),w.forEach((e=>l._free(e))),0!==y&&l._OrtReleaseRunOptions(y),v.forEach((e=>l._free(e)))}},t.endProfiling=e=>{const t=(0,i.getInstance)(),r=u.get(e);if(!r)throw new Error("invalid session id");const n=r[0],a=t._OrtEndProfiling(n);0===a&&(0,s.checkLastError)("Can\'t get an profile file name."),t._OrtFree(a)},t.extractTransferableBuffers=e=>{const t=[];for(const r of e){const e=r[2];!Array.isArray(e)&&e.buffer&&t.push(e.buffer)}return t}},263:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return a(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.dispose=t.getInstance=t.initializeWebAssembly=void 0;const i=o(r(449)),s=r(932),u=r(474);let c,l=!1,f=!1,d=!1;t.initializeWebAssembly=async e=>{if(l)return Promise.resolve();if(f)throw new Error("multiple calls to \'initializeWebAssembly()\' detected.");if(d)throw new Error("previous call to \'initializeWebAssembly()\' failed.");f=!0;const t=e.initTimeout,n=e.numThreads,a=e.simd,o=n>1&&(()=>{try{return"undefined"!=typeof SharedArrayBuffer&&("undefined"!=typeof MessageChannel&&(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])))}catch(e){return!1}})(),p=a&&(()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch(e){return!1}})(),g=e.wasmPaths,h="string"==typeof g?g:void 0,m=((e,t)=>t?e?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":e?"ort-wasm-simd.wasm":"ort-wasm.wasm")(p,o),y="object"==typeof g?g[m]:void 0;let v=!1;const b=[];if(t>0&&b.push(new Promise((e=>{setTimeout((()=>{v=!0,e()}),t)}))),b.push(new Promise(((e,t)=>{const n=o?u:s,a={locateFile:(e,t)=>o&&e.endsWith(".worker.js")&&"undefined"!=typeof Blob?URL.createObjectURL(new Blob([r(154)],{type:"text/javascript"})):e.endsWith(".wasm")?y||(null!=h?h:t)+m:t+e};if(o)if("undefined"==typeof Blob)a.mainScriptUrlOrBlob=i.join(__dirname,"ort-wasm-threaded.js");else{const e=`var ortWasmThreaded=(function(){var _scriptDir;return ${n.toString()}})();`;a.mainScriptUrlOrBlob=new Blob([e],{type:"text/javascript"})}n(a).then((t=>{f=!1,l=!0,c=t,e()}),(e=>{f=!1,d=!0,t(e)}))}))),await Promise.race(b),v)throw new Error(`WebAssembly backend initializing failed due to timeout: ${t}ms`)},t.getInstance=()=>{if(l&&c)return c;throw new Error("WebAssembly is not initialized yet.")},t.dispose=()=>{var e;!l||f||d||(f=!0,null===(e=c.PThread)||void 0===e||e.terminateAllThreads(),c=void 0,f=!1,l=!1,d=!0)}},497:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkLastError=t.iterateExtraOptions=t.allocWasmString=void 0;const n=r(263);t.allocWasmString=(e,t)=>{const r=(0,n.getInstance)(),a=r.lengthBytesUTF8(e)+1,o=r._malloc(a);return r.stringToUTF8(e,o,a),t.push(o),o},t.iterateExtraOptions=(e,r,n,a)=>{if("object"==typeof e&&null!==e){if(n.has(e))throw new Error("Circular reference in options");n.add(e)}Object.entries(e).forEach((([e,o])=>{const i=r?r+e:e;if("object"==typeof o)(0,t.iterateExtraOptions)(o,i+".",n,a);else if("string"==typeof o||"number"==typeof o)a(i,o.toString());else{if("boolean"!=typeof o)throw new Error("Can\'t handle extra config type: "+typeof o);a(i,o?"1":"0")}}))},t.checkLastError=e=>{const t=(0,n.getInstance)(),r=t.stackSave();try{const r=t.stackAlloc(8);t._OrtGetLastError(r,r+4);const n=t.HEAP32[r/4],a=t.HEAPU32[r/4+1],o=a?t.UTF8ToString(a):"";throw new Error(`${e} ERROR_CODE: ${n}, ERROR_MESSAGE: ${o}`)}finally{t.stackRestore(r)}}},474:(e,t,r)=>{var _scriptDir,n=(_scriptDir="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,"undefined"!=typeof __filename&&(_scriptDir=_scriptDir||__filename),function(e={}){function t(){return k.buffer!=x.buffer&&Y(),x}function n(){return k.buffer!=x.buffer&&Y(),I}function a(){return k.buffer!=x.buffer&&Y(),U}function o(){return k.buffer!=x.buffer&&Y(),L}function i(){return k.buffer!=x.buffer&&Y(),W}var s,u,c=e;c.ready=new Promise(((e,t)=>{s=e,u=t}));var l,f,d,p=Object.assign({},c),g="./this.program",h=(e,t)=>{throw t},m="object"==typeof window,y="function"==typeof importScripts,v="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,b=c.ENVIRONMENT_IS_PTHREAD||!1,w="";function _(e){return c.locateFile?c.locateFile(e,w):w+e}if(v){var O=r(384),S=r(908);let t;w=y?S.dirname(w)+"/":__dirname+"/",l=(e,t)=>(e=e.startsWith("file://")?new URL(e):S.normalize(e),O.readFileSync(e,t?void 0:"utf8")),d=e=>((e=l(e,!0)).buffer||(e=new Uint8Array(e)),e),f=(e,t,r,n=!0)=>{e=e.startsWith("file://")?new URL(e):S.normalize(e),O.readFile(e,n?void 0:"utf8",((e,a)=>{e?r(e):t(n?a.buffer:a)}))},!c.thisProgram&&1<process.argv.length&&(g=process.argv[1].replace(/\\\\/g,"/")),process.argv.slice(2),h=(e,t)=>{throw process.exitCode=e,t},c.inspect=()=>"[Emscripten Module object]";try{t=r(925)}catch(e){throw console.error(\'The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?\'),e}global.Worker=t.Worker}else(m||y)&&(y?w=self.location.href:"undefined"!=typeof document&&document.currentScript&&(w=document.currentScript.src),_scriptDir&&(w=_scriptDir),w=0!==w.indexOf("blob:")?w.substr(0,w.replace(/[?#].*/,"").lastIndexOf("/")+1):"",v||(l=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},y&&(d=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),f=(e,t,r)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==n.status&&n.response?t(n.response):r()},n.onerror=r,n.send(null)}));v&&"undefined"==typeof performance&&(global.performance=r(953).performance);var E=console.log.bind(console),A=console.error.bind(console);v&&(E=(...e)=>O.writeSync(1,e.join(" ")+"\\n"),A=(...e)=>O.writeSync(2,e.join(" ")+"\\n"));var T,M=c.print||E,R=c.printErr||A;Object.assign(c,p),p=null,c.thisProgram&&(g=c.thisProgram),c.quit&&(h=c.quit),c.wasmBinary&&(T=c.wasmBinary);var F=c.noExitRuntime||!0;"object"!=typeof WebAssembly&&te("no native wasm support detected");var k,C,P,D,x,I,U,L,W,H=!1;function Y(){var e=k.buffer;c.HEAP8=x=new Int8Array(e),c.HEAP16=new Int16Array(e),c.HEAP32=U=new Int32Array(e),c.HEAPU8=I=new Uint8Array(e),c.HEAPU16=new Uint16Array(e),c.HEAPU32=L=new Uint32Array(e),c.HEAPF32=new Float32Array(e),c.HEAPF64=W=new Float64Array(e)}var j=c.INITIAL_MEMORY||16777216;if(5242880<=j||te("INITIAL_MEMORY should be larger than STACK_SIZE, was "+j+"! (STACK_SIZE=5242880)"),b)k=c.wasmMemory;else if(c.wasmMemory)k=c.wasmMemory;else if(!((k=new WebAssembly.Memory({initial:j/65536,maximum:65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw R("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),v&&R("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");Y(),j=k.buffer.byteLength;var z,G=[],N=[],B=[],$=0;function q(){return F||0<$}var V,J,X=0,K=null,Z=null;function Q(){X++,c.monitorRunDependencies&&c.monitorRunDependencies(X)}function ee(){if(X--,c.monitorRunDependencies&&c.monitorRunDependencies(X),0==X&&(null!==K&&(clearInterval(K),K=null),Z)){var e=Z;Z=null,e()}}function te(e){throw c.onAbort&&c.onAbort(e),R(e="Aborted("+e+")"),H=!0,D=1,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),u(e),e}function re(e){return e.startsWith("data:application/octet-stream;base64,")}function ne(e){if(e==V&&T)return new Uint8Array(T);if(d)return d(e);throw"both async and sync fetching of the wasm failed"}function ae(e,t,r){return function(e){if(!T&&(m||y)){if("function"==typeof fetch&&!e.startsWith("file://"))return fetch(e,{credentials:"same-origin"}).then((t=>{if(!t.ok)throw"failed to load wasm binary file at \'"+e+"\'";return t.arrayBuffer()})).catch((()=>ne(e)));if(f)return new Promise(((t,r)=>{f(e,(e=>t(new Uint8Array(e))),r)}))}return Promise.resolve().then((()=>ne(e)))}(e).then((e=>WebAssembly.instantiate(e,t))).then((e=>e)).then(r,(e=>{R("failed to asynchronously prepare wasm: "+e),te(e)}))}function oe(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}function ie(e){e.terminate(),e.onmessage=()=>{}}function se(e){(e=ge.Fa[e])||te(),ge.fb(e)}function ue(e){var t=ge.Za();if(!t)return 6;ge.Ia.push(t),ge.Fa[e.Ha]=t,t.Ha=e.Ha;var r={cmd:"run",start_routine:e.gb,arg:e.Ya,pthread_ptr:e.Ha};return v&&t.unref(),t.postMessage(r,e.mb),0}re(V="ort-wasm-threaded.wasm")||(V=_(V));var ce="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,le=(e,t,r)=>{var n=(t>>>=0)+r;for(r=t;e[r]&&!(r>=n);)++r;if(16<r-t&&e.buffer&&ce)return ce.decode(e.buffer instanceof SharedArrayBuffer?e.slice(t,r):e.subarray(t,r));for(n="";t<r;){var a=e[t++];if(128&a){var o=63&e[t++];if(192==(224&a))n+=String.fromCharCode((31&a)<<6|o);else{var i=63&e[t++];65536>(a=224==(240&a)?(15&a)<<12|o<<6|i:(7&a)<<18|o<<12|i<<6|63&e[t++])?n+=String.fromCharCode(a):(a-=65536,n+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else n+=String.fromCharCode(a)}return n},fe=(e,t)=>(e>>>=0)?le(n(),e,t):"";function de(e){if(b)return qe(1,1,e);D=e,q()||(ge.hb(),c.onExit&&c.onExit(e),H=!0),h(e,new oe(e))}var pe=e=>{if(D=e,b)throw me(e),"unwind";de(e)},ge={La:[],Ia:[],Ta:[],Fa:{},Pa:function(){b?ge.ab():ge.$a()},$a:function(){G.unshift((()=>{Q(),ge.bb((()=>ee()))}))},ab:function(){ge.receiveObjectTransfer=ge.eb,ge.threadInitTLS=ge.Sa,ge.setExitStatus=ge.Ra,F=!1},Ra:function(e){D=e},rb:["$terminateWorker"],hb:function(){for(var e of ge.Ia)ie(e);for(e of ge.La)ie(e);ge.La=[],ge.Ia=[],ge.Fa=[]},fb:function(e){var t=e.Ha;delete ge.Fa[t],ge.La.push(e),ge.Ia.splice(ge.Ia.indexOf(e),1),e.Ha=0,yt(t)},eb:function(){},Sa:function(){ge.Ta.forEach((e=>e()))},cb:e=>new Promise((t=>{e.onmessage=r=>{var n=(r=r.data).cmd;if(r.targetThread&&r.targetThread!=dt()){var a=ge.Fa[r.qb];a?a.postMessage(r,r.transferList):R(\'Internal error! Worker sent a message "\'+n+\'" to target pthread \'+r.targetThread+", but that thread no longer exists!")}else"checkMailbox"===n?He():"spawnThread"===n?ue(r):"cleanupThread"===n?se(r.thread):"killThread"===n?(r=r.thread,n=ge.Fa[r],delete ge.Fa[r],ie(n),yt(r),ge.Ia.splice(ge.Ia.indexOf(n),1),n.Ha=0):"cancelThread"===n?ge.Fa[r.thread].postMessage({cmd:"cancel"}):"loaded"===n?(e.loaded=!0,t(e)):"alert"===n?alert("Thread "+r.threadId+": "+r.text):"setimmediate"===r.target?e.postMessage(r):"callHandler"===n?c[r.handler](...r.args):n&&R("worker sent an unknown command "+n)},e.onerror=e=>{throw R("worker sent an error! "+e.filename+":"+e.lineno+": "+e.message),e},v&&(e.on("message",(function(t){e.onmessage({data:t})})),e.on("error",(function(t){e.onerror(t)})));var r,n=[];for(r of["onExit","onAbort","print","printErr"])c.hasOwnProperty(r)&&n.push(r);e.postMessage({cmd:"load",handlers:n,urlOrBlob:c.mainScriptUrlOrBlob||_scriptDir,wasmMemory:k,wasmModule:P})})),bb:function(e){e()},Xa:function(){var e=_("ort-wasm-threaded.worker.js");e=new Worker(e),ge.La.push(e)},Za:function(){return 0==ge.La.length&&(ge.Xa(),ge.cb(ge.La[0])),ge.La.pop()}};c.PThread=ge;var he=e=>{for(;0<e.length;)e.shift()(c)};function me(e){if(b)return qe(2,0,e);pe(e)}c.establishStackSpace=function(){var e=dt(),t=a()[e+52>>2>>>0];e=a()[e+56>>2>>>0],_t(t,t-e),St(t)};var ye=[];function ve(e){this.Oa=e-24,this.Wa=function(e){o()[this.Oa+4>>2>>>0]=e},this.Va=function(e){o()[this.Oa+8>>2>>>0]=e},this.Pa=function(e,t){this.Ua(),this.Wa(e),this.Va(t)},this.Ua=function(){o()[this.Oa+16>>2>>>0]=0}}function be(e,t,r,n){return b?qe(3,1,e,t,r,n):we(e,t,r,n)}function we(e,t,r,n){if(e>>>=0,t>>>=0,r>>>=0,n>>>=0,"undefined"==typeof SharedArrayBuffer)return R("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var a=[];return b&&0===a.length?be(e,t,r,n):(e={gb:r,Ha:e,Ya:n,mb:a},b?(e.ob="spawnThread",postMessage(e,a),0):ue(e))}function _e(e,t,r){return b?qe(4,1,e,t,r):0}function Oe(e,t){if(b)return qe(5,1,e,t)}c.invokeEntryPoint=function(e,t){var r=ye[e];r||(e>=ye.length&&(ye.length=e+1),ye[e]=r=z.get(e)),e=r(t),q()?ge.Ra(e):vt(e)};var Se=e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);127>=n?t++:2047>=n?t+=2:55296<=n&&57343>=n?(t+=4,++r):t+=3}return t},Ee=(e,t,r,n)=>{if(!(0<n))return 0;var a=r>>>=0;n=r+n-1;for(var o=0;o<e.length;++o){var i=e.charCodeAt(o);if(55296<=i&&57343>=i&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++o)),127>=i){if(r>=n)break;t[r++>>>0]=i}else{if(2047>=i){if(r+1>=n)break;t[r++>>>0]=192|i>>6}else{if(65535>=i){if(r+2>=n)break;t[r++>>>0]=224|i>>12}else{if(r+3>=n)break;t[r++>>>0]=240|i>>18,t[r++>>>0]=128|i>>12&63}t[r++>>>0]=128|i>>6&63}t[r++>>>0]=128|63&i}}return t[r>>>0]=0,r-a},Ae=(e,t,r)=>Ee(e,n(),t,r);function Te(e,t){if(b)return qe(6,1,e,t)}function Me(e,t,r){if(b)return qe(7,1,e,t,r)}function Re(e,t,r){return b?qe(8,1,e,t,r):0}function Fe(e,t){if(b)return qe(9,1,e,t)}function ke(e,t,r){if(b)return qe(10,1,e,t,r)}function Ce(e,t,r,n){if(b)return qe(11,1,e,t,r,n)}function Pe(e,t,r,n){if(b)return qe(12,1,e,t,r,n)}function De(e,t,r,n){if(b)return qe(13,1,e,t,r,n)}function xe(e){if(b)return qe(14,1,e)}function Ie(e,t){if(b)return qe(15,1,e,t)}function Ue(e,t,r){if(b)return qe(16,1,e,t,r)}var Le=e=>{if(!H)try{if(e(),!q())try{b?vt(D):pe(D)}catch(e){e instanceof oe||"unwind"==e||h(1,e)}}catch(e){e instanceof oe||"unwind"==e||h(1,e)}};function We(e){e>>>=0,"function"==typeof Atomics.nb&&(Atomics.nb(a(),e>>2,e).value.then(He),e+=128,Atomics.store(a(),e>>2,1))}function He(){var e=dt();e&&(We(e),Le((()=>bt())))}c.__emscripten_thread_mailbox_await=We,c.checkMailbox=He;var Ye=e=>0==e%4&&(0!=e%100||0==e%400),je=[0,31,60,91,121,152,182,213,244,274,305,335],ze=[0,31,59,90,120,151,181,212,243,273,304,334];function Ge(e,t,r,n,a,o,i,s){return b?qe(17,1,e,t,r,n,a,o,i,s):-52}function Ne(e,t,r,n,a,o,i){if(b)return qe(18,1,e,t,r,n,a,o,i)}var Be=e=>{var t=Se(e)+1,r=pt(t);return r&&Ae(e,r,t),r},$e=e=>{var t=Ot();return e=e(),St(t),e};function qe(e,t){var r=arguments.length-2,n=arguments;return $e((()=>{for(var a=Et(8*r),o=a>>3,s=0;s<r;s++){var u=n[2+s];i()[o+s>>>0]=u}return mt(e,r,a,t)}))}var Ve,Je=[],Xe={},Ke=()=>{if(!Ve){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:g||"./this.program"};for(e in Xe)void 0===Xe[e]?delete t[e]:t[e]=Xe[e];var r=[];for(e in t)r.push(`${e}=${t[e]}`);Ve=r}return Ve};function Ze(e,r){if(b)return qe(19,1,e,r);e>>>=0,r>>>=0;var n=0;return Ke().forEach((function(a,i){var s=r+n;for(i=o()[e+4*i>>2>>>0]=s,s=0;s<a.length;++s)t()[i++>>0>>>0]=a.charCodeAt(s);t()[i>>0>>>0]=0,n+=a.length+1})),0}function Qe(e,t){if(b)return qe(20,1,e,t);e>>>=0,t>>>=0;var r=Ke();o()[e>>2>>>0]=r.length;var n=0;return r.forEach((function(e){n+=e.length+1})),o()[t>>2>>>0]=n,0}function et(e){return b?qe(21,1,e):52}function tt(e,t,r,n){return b?qe(22,1,e,t,r,n):52}function rt(e,t,r,n,a){return b?qe(23,1,e,t,r,n,a):70}var nt=[null,[],[]];function at(e,t,r,a){if(b)return qe(24,1,e,t,r,a);t>>>=0,r>>>=0,a>>>=0;for(var i=0,s=0;s<r;s++){var u=o()[t>>2>>>0],c=o()[t+4>>2>>>0];t+=8;for(var l=0;l<c;l++){var f=n()[u+l>>>0],d=nt[e];0===f||10===f?((1===e?M:R)(le(d,0)),d.length=0):d.push(f)}i+=c}return o()[a>>2>>>0]=i,0}var ot=e=>(ot=(()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return e=>(e.set(crypto.getRandomValues(new Uint8Array(e.byteLength))),e);if(v)try{var e=r(760);if(e.randomFillSync)return t=>e.randomFillSync(t);var t=e.randomBytes;return e=>(e.set(t(e.byteLength)),e)}catch(e){}te("initRandomDevice")})())(e),it=[31,29,31,30,31,30,31,31,30,31,30,31],st=[31,28,31,30,31,30,31,31,30,31,30,31],ut=(e,r)=>{t().set(e,r>>>0)};function ct(e,t,r,n){function o(e,t,r){for(e="number"==typeof e?e.toString():e||"";e.length<t;)e=r[0]+e;return e}function i(e,t){return o(e,t,"0")}function s(e,t){function r(e){return 0>e?-1:0<e?1:0}var n;return 0===(n=r(e.getFullYear()-t.getFullYear()))&&0===(n=r(e.getMonth()-t.getMonth()))&&(n=r(e.getDate()-t.getDate())),n}function u(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function c(e){var t=e.Ja;for(e=new Date(new Date(e.Ka+1900,0,1).getTime());0<t;){var r=e.getMonth(),n=(Ye(e.getFullYear())?it:st)[r];if(!(t>n-e.getDate())){e.setDate(e.getDate()+t);break}t-=n-e.getDate()+1,e.setDate(1),11>r?e.setMonth(r+1):(e.setMonth(0),e.setFullYear(e.getFullYear()+1))}return r=new Date(e.getFullYear()+1,0,4),t=u(new Date(e.getFullYear(),0,4)),r=u(r),0>=s(t,e)?0>=s(r,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}e>>>=0,t>>>=0,r>>>=0,n>>>=0;var l=a()[n+40>>2>>>0];for(var f in n={kb:a()[n>>2>>>0],jb:a()[n+4>>2>>>0],Ma:a()[n+8>>2>>>0],Qa:a()[n+12>>2>>>0],Na:a()[n+16>>2>>>0],Ka:a()[n+20>>2>>>0],Ga:a()[n+24>>2>>>0],Ja:a()[n+28>>2>>>0],sb:a()[n+32>>2>>>0],ib:a()[n+36>>2>>>0],lb:l?fe(l):""},r=fe(r),l={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})r=r.replace(new RegExp(f,"g"),l[f]);var d="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),p="January February March April May June July August September October November December".split(" ");for(f in l={"%a":e=>d[e.Ga].substring(0,3),"%A":e=>d[e.Ga],"%b":e=>p[e.Na].substring(0,3),"%B":e=>p[e.Na],"%C":e=>i((e.Ka+1900)/100|0,2),"%d":e=>i(e.Qa,2),"%e":e=>o(e.Qa,2," "),"%g":e=>c(e).toString().substring(2),"%G":e=>c(e),"%H":e=>i(e.Ma,2),"%I":e=>(0==(e=e.Ma)?e=12:12<e&&(e-=12),i(e,2)),"%j":e=>{for(var t=0,r=0;r<=e.Na-1;t+=(Ye(e.Ka+1900)?it:st)[r++]);return i(e.Qa+t,3)},"%m":e=>i(e.Na+1,2),"%M":e=>i(e.jb,2),"%n":()=>"\\n","%p":e=>0<=e.Ma&&12>e.Ma?"AM":"PM","%S":e=>i(e.kb,2),"%t":()=>"\\t","%u":e=>e.Ga||7,"%U":e=>i(Math.floor((e.Ja+7-e.Ga)/7),2),"%V":e=>{var t=Math.floor((e.Ja+7-(e.Ga+6)%7)/7);if(2>=(e.Ga+371-e.Ja-2)%7&&t++,t)53==t&&(4==(r=(e.Ga+371-e.Ja)%7)||3==r&&Ye(e.Ka)||(t=1));else{t=52;var r=(e.Ga+7-e.Ja-1)%7;(4==r||5==r&&Ye(e.Ka%400-1))&&t++}return i(t,2)},"%w":e=>e.Ga,"%W":e=>i(Math.floor((e.Ja+7-(e.Ga+6)%7)/7),2),"%y":e=>(e.Ka+1900).toString().substring(2),"%Y":e=>e.Ka+1900,"%z":e=>{var t=0<=(e=e.ib);return e=Math.abs(e)/60,(t?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":e=>e.lb,"%%":()=>"%"},r=r.replace(/%%/g,"\\0\\0"),l)r.includes(f)&&(r=r.replace(new RegExp(f,"g"),l[f](n)));return f=function(e){var t=Array(Se(e)+1);return Ee(e,t,0,t.length),t}(r=r.replace(/\\0\\0/g,"%")),f.length>t?0:(ut(f,e),f.length-1)}ge.Pa();var lt=[null,de,me,be,_e,Oe,Te,Me,Re,Fe,ke,Ce,Pe,De,xe,Ie,Ue,Ge,Ne,Ze,Qe,et,tt,rt,at],ft={b:function(e,t,r){throw new ve(e>>>=0).Pa(t>>>0,r>>>0),e},N:function(e){gt(e>>>0,!y,1,!m,131072,!1),ge.Sa()},k:function(e){e>>>=0,b?postMessage({cmd:"cleanupThread",thread:e}):se(e)},I:we,h:_e,T:Oe,E:Te,G:Me,U:Re,R:Fe,J:ke,Q:Ce,o:Pe,F:De,C:xe,S:Ie,D:Ue,q:()=>!0,A:function(e,t){(e>>>=0)==t>>>0?setTimeout((()=>He())):b?postMessage({targetThread:e,cmd:"checkMailbox"}):(e=ge.Fa[e])&&e.postMessage({cmd:"checkMailbox"})},L:function(){return-1},M:We,p:function(e){v&&ge.Fa[e>>>0].ref()},t:function(e,t,r){e=t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN,r>>>=0,e=new Date(1e3*e),a()[r>>2>>>0]=e.getUTCSeconds(),a()[r+4>>2>>>0]=e.getUTCMinutes(),a()[r+8>>2>>>0]=e.getUTCHours(),a()[r+12>>2>>>0]=e.getUTCDate(),a()[r+16>>2>>>0]=e.getUTCMonth(),a()[r+20>>2>>>0]=e.getUTCFullYear()-1900,a()[r+24>>2>>>0]=e.getUTCDay(),e=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,a()[r+28>>2>>>0]=e},u:function(e,t,r){e=t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN,r>>>=0,e=new Date(1e3*e),a()[r>>2>>>0]=e.getSeconds(),a()[r+4>>2>>>0]=e.getMinutes(),a()[r+8>>2>>>0]=e.getHours(),a()[r+12>>2>>>0]=e.getDate(),a()[r+16>>2>>>0]=e.getMonth(),a()[r+20>>2>>>0]=e.getFullYear()-1900,a()[r+24>>2>>>0]=e.getDay(),t=(Ye(e.getFullYear())?je:ze)[e.getMonth()]+e.getDate()-1|0,a()[r+28>>2>>>0]=t,a()[r+36>>2>>>0]=-60*e.getTimezoneOffset(),t=new Date(e.getFullYear(),6,1).getTimezoneOffset();var n=new Date(e.getFullYear(),0,1).getTimezoneOffset();e=0|(t!=n&&e.getTimezoneOffset()==Math.min(n,t)),a()[r+32>>2>>>0]=e},v:function(e){e>>>=0;var t=new Date(a()[e+20>>2>>>0]+1900,a()[e+16>>2>>>0],a()[e+12>>2>>>0],a()[e+8>>2>>>0],a()[e+4>>2>>>0],a()[e>>2>>>0],0),r=a()[e+32>>2>>>0],n=t.getTimezoneOffset(),o=new Date(t.getFullYear(),6,1).getTimezoneOffset(),i=new Date(t.getFullYear(),0,1).getTimezoneOffset(),s=Math.min(i,o);return 0>r?a()[e+32>>2>>>0]=Number(o!=i&&s==n):0<r!=(s==n)&&(o=Math.max(i,o),t.setTime(t.getTime()+6e4*((0<r?s:o)-n))),a()[e+24>>2>>>0]=t.getDay(),r=(Ye(t.getFullYear())?je:ze)[t.getMonth()]+t.getDate()-1|0,a()[e+28>>2>>>0]=r,a()[e>>2>>>0]=t.getSeconds(),a()[e+4>>2>>>0]=t.getMinutes(),a()[e+8>>2>>>0]=t.getHours(),a()[e+12>>2>>>0]=t.getDate(),a()[e+16>>2>>>0]=t.getMonth(),a()[e+20>>2>>>0]=t.getYear(),e=t.getTime()/1e3,wt((J=e,1<=+Math.abs(J)?0<J?+Math.floor(J/4294967296)>>>0:~~+Math.ceil((J-+(~~J>>>0))/4294967296)>>>0:0)),e>>>0},r:Ge,s:Ne,z:function(e,t,r){function n(e){return(e=e.toTimeString().match(/\\(([A-Za-z ]+)\\)$/))?e[1]:"GMT"}e>>>=0,t>>>=0,r>>>=0;var i=(new Date).getFullYear(),s=new Date(i,0,1),u=new Date(i,6,1);i=s.getTimezoneOffset();var c=u.getTimezoneOffset(),l=Math.max(i,c);o()[e>>2>>>0]=60*l,a()[t>>2>>>0]=Number(i!=c),e=n(s),t=n(u),e=Be(e),t=Be(t),c<i?(o()[r>>2>>>0]=e,o()[r+4>>2>>>0]=t):(o()[r>>2>>>0]=t,o()[r+4>>2>>>0]=e)},c:()=>{te("")},l:function(){},i:function(){return Date.now()},V:()=>{throw $+=1,"unwind"},B:function(){return 4294901760},e:()=>performance.timeOrigin+performance.now(),f:function(){return v?r(993).cpus().length:navigator.hardwareConcurrency},K:function(e,t,r,n){for(ge.pb=t>>>0,Je.length=r,t=n>>>0>>3,n=0;n<r;n++)Je[n]=i()[t+n>>>0];return lt[e].apply(null,Je)},y:function(e){e>>>=0;var t=n().length;if(e<=t||4294901760<e)return!1;for(var r=1;4>=r;r*=2){var a=t*(1+.2/r);a=Math.min(a,e+100663296);var o=Math;a=Math.max(e,a);e:{o=o.min.call(o,4294901760,a+(65536-a%65536)%65536)-k.buffer.byteLength+65535>>>16;try{k.grow(o),Y();var i=1;break e}catch(e){}i=void 0}if(i)return!0}return!1},O:Ze,P:Qe,j:pe,g:et,n:tt,w:rt,m:at,x:function(e,t){return e>>>=0,t>>>=0,ot(n().subarray(e>>>0,e+t>>>0)),0},a:k||c.wasmMemory,H:ct,d:function(e,t,r,n){return ct(e>>>0,t>>>0,r>>>0,n>>>0)}};!function(){function e(e,t){return e=e.exports,C=e=function(e){var t=e=>()=>e()>>>0,r=e=>t=>e(t)>>>0;return(e=Object.assign({},e)).__errno_location=t(e.__errno_location),e.pthread_self=t(e.pthread_self),e.malloc=r(e.malloc),e.stackSave=t(e.stackSave),e.stackAlloc=r(e.stackAlloc),e}(e),ge.Ta.push(C.sa),z=C.ta,N.unshift(C.W),P=t,ee(),e}var t={a:ft};if(Q(),c.instantiateWasm)try{return c.instantiateWasm(t,e)}catch(e){R("Module.instantiateWasm callback failed with error: "+e),u(e)}(function(e,t){var r=V;return T||"function"!=typeof WebAssembly.instantiateStreaming||re(r)||r.startsWith("file://")||v||"function"!=typeof fetch?ae(r,e,t):fetch(r,{credentials:"same-origin"}).then((n=>WebAssembly.instantiateStreaming(n,e).then(t,(function(n){return R("wasm streaming compile failed: "+n),R("falling back to ArrayBuffer instantiation"),ae(r,e,t)}))))})(t,(function(t){e(t.instance,t.module)})).catch(u)}(),c._OrtInit=(e,t)=>(c._OrtInit=C.X)(e,t),c._OrtGetLastError=(e,t)=>(c._OrtGetLastError=C.Y)(e,t),c._OrtCreateSessionOptions=(e,t,r,n,a,o,i,s,u,l)=>(c._OrtCreateSessionOptions=C.Z)(e,t,r,n,a,o,i,s,u,l),c._OrtAppendExecutionProvider=(e,t)=>(c._OrtAppendExecutionProvider=C._)(e,t),c._OrtAddSessionConfigEntry=(e,t,r)=>(c._OrtAddSessionConfigEntry=C.$)(e,t,r),c._OrtReleaseSessionOptions=e=>(c._OrtReleaseSessionOptions=C.aa)(e),c._OrtCreateSession=(e,t,r)=>(c._OrtCreateSession=C.ba)(e,t,r),c._OrtReleaseSession=e=>(c._OrtReleaseSession=C.ca)(e),c._OrtGetInputOutputCount=(e,t,r)=>(c._OrtGetInputOutputCount=C.da)(e,t,r),c._OrtGetInputName=(e,t)=>(c._OrtGetInputName=C.ea)(e,t),c._OrtGetOutputName=(e,t)=>(c._OrtGetOutputName=C.fa)(e,t),c._OrtFree=e=>(c._OrtFree=C.ga)(e),c._OrtCreateTensor=(e,t,r,n,a)=>(c._OrtCreateTensor=C.ha)(e,t,r,n,a),c._OrtGetTensorData=(e,t,r,n,a)=>(c._OrtGetTensorData=C.ia)(e,t,r,n,a),c._OrtReleaseTensor=e=>(c._OrtReleaseTensor=C.ja)(e),c._OrtCreateRunOptions=(e,t,r,n)=>(c._OrtCreateRunOptions=C.ka)(e,t,r,n),c._OrtAddRunConfigEntry=(e,t,r)=>(c._OrtAddRunConfigEntry=C.la)(e,t,r),c._OrtReleaseRunOptions=e=>(c._OrtReleaseRunOptions=C.ma)(e),c._OrtRun=(e,t,r,n,a,o,i,s)=>(c._OrtRun=C.na)(e,t,r,n,a,o,i,s),c._OrtEndProfiling=e=>(c._OrtEndProfiling=C.oa)(e);var dt=c._pthread_self=()=>(dt=c._pthread_self=C.pa)(),pt=c._malloc=e=>(pt=c._malloc=C.qa)(e);c._free=e=>(c._free=C.ra)(e),c.__emscripten_tls_init=()=>(c.__emscripten_tls_init=C.sa)();var gt=c.__emscripten_thread_init=(e,t,r,n,a,o)=>(gt=c.__emscripten_thread_init=C.ua)(e,t,r,n,a,o);c.__emscripten_thread_crashed=()=>(c.__emscripten_thread_crashed=C.va)();var ht,mt=(e,t,r,n)=>(mt=C.wa)(e,t,r,n),yt=e=>(yt=C.xa)(e),vt=c.__emscripten_thread_exit=e=>(vt=c.__emscripten_thread_exit=C.ya)(e),bt=c.__emscripten_check_mailbox=()=>(bt=c.__emscripten_check_mailbox=C.za)(),wt=e=>(wt=C.Aa)(e),_t=(e,t)=>(_t=C.Ba)(e,t),Ot=()=>(Ot=C.Ca)(),St=e=>(St=C.Da)(e),Et=e=>(Et=C.Ea)(e);function At(){function e(){if(!ht&&(ht=!0,c.calledRun=!0,!H)&&(b||he(N),s(c),c.onRuntimeInitialized&&c.onRuntimeInitialized(),!b)){if(c.postRun)for("function"==typeof c.postRun&&(c.postRun=[c.postRun]);c.postRun.length;){var e=c.postRun.shift();B.unshift(e)}he(B)}}if(!(0<X))if(b)s(c),b||he(N),startWorker(c);else{if(c.preRun)for("function"==typeof c.preRun&&(c.preRun=[c.preRun]);c.preRun.length;)G.unshift(c.preRun.shift());he(G),0<X||(c.setStatus?(c.setStatus("Running..."),setTimeout((function(){setTimeout((function(){c.setStatus("")}),1),e()}),1)):e())}}if(c.keepRuntimeAlive=q,c.wasmMemory=k,c.stackAlloc=Et,c.stackSave=Ot,c.stackRestore=St,c.UTF8ToString=fe,c.stringToUTF8=Ae,c.lengthBytesUTF8=Se,c.ExitStatus=oe,c.PThread=ge,Z=function e(){ht||At(),ht||(Z=e)},c.preInit)for("function"==typeof c.preInit&&(c.preInit=[c.preInit]);0<c.preInit.length;)c.preInit.pop()();return At(),e.ready});e.exports=n},932:(e,t,r)=>{var _scriptDir,n=(_scriptDir="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,"undefined"!=typeof __filename&&(_scriptDir=_scriptDir||__filename),function(e={}){var t,n,a=e;a.ready=new Promise(((e,r)=>{t=e,n=r}));var o,i,s,u=Object.assign({},a),c="./this.program",l=(e,t)=>{throw t},f="object"==typeof window,d="function"==typeof importScripts,p="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,g="";if(p){var h=r(384),m=r(908);g=d?m.dirname(g)+"/":__dirname+"/",o=(e,t)=>(e=e.startsWith("file://")?new URL(e):m.normalize(e),h.readFileSync(e,t?void 0:"utf8")),s=e=>((e=o(e,!0)).buffer||(e=new Uint8Array(e)),e),i=(e,t,r,n=!0)=>{e=e.startsWith("file://")?new URL(e):m.normalize(e),h.readFile(e,n?void 0:"utf8",((e,a)=>{e?r(e):t(n?a.buffer:a)}))},!a.thisProgram&&1<process.argv.length&&(c=process.argv[1].replace(/\\\\/g,"/")),process.argv.slice(2),l=(e,t)=>{throw process.exitCode=e,t},a.inspect=()=>"[Emscripten Module object]"}else(f||d)&&(d?g=self.location.href:"undefined"!=typeof document&&document.currentScript&&(g=document.currentScript.src),_scriptDir&&(g=_scriptDir),g=0!==g.indexOf("blob:")?g.substr(0,g.replace(/[?#].*/,"").lastIndexOf("/")+1):"",o=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},d&&(s=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),i=(e,t,r)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==n.status&&n.response?t(n.response):r()},n.onerror=r,n.send(null)});var y,v=a.print||console.log.bind(console),b=a.printErr||console.error.bind(console);Object.assign(a,u),u=null,a.thisProgram&&(c=a.thisProgram),a.quit&&(l=a.quit),a.wasmBinary&&(y=a.wasmBinary);var w=a.noExitRuntime||!0;"object"!=typeof WebAssembly&&W("no native wasm support detected");var _,O,S,E,A,T,M=!1;function R(){var e=_.buffer;a.HEAP8=S=new Int8Array(e),a.HEAP16=new Int16Array(e),a.HEAP32=A=new Int32Array(e),a.HEAPU8=E=new Uint8Array(e),a.HEAPU16=new Uint16Array(e),a.HEAPU32=T=new Uint32Array(e),a.HEAPF32=new Float32Array(e),a.HEAPF64=new Float64Array(e)}var F=[],k=[],C=[];function P(){var e=a.preRun.shift();F.unshift(e)}var D,x,I=0,U=null,L=null;function W(e){throw a.onAbort&&a.onAbort(e),b(e="Aborted("+e+")"),M=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),n(e),e}function H(e){return e.startsWith("data:application/octet-stream;base64,")}if(!H(D="ort-wasm.wasm")){var Y=D;D=a.locateFile?a.locateFile(Y,g):g+Y}function j(e){if(e==D&&y)return new Uint8Array(y);if(s)return s(e);throw"both async and sync fetching of the wasm failed"}function z(e,t,r){return function(e){if(!y&&(f||d)){if("function"==typeof fetch&&!e.startsWith("file://"))return fetch(e,{credentials:"same-origin"}).then((t=>{if(!t.ok)throw"failed to load wasm binary file at \'"+e+"\'";return t.arrayBuffer()})).catch((()=>j(e)));if(i)return new Promise(((t,r)=>{i(e,(e=>t(new Uint8Array(e))),r)}))}return Promise.resolve().then((()=>j(e)))}(e).then((e=>WebAssembly.instantiate(e,t))).then((e=>e)).then(r,(e=>{b("failed to asynchronously prepare wasm: "+e),W(e)}))}function G(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var N=e=>{for(;0<e.length;)e.shift()(a)};function B(e){this.qa=e-24,this.va=function(e){T[this.qa+4>>2>>>0]=e},this.ua=function(e){T[this.qa+8>>2>>>0]=e},this.sa=function(e,t){this.ta(),this.va(e),this.ua(t)},this.ta=function(){T[this.qa+16>>2>>>0]=0}}var $,q="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,V=(e,t,r)=>{var n=(t>>>=0)+r;for(r=t;e[r]&&!(r>=n);)++r;if(16<r-t&&e.buffer&&q)return q.decode(e.subarray(t,r));for(n="";t<r;){var a=e[t++];if(128&a){var o=63&e[t++];if(192==(224&a))n+=String.fromCharCode((31&a)<<6|o);else{var i=63&e[t++];65536>(a=224==(240&a)?(15&a)<<12|o<<6|i:(7&a)<<18|o<<12|i<<6|63&e[t++])?n+=String.fromCharCode(a):(a-=65536,n+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else n+=String.fromCharCode(a)}return n},J=(e,t)=>(e>>>=0)?V(E,e,t):"",X=e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);127>=n?t++:2047>=n?t+=2:55296<=n&&57343>=n?(t+=4,++r):t+=3}return t},K=(e,t,r,n)=>{if(!(0<n))return 0;var a=r>>>=0;n=r+n-1;for(var o=0;o<e.length;++o){var i=e.charCodeAt(o);if(55296<=i&&57343>=i&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++o)),127>=i){if(r>=n)break;t[r++>>>0]=i}else{if(2047>=i){if(r+1>=n)break;t[r++>>>0]=192|i>>6}else{if(65535>=i){if(r+2>=n)break;t[r++>>>0]=224|i>>12}else{if(r+3>=n)break;t[r++>>>0]=240|i>>18,t[r++>>>0]=128|i>>12&63}t[r++>>>0]=128|i>>6&63}t[r++>>>0]=128|63&i}}return t[r>>>0]=0,r-a},Z=e=>0==e%4&&(0!=e%100||0==e%400),Q=[0,31,60,91,121,152,182,213,244,274,305,335],ee=[0,31,59,90,120,151,181,212,243,273,304,334],te=e=>{var t=X(e)+1,r=le(t);return r&&K(e,E,r,t),r},re={},ne=()=>{if(!$){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:c||"./this.program"};for(e in re)void 0===re[e]?delete t[e]:t[e]=re[e];var r=[];for(e in t)r.push(`${e}=${t[e]}`);$=r}return $},ae=[null,[],[]],oe=e=>(oe=(()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return e=>crypto.getRandomValues(e);if(p)try{var e=r(760);if(e.randomFillSync)return t=>e.randomFillSync(t);var t=e.randomBytes;return e=>(e.set(t(e.byteLength)),e)}catch(e){}W("initRandomDevice")})())(e),ie=[31,29,31,30,31,30,31,31,30,31,30,31],se=[31,28,31,30,31,30,31,31,30,31,30,31];function ue(e,t,r,n){function a(e,t,r){for(e="number"==typeof e?e.toString():e||"";e.length<t;)e=r[0]+e;return e}function o(e,t){return a(e,t,"0")}function i(e,t){function r(e){return 0>e?-1:0<e?1:0}var n;return 0===(n=r(e.getFullYear()-t.getFullYear()))&&0===(n=r(e.getMonth()-t.getMonth()))&&(n=r(e.getDate()-t.getDate())),n}function s(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function u(e){var t=e.ma;for(e=new Date(new Date(e.na+1900,0,1).getTime());0<t;){var r=e.getMonth(),n=(Z(e.getFullYear())?ie:se)[r];if(!(t>n-e.getDate())){e.setDate(e.getDate()+t);break}t-=n-e.getDate()+1,e.setDate(1),11>r?e.setMonth(r+1):(e.setMonth(0),e.setFullYear(e.getFullYear()+1))}return r=new Date(e.getFullYear()+1,0,4),t=s(new Date(e.getFullYear(),0,4)),r=s(r),0>=i(t,e)?0>=i(r,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}e>>>=0,t>>>=0,r>>>=0;var c=A[40+(n>>>=0)>>2>>>0];for(var l in n={ya:A[n>>2>>>0],xa:A[n+4>>2>>>0],oa:A[n+8>>2>>>0],ra:A[n+12>>2>>>0],pa:A[n+16>>2>>>0],na:A[n+20>>2>>>0],ha:A[n+24>>2>>>0],ma:A[n+28>>2>>>0],Aa:A[n+32>>2>>>0],wa:A[n+36>>2>>>0],za:c?J(c):""},r=J(r),c={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})r=r.replace(new RegExp(l,"g"),c[l]);var f="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),d="January February March April May June July August September October November December".split(" ");for(l in c={"%a":e=>f[e.ha].substring(0,3),"%A":e=>f[e.ha],"%b":e=>d[e.pa].substring(0,3),"%B":e=>d[e.pa],"%C":e=>o((e.na+1900)/100|0,2),"%d":e=>o(e.ra,2),"%e":e=>a(e.ra,2," "),"%g":e=>u(e).toString().substring(2),"%G":e=>u(e),"%H":e=>o(e.oa,2),"%I":e=>(0==(e=e.oa)?e=12:12<e&&(e-=12),o(e,2)),"%j":e=>{for(var t=0,r=0;r<=e.pa-1;t+=(Z(e.na+1900)?ie:se)[r++]);return o(e.ra+t,3)},"%m":e=>o(e.pa+1,2),"%M":e=>o(e.xa,2),"%n":()=>"\\n","%p":e=>0<=e.oa&&12>e.oa?"AM":"PM","%S":e=>o(e.ya,2),"%t":()=>"\\t","%u":e=>e.ha||7,"%U":e=>o(Math.floor((e.ma+7-e.ha)/7),2),"%V":e=>{var t=Math.floor((e.ma+7-(e.ha+6)%7)/7);if(2>=(e.ha+371-e.ma-2)%7&&t++,t)53==t&&(4==(r=(e.ha+371-e.ma)%7)||3==r&&Z(e.na)||(t=1));else{t=52;var r=(e.ha+7-e.ma-1)%7;(4==r||5==r&&Z(e.na%400-1))&&t++}return o(t,2)},"%w":e=>e.ha,"%W":e=>o(Math.floor((e.ma+7-(e.ha+6)%7)/7),2),"%y":e=>(e.na+1900).toString().substring(2),"%Y":e=>e.na+1900,"%z":e=>{var t=0<=(e=e.wa);return e=Math.abs(e)/60,(t?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":e=>e.za,"%%":()=>"%"},r=r.replace(/%%/g,"\\0\\0"),c)r.includes(l)&&(r=r.replace(new RegExp(l,"g"),c[l](n)));return l=function(e){var t=Array(X(e)+1);return K(e,t,0,t.length),t}(r=r.replace(/\\0\\0/g,"%")),l.length>t?0:(S.set(l,e>>>0),l.length-1)}var ce={a:function(e,t,r){throw new B(e>>>=0).sa(t>>>0,r>>>0),e},e:function(){return 0},I:function(){},y:function(){},A:function(){},K:function(){return 0},G:function(){},B:function(){},F:function(){},g:function(){},z:function(){},w:function(){},H:function(){},x:function(){},k:()=>!0,n:function(e,t,r){e=t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN,r>>>=0,e=new Date(1e3*e),A[r>>2>>>0]=e.getUTCSeconds(),A[r+4>>2>>>0]=e.getUTCMinutes(),A[r+8>>2>>>0]=e.getUTCHours(),A[r+12>>2>>>0]=e.getUTCDate(),A[r+16>>2>>>0]=e.getUTCMonth(),A[r+20>>2>>>0]=e.getUTCFullYear()-1900,A[r+24>>2>>>0]=e.getUTCDay(),A[r+28>>2>>>0]=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},o:function(e,t,r){e=t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN,r>>>=0,e=new Date(1e3*e),A[r>>2>>>0]=e.getSeconds(),A[r+4>>2>>>0]=e.getMinutes(),A[r+8>>2>>>0]=e.getHours(),A[r+12>>2>>>0]=e.getDate(),A[r+16>>2>>>0]=e.getMonth(),A[r+20>>2>>>0]=e.getFullYear()-1900,A[r+24>>2>>>0]=e.getDay(),A[r+28>>2>>>0]=(Z(e.getFullYear())?Q:ee)[e.getMonth()]+e.getDate()-1|0,A[r+36>>2>>>0]=-60*e.getTimezoneOffset(),t=new Date(e.getFullYear(),6,1).getTimezoneOffset();var n=new Date(e.getFullYear(),0,1).getTimezoneOffset();A[r+32>>2>>>0]=0|(t!=n&&e.getTimezoneOffset()==Math.min(n,t))},p:function(e){e>>>=0;var t=new Date(A[e+20>>2>>>0]+1900,A[e+16>>2>>>0],A[e+12>>2>>>0],A[e+8>>2>>>0],A[e+4>>2>>>0],A[e>>2>>>0],0),r=A[e+32>>2>>>0],n=t.getTimezoneOffset(),a=new Date(t.getFullYear(),6,1).getTimezoneOffset(),o=new Date(t.getFullYear(),0,1).getTimezoneOffset(),i=Math.min(o,a);return 0>r?A[e+32>>2>>>0]=Number(a!=o&&i==n):0<r!=(i==n)&&(a=Math.max(o,a),t.setTime(t.getTime()+6e4*((0<r?i:a)-n))),A[e+24>>2>>>0]=t.getDay(),A[e+28>>2>>>0]=(Z(t.getFullYear())?Q:ee)[t.getMonth()]+t.getDate()-1|0,A[e>>2>>>0]=t.getSeconds(),A[e+4>>2>>>0]=t.getMinutes(),A[e+8>>2>>>0]=t.getHours(),A[e+12>>2>>>0]=t.getDate(),A[e+16>>2>>>0]=t.getMonth(),A[e+20>>2>>>0]=t.getYear(),e=t.getTime()/1e3,de((x=e,1<=+Math.abs(x)?0<x?+Math.floor(x/4294967296)>>>0:~~+Math.ceil((x-+(~~x>>>0))/4294967296)>>>0:0)),e>>>0},l:function(){return-52},m:function(){},u:function(e,t,r){function n(e){return(e=e.toTimeString().match(/\\(([A-Za-z ]+)\\)$/))?e[1]:"GMT"}r>>>=0;var a=(new Date).getFullYear(),o=new Date(a,0,1),i=new Date(a,6,1);a=o.getTimezoneOffset();var s=i.getTimezoneOffset();T[e>>>0>>2>>>0]=60*Math.max(a,s),A[t>>>0>>2>>>0]=Number(a!=s),e=n(o),t=n(i),e=te(e),t=te(t),s<a?(T[r>>2>>>0]=e,T[r+4>>2>>>0]=t):(T[r>>2>>>0]=t,T[r+4>>2>>>0]=e)},d:()=>{W("")},h:function(){return Date.now()},v:function(){return 4294901760},b:()=>performance.now(),J:function(e,t,r){return t>>>=0,E.copyWithin(e>>>0>>>0,t>>>0,t+(r>>>0)>>>0)},t:function(e){e>>>=0;var t=E.length;if(4294901760<e)return!1;for(var r=1;4>=r;r*=2){var n=t*(1+.2/r);n=Math.min(n,e+100663296);var a=Math;n=Math.max(e,n);e:{a=a.min.call(a,4294901760,n+(65536-n%65536)%65536)-_.buffer.byteLength+65535>>>16;try{_.grow(a),R();var o=1;break e}catch(e){}o=void 0}if(o)return!0}return!1},D:function(e,t){e>>>=0,t>>>=0;var r=0;return ne().forEach((function(n,a){var o=t+r;for(a=T[e+4*a>>2>>>0]=o,o=0;o<n.length;++o)S[a++>>0>>>0]=n.charCodeAt(o);S[a>>0>>>0]=0,r+=n.length+1})),0},E:function(e,t){e>>>=0,t>>>=0;var r=ne();T[e>>2>>>0]=r.length;var n=0;return r.forEach((function(e){n+=e.length+1})),T[t>>2>>>0]=n,0},s:e=>{w||(a.onExit&&a.onExit(e),M=!0),l(e,new G(e))},f:()=>52,j:function(){return 52},q:function(){return 70},i:function(e,t,r,n){t>>>=0,r>>>=0,n>>>=0;for(var a=0,o=0;o<r;o++){var i=T[t>>2>>>0],s=T[t+4>>2>>>0];t+=8;for(var u=0;u<s;u++){var c=E[i+u>>>0],l=ae[e];0===c||10===c?((1===e?v:b)(V(l,0)),l.length=0):l.push(c)}a+=s}return T[n>>2>>>0]=a,0},r:function(e,t){return e>>>=0,oe(E.subarray(e>>>0,e+(t>>>0)>>>0)),0},C:ue,c:function(e,t,r,n){return ue(e>>>0,t>>>0,r>>>0,n>>>0)}};!function(){function e(e){if(e=e.exports,O=e=function(e){var t=e=>()=>e()>>>0,r=e=>t=>e(t)>>>0;return(e=Object.assign({},e)).__errno_location=t(e.__errno_location),e.malloc=r(e.malloc),e.stackSave=t(e.stackSave),e.stackAlloc=r(e.stackAlloc),e}(e),_=O.L,R(),k.unshift(O.M),I--,a.monitorRunDependencies&&a.monitorRunDependencies(I),0==I&&(null!==U&&(clearInterval(U),U=null),L)){var t=L;L=null,t()}return e}var t={a:ce};if(I++,a.monitorRunDependencies&&a.monitorRunDependencies(I),a.instantiateWasm)try{return a.instantiateWasm(t,e)}catch(e){b("Module.instantiateWasm callback failed with error: "+e),n(e)}(function(e,t){var r=D;return y||"function"!=typeof WebAssembly.instantiateStreaming||H(r)||r.startsWith("file://")||p||"function"!=typeof fetch?z(r,e,t):fetch(r,{credentials:"same-origin"}).then((n=>WebAssembly.instantiateStreaming(n,e).then(t,(function(n){return b("wasm streaming compile failed: "+n),b("falling back to ArrayBuffer instantiation"),z(r,e,t)}))))})(t,(function(t){e(t.instance)})).catch(n)}(),a._OrtInit=(e,t)=>(a._OrtInit=O.N)(e,t),a._OrtGetLastError=(e,t)=>(a._OrtGetLastError=O.O)(e,t),a._OrtCreateSessionOptions=(e,t,r,n,o,i,s,u,c,l)=>(a._OrtCreateSessionOptions=O.P)(e,t,r,n,o,i,s,u,c,l),a._OrtAppendExecutionProvider=(e,t)=>(a._OrtAppendExecutionProvider=O.Q)(e,t),a._OrtAddSessionConfigEntry=(e,t,r)=>(a._OrtAddSessionConfigEntry=O.R)(e,t,r),a._OrtReleaseSessionOptions=e=>(a._OrtReleaseSessionOptions=O.S)(e),a._OrtCreateSession=(e,t,r)=>(a._OrtCreateSession=O.T)(e,t,r),a._OrtReleaseSession=e=>(a._OrtReleaseSession=O.U)(e),a._OrtGetInputOutputCount=(e,t,r)=>(a._OrtGetInputOutputCount=O.V)(e,t,r),a._OrtGetInputName=(e,t)=>(a._OrtGetInputName=O.W)(e,t),a._OrtGetOutputName=(e,t)=>(a._OrtGetOutputName=O.X)(e,t),a._OrtFree=e=>(a._OrtFree=O.Y)(e),a._OrtCreateTensor=(e,t,r,n,o)=>(a._OrtCreateTensor=O.Z)(e,t,r,n,o),a._OrtGetTensorData=(e,t,r,n,o)=>(a._OrtGetTensorData=O._)(e,t,r,n,o),a._OrtReleaseTensor=e=>(a._OrtReleaseTensor=O.$)(e),a._OrtCreateRunOptions=(e,t,r,n)=>(a._OrtCreateRunOptions=O.aa)(e,t,r,n),a._OrtAddRunConfigEntry=(e,t,r)=>(a._OrtAddRunConfigEntry=O.ba)(e,t,r),a._OrtReleaseRunOptions=e=>(a._OrtReleaseRunOptions=O.ca)(e),a._OrtRun=(e,t,r,n,o,i,s,u)=>(a._OrtRun=O.da)(e,t,r,n,o,i,s,u),a._OrtEndProfiling=e=>(a._OrtEndProfiling=O.ea)(e);var le=a._malloc=e=>(le=a._malloc=O.fa)(e);a._free=e=>(a._free=O.ga)(e);var fe,de=e=>(de=O.ia)(e),pe=()=>(pe=O.ja)(),ge=e=>(ge=O.ka)(e),he=e=>(he=O.la)(e);function me(){function e(){if(!fe&&(fe=!0,a.calledRun=!0,!M)){if(N(k),t(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),a.postRun)for("function"==typeof a.postRun&&(a.postRun=[a.postRun]);a.postRun.length;){var e=a.postRun.shift();C.unshift(e)}N(C)}}if(!(0<I)){if(a.preRun)for("function"==typeof a.preRun&&(a.preRun=[a.preRun]);a.preRun.length;)P();N(F),0<I||(a.setStatus?(a.setStatus("Running..."),setTimeout((function(){setTimeout((function(){a.setStatus("")}),1),e()}),1)):e())}}if(a.stackAlloc=he,a.stackSave=pe,a.stackRestore=ge,a.UTF8ToString=J,a.stringToUTF8=(e,t,r)=>K(e,E,t,r),a.lengthBytesUTF8=X,L=function e(){fe||me(),fe||(L=e)},a.preInit)for("function"==typeof a.preInit&&(a.preInit=[a.preInit]);0<a.preInit.length;)a.preInit.pop()();return me(),e.ready});e.exports=n},154:e=>{"use strict";e.exports=\'"use strict";var e={},a="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node;if(a){var r=require("worker_threads"),t=r.parentPort;t.on("message",(e=>onmessage({data:e})));var s=require("fs");Object.assign(global,{self:global,require:require,Module:e,location:{href:__filename},Worker:r.Worker,importScripts:e=>(0,eval)(s.readFileSync(e,"utf8")+"//# sourceURL="+e),postMessage:e=>t.postMessage(e),performance:global.performance||{now:Date.now}})}var o=!1,d=function(){var e=Array.prototype.slice.call(arguments).join(" ");a?s.writeSync(2,e+"\\\\n"):console.error(e)};self.alert=function(){var a=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:a,threadId:e._pthread_self()})},e.instantiateWasm=(a,r)=>{var t=e.wasmModule;return e.wasmModule=null,r(new WebAssembly.Instance(t,a))},self.onunhandledrejection=e=>{throw e.reason??e},self.onmessage=function a(r){try{if("load"===r.data.cmd){let s=[];self.onmessage=e=>s.push(e),self.startWorker=r=>{e=r,postMessage({cmd:"loaded"});for(let e of s)a(e);self.onmessage=a},e.wasmModule=r.data.wasmModule;for(const a of r.data.handlers)e[a]=(...e)=>{postMessage({cmd:"callHandler",handler:a,args:e})};if(e.wasmMemory=r.data.wasmMemory,e.buffer=e.wasmMemory.buffer,e.ENVIRONMENT_IS_PTHREAD=!0,"string"==typeof r.data.urlOrBlob)importScripts(r.data.urlOrBlob);else{var t=URL.createObjectURL(r.data.urlOrBlob);importScripts(t),URL.revokeObjectURL(t)}ortWasmThreaded(e)}else if("run"===r.data.cmd){e.__emscripten_thread_init(r.data.pthread_ptr,0,0,1),e.__emscripten_thread_mailbox_await(r.data.pthread_ptr),e.establishStackSpace(),e.PThread.receiveObjectTransfer(r.data),e.PThread.threadInitTLS(),o||(o=!0);try{e.invokeEntryPoint(r.data.start_routine,r.data.arg)}catch(e){if("unwind"!=e)throw e}}else"cancel"===r.data.cmd?e._pthread_self()&&e.__emscripten_thread_exit(-1):"setimmediate"===r.data.target||("checkMailbox"===r.data.cmd?o&&e.checkMailbox():r.data.cmd&&(d("worker.js received unknown command "+r.data.cmd),d(r.data)))}catch(a){throw e.__emscripten_thread_crashed&&e.__emscripten_thread_crashed(),a}};\\n\'},760:()=>{},384:()=>{},993:()=>{},908:()=>{},953:()=>{},925:()=>{},449:()=>{}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,r),o.exports}(()=>{"use strict";const e=r(259),t=r(263);self.onmessage=r=>{switch(r.data.type){case"init-wasm":try{(0,t.initializeWebAssembly)(r.data.in).then((()=>postMessage({type:"init-wasm"})),(e=>postMessage({type:"init-wasm",err:e})))}catch(e){postMessage({type:"init-wasm",err:e})}break;case"init-ort":try{(0,e.initRuntime)(r.data.in).then((()=>postMessage({type:"init-ort"})),(e=>postMessage({type:"init-ort",err:e}))),postMessage({type:"init-ort"})}catch(e){postMessage({type:"init-ort",err:e})}break;case"create_allocate":try{const{model:t}=r.data.in,n=(0,e.createSessionAllocate)(t);postMessage({type:"create_allocate",out:n})}catch(e){postMessage({type:"create_allocate",err:e})}break;case"create_finalize":try{const{modeldata:t,options:n}=r.data.in,a=(0,e.createSessionFinalize)(t,n);postMessage({type:"create_finalize",out:a})}catch(e){postMessage({type:"create_finalize",err:e})}break;case"create":try{const{model:t,options:n}=r.data.in,a=(0,e.createSession)(t,n);postMessage({type:"create",out:a})}catch(e){postMessage({type:"create",err:e})}break;case"release":try{const t=r.data.in;(0,e.releaseSession)(t),postMessage({type:"release"})}catch(e){postMessage({type:"release",err:e})}break;case"run":try{const{sessionId:t,inputIndices:n,inputs:a,outputIndices:o,options:i}=r.data.in;(0,e.run)(t,n,a,o,i).then((t=>{postMessage({type:"run",out:t},(0,e.extractTransferableBuffers)(t))}),(e=>{postMessage({type:"run",err:e})}))}catch(e){postMessage({type:"run",err:e})}break;case"end-profiling":try{const t=r.data.in;(0,e.endProfiling)(t),postMessage({type:"end-profiling"})}catch(e){postMessage({type:"end-profiling",err:e})}}}})()})();\n',"Worker",void 0,void 0)}},6614:c=>{c.exports=function(e,n,r,i){var o=self||window;try{try{var a;try{a=new o.Blob([e])}catch{(a=new(o.BlobBuilder||o.WebKitBlobBuilder||o.MozBlobBuilder||o.MSBlobBuilder)).append(e),a=a.getBlob()}var d=o.URL||o.webkitURL,f=d.createObjectURL(a),h=new o[n](f,r);return d.revokeObjectURL(f),h}catch{return new o[n]("data:application/javascript,".concat(encodeURIComponent(e)),r)}}catch{if(!i)throw Error("Inline worker is not supported");return new o[n](i,r)}}},2446:(c,e,n)=>{var r,i,o,a=n(2100),d=a.Reader,f=a.Writer,h=a.util,p=a.roots.default||(a.roots.default={});p.onnx=((o={}).Version=(r={},(i=Object.create(r))[r[0]="_START_VERSION"]=0,i[r[1]="IR_VERSION_2017_10_10"]=1,i[r[2]="IR_VERSION_2017_10_30"]=2,i[r[3]="IR_VERSION_2017_11_3"]=3,i[r[4]="IR_VERSION_2019_1_22"]=4,i[r[5]="IR_VERSION_2019_3_18"]=5,i[r[6]="IR_VERSION_2019_9_19"]=6,i[r[7]="IR_VERSION_2020_5_8"]=7,i[r[8]="IR_VERSION_2021_7_30"]=8,i[r[9]="IR_VERSION"]=9,i),o.AttributeProto=function(){function s(t){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],this.sparseTensors=[],this.typeProtos=[],t)for(var l=Object.keys(t),u=0;u<l.length;++u)t[l[u]]!=null&&(this[l[u]]=t[l[u]])}return s.prototype.name="",s.prototype.refAttrName="",s.prototype.docString="",s.prototype.type=0,s.prototype.f=0,s.prototype.i=h.Long?h.Long.fromBits(0,0,!1):0,s.prototype.s=h.newBuffer([]),s.prototype.t=null,s.prototype.g=null,s.prototype.sparseTensor=null,s.prototype.tp=null,s.prototype.floats=h.emptyArray,s.prototype.ints=h.emptyArray,s.prototype.strings=h.emptyArray,s.prototype.tensors=h.emptyArray,s.prototype.graphs=h.emptyArray,s.prototype.sparseTensors=h.emptyArray,s.prototype.typeProtos=h.emptyArray,s.create=function(t){return new s(t)},s.encode=function(t,l){if(l||(l=f.create()),t.name!=null&&Object.hasOwnProperty.call(t,"name")&&l.uint32(10).string(t.name),t.f!=null&&Object.hasOwnProperty.call(t,"f")&&l.uint32(21).float(t.f),t.i!=null&&Object.hasOwnProperty.call(t,"i")&&l.uint32(24).int64(t.i),t.s!=null&&Object.hasOwnProperty.call(t,"s")&&l.uint32(34).bytes(t.s),t.t!=null&&Object.hasOwnProperty.call(t,"t")&&p.onnx.TensorProto.encode(t.t,l.uint32(42).fork()).ldelim(),t.g!=null&&Object.hasOwnProperty.call(t,"g")&&p.onnx.GraphProto.encode(t.g,l.uint32(50).fork()).ldelim(),t.floats!=null&&t.floats.length){l.uint32(58).fork();for(var u=0;u<t.floats.length;++u)l.float(t.floats[u]);l.ldelim()}if(t.ints!=null&&t.ints.length){for(l.uint32(66).fork(),u=0;u<t.ints.length;++u)l.int64(t.ints[u]);l.ldelim()}if(t.strings!=null&&t.strings.length)for(u=0;u<t.strings.length;++u)l.uint32(74).bytes(t.strings[u]);if(t.tensors!=null&&t.tensors.length)for(u=0;u<t.tensors.length;++u)p.onnx.TensorProto.encode(t.tensors[u],l.uint32(82).fork()).ldelim();if(t.graphs!=null&&t.graphs.length)for(u=0;u<t.graphs.length;++u)p.onnx.GraphProto.encode(t.graphs[u],l.uint32(90).fork()).ldelim();if(t.docString!=null&&Object.hasOwnProperty.call(t,"docString")&&l.uint32(106).string(t.docString),t.tp!=null&&Object.hasOwnProperty.call(t,"tp")&&p.onnx.TypeProto.encode(t.tp,l.uint32(114).fork()).ldelim(),t.typeProtos!=null&&t.typeProtos.length)for(u=0;u<t.typeProtos.length;++u)p.onnx.TypeProto.encode(t.typeProtos[u],l.uint32(122).fork()).ldelim();if(t.type!=null&&Object.hasOwnProperty.call(t,"type")&&l.uint32(160).int32(t.type),t.refAttrName!=null&&Object.hasOwnProperty.call(t,"refAttrName")&&l.uint32(170).string(t.refAttrName),t.sparseTensor!=null&&Object.hasOwnProperty.call(t,"sparseTensor")&&p.onnx.SparseTensorProto.encode(t.sparseTensor,l.uint32(178).fork()).ldelim(),t.sparseTensors!=null&&t.sparseTensors.length)for(u=0;u<t.sparseTensors.length;++u)p.onnx.SparseTensorProto.encode(t.sparseTensors[u],l.uint32(186).fork()).ldelim();return l},s.encodeDelimited=function(t,l){return this.encode(t,l).ldelim()},s.decode=function(t,l){t instanceof d||(t=d.create(t));for(var u=l===void 0?t.len:t.pos+l,g=new p.onnx.AttributeProto;t.pos<u;){var m=t.uint32();switch(m>>>3){case 1:g.name=t.string();break;case 21:g.refAttrName=t.string();break;case 13:g.docString=t.string();break;case 20:g.type=t.int32();break;case 2:g.f=t.float();break;case 3:g.i=t.int64();break;case 4:g.s=t.bytes();break;case 5:g.t=p.onnx.TensorProto.decode(t,t.uint32());break;case 6:g.g=p.onnx.GraphProto.decode(t,t.uint32());break;case 22:g.sparseTensor=p.onnx.SparseTensorProto.decode(t,t.uint32());break;case 14:g.tp=p.onnx.TypeProto.decode(t,t.uint32());break;case 7:if(g.floats&&g.floats.length||(g.floats=[]),(7&m)==2)for(var _=t.uint32()+t.pos;t.pos<_;)g.floats.push(t.float());else g.floats.push(t.float());break;case 8:if(g.ints&&g.ints.length||(g.ints=[]),(7&m)==2)for(_=t.uint32()+t.pos;t.pos<_;)g.ints.push(t.int64());else g.ints.push(t.int64());break;case 9:g.strings&&g.strings.length||(g.strings=[]),g.strings.push(t.bytes());break;case 10:g.tensors&&g.tensors.length||(g.tensors=[]),g.tensors.push(p.onnx.TensorProto.decode(t,t.uint32()));break;case 11:g.graphs&&g.graphs.length||(g.graphs=[]),g.graphs.push(p.onnx.GraphProto.decode(t,t.uint32()));break;case 23:g.sparseTensors&&g.sparseTensors.length||(g.sparseTensors=[]),g.sparseTensors.push(p.onnx.SparseTensorProto.decode(t,t.uint32()));break;case 15:g.typeProtos&&g.typeProtos.length||(g.typeProtos=[]),g.typeProtos.push(p.onnx.TypeProto.decode(t,t.uint32()));break;default:t.skipType(7&m)}}return g},s.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},s.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.name!=null&&t.hasOwnProperty("name")&&!h.isString(t.name))return"name: string expected";if(t.refAttrName!=null&&t.hasOwnProperty("refAttrName")&&!h.isString(t.refAttrName))return"refAttrName: string expected";if(t.docString!=null&&t.hasOwnProperty("docString")&&!h.isString(t.docString))return"docString: string expected";if(t.type!=null&&t.hasOwnProperty("type"))switch(t.type){default:return"type: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 11:case 13:case 6:case 7:case 8:case 9:case 10:case 12:case 14:}if(t.f!=null&&t.hasOwnProperty("f")&&typeof t.f!="number")return"f: number expected";if(t.i!=null&&t.hasOwnProperty("i")&&!(h.isInteger(t.i)||t.i&&h.isInteger(t.i.low)&&h.isInteger(t.i.high)))return"i: integer|Long expected";if(t.s!=null&&t.hasOwnProperty("s")&&!(t.s&&typeof t.s.length=="number"||h.isString(t.s)))return"s: buffer expected";if(t.t!=null&&t.hasOwnProperty("t")&&(u=p.onnx.TensorProto.verify(t.t)))return"t."+u;if(t.g!=null&&t.hasOwnProperty("g")&&(u=p.onnx.GraphProto.verify(t.g)))return"g."+u;if(t.sparseTensor!=null&&t.hasOwnProperty("sparseTensor")&&(u=p.onnx.SparseTensorProto.verify(t.sparseTensor)))return"sparseTensor."+u;if(t.tp!=null&&t.hasOwnProperty("tp")&&(u=p.onnx.TypeProto.verify(t.tp)))return"tp."+u;if(t.floats!=null&&t.hasOwnProperty("floats")){if(!Array.isArray(t.floats))return"floats: array expected";for(var l=0;l<t.floats.length;++l)if(typeof t.floats[l]!="number")return"floats: number[] expected"}if(t.ints!=null&&t.hasOwnProperty("ints")){if(!Array.isArray(t.ints))return"ints: array expected";for(l=0;l<t.ints.length;++l)if(!(h.isInteger(t.ints[l])||t.ints[l]&&h.isInteger(t.ints[l].low)&&h.isInteger(t.ints[l].high)))return"ints: integer|Long[] expected"}if(t.strings!=null&&t.hasOwnProperty("strings")){if(!Array.isArray(t.strings))return"strings: array expected";for(l=0;l<t.strings.length;++l)if(!(t.strings[l]&&typeof t.strings[l].length=="number"||h.isString(t.strings[l])))return"strings: buffer[] expected"}if(t.tensors!=null&&t.hasOwnProperty("tensors")){if(!Array.isArray(t.tensors))return"tensors: array expected";for(l=0;l<t.tensors.length;++l)if(u=p.onnx.TensorProto.verify(t.tensors[l]))return"tensors."+u}if(t.graphs!=null&&t.hasOwnProperty("graphs")){if(!Array.isArray(t.graphs))return"graphs: array expected";for(l=0;l<t.graphs.length;++l)if(u=p.onnx.GraphProto.verify(t.graphs[l]))return"graphs."+u}if(t.sparseTensors!=null&&t.hasOwnProperty("sparseTensors")){if(!Array.isArray(t.sparseTensors))return"sparseTensors: array expected";for(l=0;l<t.sparseTensors.length;++l)if(u=p.onnx.SparseTensorProto.verify(t.sparseTensors[l]))return"sparseTensors."+u}if(t.typeProtos!=null&&t.hasOwnProperty("typeProtos")){if(!Array.isArray(t.typeProtos))return"typeProtos: array expected";for(l=0;l<t.typeProtos.length;++l){var u;if(u=p.onnx.TypeProto.verify(t.typeProtos[l]))return"typeProtos."+u}}return null},s.fromObject=function(t){if(t instanceof p.onnx.AttributeProto)return t;var l=new p.onnx.AttributeProto;switch(t.name!=null&&(l.name=String(t.name)),t.refAttrName!=null&&(l.refAttrName=String(t.refAttrName)),t.docString!=null&&(l.docString=String(t.docString)),t.type){default:if(typeof t.type=="number"){l.type=t.type;break}break;case"UNDEFINED":case 0:l.type=0;break;case"FLOAT":case 1:l.type=1;break;case"INT":case 2:l.type=2;break;case"STRING":case 3:l.type=3;break;case"TENSOR":case 4:l.type=4;break;case"GRAPH":case 5:l.type=5;break;case"SPARSE_TENSOR":case 11:l.type=11;break;case"TYPE_PROTO":case 13:l.type=13;break;case"FLOATS":case 6:l.type=6;break;case"INTS":case 7:l.type=7;break;case"STRINGS":case 8:l.type=8;break;case"TENSORS":case 9:l.type=9;break;case"GRAPHS":case 10:l.type=10;break;case"SPARSE_TENSORS":case 12:l.type=12;break;case"TYPE_PROTOS":case 14:l.type=14}if(t.f!=null&&(l.f=Number(t.f)),t.i!=null&&(h.Long?(l.i=h.Long.fromValue(t.i)).unsigned=!1:typeof t.i=="string"?l.i=parseInt(t.i,10):typeof t.i=="number"?l.i=t.i:typeof t.i=="object"&&(l.i=new h.LongBits(t.i.low>>>0,t.i.high>>>0).toNumber())),t.s!=null&&(typeof t.s=="string"?h.base64.decode(t.s,l.s=h.newBuffer(h.base64.length(t.s)),0):t.s.length>=0&&(l.s=t.s)),t.t!=null){if(typeof t.t!="object")throw TypeError(".onnx.AttributeProto.t: object expected");l.t=p.onnx.TensorProto.fromObject(t.t)}if(t.g!=null){if(typeof t.g!="object")throw TypeError(".onnx.AttributeProto.g: object expected");l.g=p.onnx.GraphProto.fromObject(t.g)}if(t.sparseTensor!=null){if(typeof t.sparseTensor!="object")throw TypeError(".onnx.AttributeProto.sparseTensor: object expected");l.sparseTensor=p.onnx.SparseTensorProto.fromObject(t.sparseTensor)}if(t.tp!=null){if(typeof t.tp!="object")throw TypeError(".onnx.AttributeProto.tp: object expected");l.tp=p.onnx.TypeProto.fromObject(t.tp)}if(t.floats){if(!Array.isArray(t.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");l.floats=[];for(var u=0;u<t.floats.length;++u)l.floats[u]=Number(t.floats[u])}if(t.ints){if(!Array.isArray(t.ints))throw TypeError(".onnx.AttributeProto.ints: array expected");for(l.ints=[],u=0;u<t.ints.length;++u)h.Long?(l.ints[u]=h.Long.fromValue(t.ints[u])).unsigned=!1:typeof t.ints[u]=="string"?l.ints[u]=parseInt(t.ints[u],10):typeof t.ints[u]=="number"?l.ints[u]=t.ints[u]:typeof t.ints[u]=="object"&&(l.ints[u]=new h.LongBits(t.ints[u].low>>>0,t.ints[u].high>>>0).toNumber())}if(t.strings){if(!Array.isArray(t.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");for(l.strings=[],u=0;u<t.strings.length;++u)typeof t.strings[u]=="string"?h.base64.decode(t.strings[u],l.strings[u]=h.newBuffer(h.base64.length(t.strings[u])),0):t.strings[u].length>=0&&(l.strings[u]=t.strings[u])}if(t.tensors){if(!Array.isArray(t.tensors))throw TypeError(".onnx.AttributeProto.tensors: array expected");for(l.tensors=[],u=0;u<t.tensors.length;++u){if(typeof t.tensors[u]!="object")throw TypeError(".onnx.AttributeProto.tensors: object expected");l.tensors[u]=p.onnx.TensorProto.fromObject(t.tensors[u])}}if(t.graphs){if(!Array.isArray(t.graphs))throw TypeError(".onnx.AttributeProto.graphs: array expected");for(l.graphs=[],u=0;u<t.graphs.length;++u){if(typeof t.graphs[u]!="object")throw TypeError(".onnx.AttributeProto.graphs: object expected");l.graphs[u]=p.onnx.GraphProto.fromObject(t.graphs[u])}}if(t.sparseTensors){if(!Array.isArray(t.sparseTensors))throw TypeError(".onnx.AttributeProto.sparseTensors: array expected");for(l.sparseTensors=[],u=0;u<t.sparseTensors.length;++u){if(typeof t.sparseTensors[u]!="object")throw TypeError(".onnx.AttributeProto.sparseTensors: object expected");l.sparseTensors[u]=p.onnx.SparseTensorProto.fromObject(t.sparseTensors[u])}}if(t.typeProtos){if(!Array.isArray(t.typeProtos))throw TypeError(".onnx.AttributeProto.typeProtos: array expected");for(l.typeProtos=[],u=0;u<t.typeProtos.length;++u){if(typeof t.typeProtos[u]!="object")throw TypeError(".onnx.AttributeProto.typeProtos: object expected");l.typeProtos[u]=p.onnx.TypeProto.fromObject(t.typeProtos[u])}}return l},s.toObject=function(t,l){l||(l={});var u={};if((l.arrays||l.defaults)&&(u.floats=[],u.ints=[],u.strings=[],u.tensors=[],u.graphs=[],u.typeProtos=[],u.sparseTensors=[]),l.defaults){if(u.name="",u.f=0,h.Long){var g=new h.Long(0,0,!1);u.i=l.longs===String?g.toString():l.longs===Number?g.toNumber():g}else u.i=l.longs===String?"0":0;l.bytes===String?u.s="":(u.s=[],l.bytes!==Array&&(u.s=h.newBuffer(u.s))),u.t=null,u.g=null,u.docString="",u.tp=null,u.type=l.enums===String?"UNDEFINED":0,u.refAttrName="",u.sparseTensor=null}if(t.name!=null&&t.hasOwnProperty("name")&&(u.name=t.name),t.f!=null&&t.hasOwnProperty("f")&&(u.f=l.json&&!isFinite(t.f)?String(t.f):t.f),t.i!=null&&t.hasOwnProperty("i")&&(typeof t.i=="number"?u.i=l.longs===String?String(t.i):t.i:u.i=l.longs===String?h.Long.prototype.toString.call(t.i):l.longs===Number?new h.LongBits(t.i.low>>>0,t.i.high>>>0).toNumber():t.i),t.s!=null&&t.hasOwnProperty("s")&&(u.s=l.bytes===String?h.base64.encode(t.s,0,t.s.length):l.bytes===Array?Array.prototype.slice.call(t.s):t.s),t.t!=null&&t.hasOwnProperty("t")&&(u.t=p.onnx.TensorProto.toObject(t.t,l)),t.g!=null&&t.hasOwnProperty("g")&&(u.g=p.onnx.GraphProto.toObject(t.g,l)),t.floats&&t.floats.length){u.floats=[];for(var m=0;m<t.floats.length;++m)u.floats[m]=l.json&&!isFinite(t.floats[m])?String(t.floats[m]):t.floats[m]}if(t.ints&&t.ints.length)for(u.ints=[],m=0;m<t.ints.length;++m)typeof t.ints[m]=="number"?u.ints[m]=l.longs===String?String(t.ints[m]):t.ints[m]:u.ints[m]=l.longs===String?h.Long.prototype.toString.call(t.ints[m]):l.longs===Number?new h.LongBits(t.ints[m].low>>>0,t.ints[m].high>>>0).toNumber():t.ints[m];if(t.strings&&t.strings.length)for(u.strings=[],m=0;m<t.strings.length;++m)u.strings[m]=l.bytes===String?h.base64.encode(t.strings[m],0,t.strings[m].length):l.bytes===Array?Array.prototype.slice.call(t.strings[m]):t.strings[m];if(t.tensors&&t.tensors.length)for(u.tensors=[],m=0;m<t.tensors.length;++m)u.tensors[m]=p.onnx.TensorProto.toObject(t.tensors[m],l);if(t.graphs&&t.graphs.length)for(u.graphs=[],m=0;m<t.graphs.length;++m)u.graphs[m]=p.onnx.GraphProto.toObject(t.graphs[m],l);if(t.docString!=null&&t.hasOwnProperty("docString")&&(u.docString=t.docString),t.tp!=null&&t.hasOwnProperty("tp")&&(u.tp=p.onnx.TypeProto.toObject(t.tp,l)),t.typeProtos&&t.typeProtos.length)for(u.typeProtos=[],m=0;m<t.typeProtos.length;++m)u.typeProtos[m]=p.onnx.TypeProto.toObject(t.typeProtos[m],l);if(t.type!=null&&t.hasOwnProperty("type")&&(u.type=l.enums===String?p.onnx.AttributeProto.AttributeType[t.type]===void 0?t.type:p.onnx.AttributeProto.AttributeType[t.type]:t.type),t.refAttrName!=null&&t.hasOwnProperty("refAttrName")&&(u.refAttrName=t.refAttrName),t.sparseTensor!=null&&t.hasOwnProperty("sparseTensor")&&(u.sparseTensor=p.onnx.SparseTensorProto.toObject(t.sparseTensor,l)),t.sparseTensors&&t.sparseTensors.length)for(u.sparseTensors=[],m=0;m<t.sparseTensors.length;++m)u.sparseTensors[m]=p.onnx.SparseTensorProto.toObject(t.sparseTensors[m],l);return u},s.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},s.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.AttributeProto"},s.AttributeType=function(){var t={},l=Object.create(t);return l[t[0]="UNDEFINED"]=0,l[t[1]="FLOAT"]=1,l[t[2]="INT"]=2,l[t[3]="STRING"]=3,l[t[4]="TENSOR"]=4,l[t[5]="GRAPH"]=5,l[t[11]="SPARSE_TENSOR"]=11,l[t[13]="TYPE_PROTO"]=13,l[t[6]="FLOATS"]=6,l[t[7]="INTS"]=7,l[t[8]="STRINGS"]=8,l[t[9]="TENSORS"]=9,l[t[10]="GRAPHS"]=10,l[t[12]="SPARSE_TENSORS"]=12,l[t[14]="TYPE_PROTOS"]=14,l}(),s}(),o.ValueInfoProto=function(){function s(t){if(t)for(var l=Object.keys(t),u=0;u<l.length;++u)t[l[u]]!=null&&(this[l[u]]=t[l[u]])}return s.prototype.name="",s.prototype.type=null,s.prototype.docString="",s.create=function(t){return new s(t)},s.encode=function(t,l){return l||(l=f.create()),t.name!=null&&Object.hasOwnProperty.call(t,"name")&&l.uint32(10).string(t.name),t.type!=null&&Object.hasOwnProperty.call(t,"type")&&p.onnx.TypeProto.encode(t.type,l.uint32(18).fork()).ldelim(),t.docString!=null&&Object.hasOwnProperty.call(t,"docString")&&l.uint32(26).string(t.docString),l},s.encodeDelimited=function(t,l){return this.encode(t,l).ldelim()},s.decode=function(t,l){t instanceof d||(t=d.create(t));for(var u=l===void 0?t.len:t.pos+l,g=new p.onnx.ValueInfoProto;t.pos<u;){var m=t.uint32();switch(m>>>3){case 1:g.name=t.string();break;case 2:g.type=p.onnx.TypeProto.decode(t,t.uint32());break;case 3:g.docString=t.string();break;default:t.skipType(7&m)}}return g},s.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},s.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.name!=null&&t.hasOwnProperty("name")&&!h.isString(t.name))return"name: string expected";if(t.type!=null&&t.hasOwnProperty("type")){var l=p.onnx.TypeProto.verify(t.type);if(l)return"type."+l}return t.docString!=null&&t.hasOwnProperty("docString")&&!h.isString(t.docString)?"docString: string expected":null},s.fromObject=function(t){if(t instanceof p.onnx.ValueInfoProto)return t;var l=new p.onnx.ValueInfoProto;if(t.name!=null&&(l.name=String(t.name)),t.type!=null){if(typeof t.type!="object")throw TypeError(".onnx.ValueInfoProto.type: object expected");l.type=p.onnx.TypeProto.fromObject(t.type)}return t.docString!=null&&(l.docString=String(t.docString)),l},s.toObject=function(t,l){l||(l={});var u={};return l.defaults&&(u.name="",u.type=null,u.docString=""),t.name!=null&&t.hasOwnProperty("name")&&(u.name=t.name),t.type!=null&&t.hasOwnProperty("type")&&(u.type=p.onnx.TypeProto.toObject(t.type,l)),t.docString!=null&&t.hasOwnProperty("docString")&&(u.docString=t.docString),u},s.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},s.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.ValueInfoProto"},s}(),o.NodeProto=function(){function s(t){if(this.input=[],this.output=[],this.attribute=[],t)for(var l=Object.keys(t),u=0;u<l.length;++u)t[l[u]]!=null&&(this[l[u]]=t[l[u]])}return s.prototype.input=h.emptyArray,s.prototype.output=h.emptyArray,s.prototype.name="",s.prototype.opType="",s.prototype.domain="",s.prototype.attribute=h.emptyArray,s.prototype.docString="",s.create=function(t){return new s(t)},s.encode=function(t,l){if(l||(l=f.create()),t.input!=null&&t.input.length)for(var u=0;u<t.input.length;++u)l.uint32(10).string(t.input[u]);if(t.output!=null&&t.output.length)for(u=0;u<t.output.length;++u)l.uint32(18).string(t.output[u]);if(t.name!=null&&Object.hasOwnProperty.call(t,"name")&&l.uint32(26).string(t.name),t.opType!=null&&Object.hasOwnProperty.call(t,"opType")&&l.uint32(34).string(t.opType),t.attribute!=null&&t.attribute.length)for(u=0;u<t.attribute.length;++u)p.onnx.AttributeProto.encode(t.attribute[u],l.uint32(42).fork()).ldelim();return t.docString!=null&&Object.hasOwnProperty.call(t,"docString")&&l.uint32(50).string(t.docString),t.domain!=null&&Object.hasOwnProperty.call(t,"domain")&&l.uint32(58).string(t.domain),l},s.encodeDelimited=function(t,l){return this.encode(t,l).ldelim()},s.decode=function(t,l){t instanceof d||(t=d.create(t));for(var u=l===void 0?t.len:t.pos+l,g=new p.onnx.NodeProto;t.pos<u;){var m=t.uint32();switch(m>>>3){case 1:g.input&&g.input.length||(g.input=[]),g.input.push(t.string());break;case 2:g.output&&g.output.length||(g.output=[]),g.output.push(t.string());break;case 3:g.name=t.string();break;case 4:g.opType=t.string();break;case 7:g.domain=t.string();break;case 5:g.attribute&&g.attribute.length||(g.attribute=[]),g.attribute.push(p.onnx.AttributeProto.decode(t,t.uint32()));break;case 6:g.docString=t.string();break;default:t.skipType(7&m)}}return g},s.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},s.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.input!=null&&t.hasOwnProperty("input")){if(!Array.isArray(t.input))return"input: array expected";for(var l=0;l<t.input.length;++l)if(!h.isString(t.input[l]))return"input: string[] expected"}if(t.output!=null&&t.hasOwnProperty("output")){if(!Array.isArray(t.output))return"output: array expected";for(l=0;l<t.output.length;++l)if(!h.isString(t.output[l]))return"output: string[] expected"}if(t.name!=null&&t.hasOwnProperty("name")&&!h.isString(t.name))return"name: string expected";if(t.opType!=null&&t.hasOwnProperty("opType")&&!h.isString(t.opType))return"opType: string expected";if(t.domain!=null&&t.hasOwnProperty("domain")&&!h.isString(t.domain))return"domain: string expected";if(t.attribute!=null&&t.hasOwnProperty("attribute")){if(!Array.isArray(t.attribute))return"attribute: array expected";for(l=0;l<t.attribute.length;++l){var u=p.onnx.AttributeProto.verify(t.attribute[l]);if(u)return"attribute."+u}}return t.docString!=null&&t.hasOwnProperty("docString")&&!h.isString(t.docString)?"docString: string expected":null},s.fromObject=function(t){if(t instanceof p.onnx.NodeProto)return t;var l=new p.onnx.NodeProto;if(t.input){if(!Array.isArray(t.input))throw TypeError(".onnx.NodeProto.input: array expected");l.input=[];for(var u=0;u<t.input.length;++u)l.input[u]=String(t.input[u])}if(t.output){if(!Array.isArray(t.output))throw TypeError(".onnx.NodeProto.output: array expected");for(l.output=[],u=0;u<t.output.length;++u)l.output[u]=String(t.output[u])}if(t.name!=null&&(l.name=String(t.name)),t.opType!=null&&(l.opType=String(t.opType)),t.domain!=null&&(l.domain=String(t.domain)),t.attribute){if(!Array.isArray(t.attribute))throw TypeError(".onnx.NodeProto.attribute: array expected");for(l.attribute=[],u=0;u<t.attribute.length;++u){if(typeof t.attribute[u]!="object")throw TypeError(".onnx.NodeProto.attribute: object expected");l.attribute[u]=p.onnx.AttributeProto.fromObject(t.attribute[u])}}return t.docString!=null&&(l.docString=String(t.docString)),l},s.toObject=function(t,l){l||(l={});var u={};if((l.arrays||l.defaults)&&(u.input=[],u.output=[],u.attribute=[]),l.defaults&&(u.name="",u.opType="",u.docString="",u.domain=""),t.input&&t.input.length){u.input=[];for(var g=0;g<t.input.length;++g)u.input[g]=t.input[g]}if(t.output&&t.output.length)for(u.output=[],g=0;g<t.output.length;++g)u.output[g]=t.output[g];if(t.name!=null&&t.hasOwnProperty("name")&&(u.name=t.name),t.opType!=null&&t.hasOwnProperty("opType")&&(u.opType=t.opType),t.attribute&&t.attribute.length)for(u.attribute=[],g=0;g<t.attribute.length;++g)u.attribute[g]=p.onnx.AttributeProto.toObject(t.attribute[g],l);return t.docString!=null&&t.hasOwnProperty("docString")&&(u.docString=t.docString),t.domain!=null&&t.hasOwnProperty("domain")&&(u.domain=t.domain),u},s.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},s.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.NodeProto"},s}(),o.TrainingInfoProto=function(){function s(t){if(this.initializationBinding=[],this.updateBinding=[],t)for(var l=Object.keys(t),u=0;u<l.length;++u)t[l[u]]!=null&&(this[l[u]]=t[l[u]])}return s.prototype.initialization=null,s.prototype.algorithm=null,s.prototype.initializationBinding=h.emptyArray,s.prototype.updateBinding=h.emptyArray,s.create=function(t){return new s(t)},s.encode=function(t,l){if(l||(l=f.create()),t.initialization!=null&&Object.hasOwnProperty.call(t,"initialization")&&p.onnx.GraphProto.encode(t.initialization,l.uint32(10).fork()).ldelim(),t.algorithm!=null&&Object.hasOwnProperty.call(t,"algorithm")&&p.onnx.GraphProto.encode(t.algorithm,l.uint32(18).fork()).ldelim(),t.initializationBinding!=null&&t.initializationBinding.length)for(var u=0;u<t.initializationBinding.length;++u)p.onnx.StringStringEntryProto.encode(t.initializationBinding[u],l.uint32(26).fork()).ldelim();if(t.updateBinding!=null&&t.updateBinding.length)for(u=0;u<t.updateBinding.length;++u)p.onnx.StringStringEntryProto.encode(t.updateBinding[u],l.uint32(34).fork()).ldelim();return l},s.encodeDelimited=function(t,l){return this.encode(t,l).ldelim()},s.decode=function(t,l){t instanceof d||(t=d.create(t));for(var u=l===void 0?t.len:t.pos+l,g=new p.onnx.TrainingInfoProto;t.pos<u;){var m=t.uint32();switch(m>>>3){case 1:g.initialization=p.onnx.GraphProto.decode(t,t.uint32());break;case 2:g.algorithm=p.onnx.GraphProto.decode(t,t.uint32());break;case 3:g.initializationBinding&&g.initializationBinding.length||(g.initializationBinding=[]),g.initializationBinding.push(p.onnx.StringStringEntryProto.decode(t,t.uint32()));break;case 4:g.updateBinding&&g.updateBinding.length||(g.updateBinding=[]),g.updateBinding.push(p.onnx.StringStringEntryProto.decode(t,t.uint32()));break;default:t.skipType(7&m)}}return g},s.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},s.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.initialization!=null&&t.hasOwnProperty("initialization")&&(u=p.onnx.GraphProto.verify(t.initialization)))return"initialization."+u;if(t.algorithm!=null&&t.hasOwnProperty("algorithm")&&(u=p.onnx.GraphProto.verify(t.algorithm)))return"algorithm."+u;if(t.initializationBinding!=null&&t.hasOwnProperty("initializationBinding")){if(!Array.isArray(t.initializationBinding))return"initializationBinding: array expected";for(var l=0;l<t.initializationBinding.length;++l)if(u=p.onnx.StringStringEntryProto.verify(t.initializationBinding[l]))return"initializationBinding."+u}if(t.updateBinding!=null&&t.hasOwnProperty("updateBinding")){if(!Array.isArray(t.updateBinding))return"updateBinding: array expected";for(l=0;l<t.updateBinding.length;++l){var u;if(u=p.onnx.StringStringEntryProto.verify(t.updateBinding[l]))return"updateBinding."+u}}return null},s.fromObject=function(t){if(t instanceof p.onnx.TrainingInfoProto)return t;var l=new p.onnx.TrainingInfoProto;if(t.initialization!=null){if(typeof t.initialization!="object")throw TypeError(".onnx.TrainingInfoProto.initialization: object expected");l.initialization=p.onnx.GraphProto.fromObject(t.initialization)}if(t.algorithm!=null){if(typeof t.algorithm!="object")throw TypeError(".onnx.TrainingInfoProto.algorithm: object expected");l.algorithm=p.onnx.GraphProto.fromObject(t.algorithm)}if(t.initializationBinding){if(!Array.isArray(t.initializationBinding))throw TypeError(".onnx.TrainingInfoProto.initializationBinding: array expected");l.initializationBinding=[];for(var u=0;u<t.initializationBinding.length;++u){if(typeof t.initializationBinding[u]!="object")throw TypeError(".onnx.TrainingInfoProto.initializationBinding: object expected");l.initializationBinding[u]=p.onnx.StringStringEntryProto.fromObject(t.initializationBinding[u])}}if(t.updateBinding){if(!Array.isArray(t.updateBinding))throw TypeError(".onnx.TrainingInfoProto.updateBinding: array expected");for(l.updateBinding=[],u=0;u<t.updateBinding.length;++u){if(typeof t.updateBinding[u]!="object")throw TypeError(".onnx.TrainingInfoProto.updateBinding: object expected");l.updateBinding[u]=p.onnx.StringStringEntryProto.fromObject(t.updateBinding[u])}}return l},s.toObject=function(t,l){l||(l={});var u={};if((l.arrays||l.defaults)&&(u.initializationBinding=[],u.updateBinding=[]),l.defaults&&(u.initialization=null,u.algorithm=null),t.initialization!=null&&t.hasOwnProperty("initialization")&&(u.initialization=p.onnx.GraphProto.toObject(t.initialization,l)),t.algorithm!=null&&t.hasOwnProperty("algorithm")&&(u.algorithm=p.onnx.GraphProto.toObject(t.algorithm,l)),t.initializationBinding&&t.initializationBinding.length){u.initializationBinding=[];for(var g=0;g<t.initializationBinding.length;++g)u.initializationBinding[g]=p.onnx.StringStringEntryProto.toObject(t.initializationBinding[g],l)}if(t.updateBinding&&t.updateBinding.length)for(u.updateBinding=[],g=0;g<t.updateBinding.length;++g)u.updateBinding[g]=p.onnx.StringStringEntryProto.toObject(t.updateBinding[g],l);return u},s.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},s.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.TrainingInfoProto"},s}(),o.ModelProto=function(){function s(t){if(this.opsetImport=[],this.metadataProps=[],this.trainingInfo=[],this.functions=[],t)for(var l=Object.keys(t),u=0;u<l.length;++u)t[l[u]]!=null&&(this[l[u]]=t[l[u]])}return s.prototype.irVersion=h.Long?h.Long.fromBits(0,0,!1):0,s.prototype.opsetImport=h.emptyArray,s.prototype.producerName="",s.prototype.producerVersion="",s.prototype.domain="",s.prototype.modelVersion=h.Long?h.Long.fromBits(0,0,!1):0,s.prototype.docString="",s.prototype.graph=null,s.prototype.metadataProps=h.emptyArray,s.prototype.trainingInfo=h.emptyArray,s.prototype.functions=h.emptyArray,s.create=function(t){return new s(t)},s.encode=function(t,l){if(l||(l=f.create()),t.irVersion!=null&&Object.hasOwnProperty.call(t,"irVersion")&&l.uint32(8).int64(t.irVersion),t.producerName!=null&&Object.hasOwnProperty.call(t,"producerName")&&l.uint32(18).string(t.producerName),t.producerVersion!=null&&Object.hasOwnProperty.call(t,"producerVersion")&&l.uint32(26).string(t.producerVersion),t.domain!=null&&Object.hasOwnProperty.call(t,"domain")&&l.uint32(34).string(t.domain),t.modelVersion!=null&&Object.hasOwnProperty.call(t,"modelVersion")&&l.uint32(40).int64(t.modelVersion),t.docString!=null&&Object.hasOwnProperty.call(t,"docString")&&l.uint32(50).string(t.docString),t.graph!=null&&Object.hasOwnProperty.call(t,"graph")&&p.onnx.GraphProto.encode(t.graph,l.uint32(58).fork()).ldelim(),t.opsetImport!=null&&t.opsetImport.length)for(var u=0;u<t.opsetImport.length;++u)p.onnx.OperatorSetIdProto.encode(t.opsetImport[u],l.uint32(66).fork()).ldelim();if(t.metadataProps!=null&&t.metadataProps.length)for(u=0;u<t.metadataProps.length;++u)p.onnx.StringStringEntryProto.encode(t.metadataProps[u],l.uint32(114).fork()).ldelim();if(t.trainingInfo!=null&&t.trainingInfo.length)for(u=0;u<t.trainingInfo.length;++u)p.onnx.TrainingInfoProto.encode(t.trainingInfo[u],l.uint32(162).fork()).ldelim();if(t.functions!=null&&t.functions.length)for(u=0;u<t.functions.length;++u)p.onnx.FunctionProto.encode(t.functions[u],l.uint32(202).fork()).ldelim();return l},s.encodeDelimited=function(t,l){return this.encode(t,l).ldelim()},s.decode=function(t,l){t instanceof d||(t=d.create(t));for(var u=l===void 0?t.len:t.pos+l,g=new p.onnx.ModelProto;t.pos<u;){var m=t.uint32();switch(m>>>3){case 1:g.irVersion=t.int64();break;case 8:g.opsetImport&&g.opsetImport.length||(g.opsetImport=[]),g.opsetImport.push(p.onnx.OperatorSetIdProto.decode(t,t.uint32()));break;case 2:g.producerName=t.string();break;case 3:g.producerVersion=t.string();break;case 4:g.domain=t.string();break;case 5:g.modelVersion=t.int64();break;case 6:g.docString=t.string();break;case 7:g.graph=p.onnx.GraphProto.decode(t,t.uint32());break;case 14:g.metadataProps&&g.metadataProps.length||(g.metadataProps=[]),g.metadataProps.push(p.onnx.StringStringEntryProto.decode(t,t.uint32()));break;case 20:g.trainingInfo&&g.trainingInfo.length||(g.trainingInfo=[]),g.trainingInfo.push(p.onnx.TrainingInfoProto.decode(t,t.uint32()));break;case 25:g.functions&&g.functions.length||(g.functions=[]),g.functions.push(p.onnx.FunctionProto.decode(t,t.uint32()));break;default:t.skipType(7&m)}}return g},s.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},s.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.irVersion!=null&&t.hasOwnProperty("irVersion")&&!(h.isInteger(t.irVersion)||t.irVersion&&h.isInteger(t.irVersion.low)&&h.isInteger(t.irVersion.high)))return"irVersion: integer|Long expected";if(t.opsetImport!=null&&t.hasOwnProperty("opsetImport")){if(!Array.isArray(t.opsetImport))return"opsetImport: array expected";for(var l=0;l<t.opsetImport.length;++l)if(u=p.onnx.OperatorSetIdProto.verify(t.opsetImport[l]))return"opsetImport."+u}if(t.producerName!=null&&t.hasOwnProperty("producerName")&&!h.isString(t.producerName))return"producerName: string expected";if(t.producerVersion!=null&&t.hasOwnProperty("producerVersion")&&!h.isString(t.producerVersion))return"producerVersion: string expected";if(t.domain!=null&&t.hasOwnProperty("domain")&&!h.isString(t.domain))return"domain: string expected";if(t.modelVersion!=null&&t.hasOwnProperty("modelVersion")&&!(h.isInteger(t.modelVersion)||t.modelVersion&&h.isInteger(t.modelVersion.low)&&h.isInteger(t.modelVersion.high)))return"modelVersion: integer|Long expected";if(t.docString!=null&&t.hasOwnProperty("docString")&&!h.isString(t.docString))return"docString: string expected";if(t.graph!=null&&t.hasOwnProperty("graph")&&(u=p.onnx.GraphProto.verify(t.graph)))return"graph."+u;if(t.metadataProps!=null&&t.hasOwnProperty("metadataProps")){if(!Array.isArray(t.metadataProps))return"metadataProps: array expected";for(l=0;l<t.metadataProps.length;++l)if(u=p.onnx.StringStringEntryProto.verify(t.metadataProps[l]))return"metadataProps."+u}if(t.trainingInfo!=null&&t.hasOwnProperty("trainingInfo")){if(!Array.isArray(t.trainingInfo))return"trainingInfo: array expected";for(l=0;l<t.trainingInfo.length;++l)if(u=p.onnx.TrainingInfoProto.verify(t.trainingInfo[l]))return"trainingInfo."+u}if(t.functions!=null&&t.hasOwnProperty("functions")){if(!Array.isArray(t.functions))return"functions: array expected";for(l=0;l<t.functions.length;++l){var u;if(u=p.onnx.FunctionProto.verify(t.functions[l]))return"functions."+u}}return null},s.fromObject=function(t){if(t instanceof p.onnx.ModelProto)return t;var l=new p.onnx.ModelProto;if(t.irVersion!=null&&(h.Long?(l.irVersion=h.Long.fromValue(t.irVersion)).unsigned=!1:typeof t.irVersion=="string"?l.irVersion=parseInt(t.irVersion,10):typeof t.irVersion=="number"?l.irVersion=t.irVersion:typeof t.irVersion=="object"&&(l.irVersion=new h.LongBits(t.irVersion.low>>>0,t.irVersion.high>>>0).toNumber())),t.opsetImport){if(!Array.isArray(t.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");l.opsetImport=[];for(var u=0;u<t.opsetImport.length;++u){if(typeof t.opsetImport[u]!="object")throw TypeError(".onnx.ModelProto.opsetImport: object expected");l.opsetImport[u]=p.onnx.OperatorSetIdProto.fromObject(t.opsetImport[u])}}if(t.producerName!=null&&(l.producerName=String(t.producerName)),t.producerVersion!=null&&(l.producerVersion=String(t.producerVersion)),t.domain!=null&&(l.domain=String(t.domain)),t.modelVersion!=null&&(h.Long?(l.modelVersion=h.Long.fromValue(t.modelVersion)).unsigned=!1:typeof t.modelVersion=="string"?l.modelVersion=parseInt(t.modelVersion,10):typeof t.modelVersion=="number"?l.modelVersion=t.modelVersion:typeof t.modelVersion=="object"&&(l.modelVersion=new h.LongBits(t.modelVersion.low>>>0,t.modelVersion.high>>>0).toNumber())),t.docString!=null&&(l.docString=String(t.docString)),t.graph!=null){if(typeof t.graph!="object")throw TypeError(".onnx.ModelProto.graph: object expected");l.graph=p.onnx.GraphProto.fromObject(t.graph)}if(t.metadataProps){if(!Array.isArray(t.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");for(l.metadataProps=[],u=0;u<t.metadataProps.length;++u){if(typeof t.metadataProps[u]!="object")throw TypeError(".onnx.ModelProto.metadataProps: object expected");l.metadataProps[u]=p.onnx.StringStringEntryProto.fromObject(t.metadataProps[u])}}if(t.trainingInfo){if(!Array.isArray(t.trainingInfo))throw TypeError(".onnx.ModelProto.trainingInfo: array expected");for(l.trainingInfo=[],u=0;u<t.trainingInfo.length;++u){if(typeof t.trainingInfo[u]!="object")throw TypeError(".onnx.ModelProto.trainingInfo: object expected");l.trainingInfo[u]=p.onnx.TrainingInfoProto.fromObject(t.trainingInfo[u])}}if(t.functions){if(!Array.isArray(t.functions))throw TypeError(".onnx.ModelProto.functions: array expected");for(l.functions=[],u=0;u<t.functions.length;++u){if(typeof t.functions[u]!="object")throw TypeError(".onnx.ModelProto.functions: object expected");l.functions[u]=p.onnx.FunctionProto.fromObject(t.functions[u])}}return l},s.toObject=function(t,l){l||(l={});var u={};if((l.arrays||l.defaults)&&(u.opsetImport=[],u.metadataProps=[],u.trainingInfo=[],u.functions=[]),l.defaults){if(h.Long){var g=new h.Long(0,0,!1);u.irVersion=l.longs===String?g.toString():l.longs===Number?g.toNumber():g}else u.irVersion=l.longs===String?"0":0;u.producerName="",u.producerVersion="",u.domain="",h.Long?(g=new h.Long(0,0,!1),u.modelVersion=l.longs===String?g.toString():l.longs===Number?g.toNumber():g):u.modelVersion=l.longs===String?"0":0,u.docString="",u.graph=null}if(t.irVersion!=null&&t.hasOwnProperty("irVersion")&&(typeof t.irVersion=="number"?u.irVersion=l.longs===String?String(t.irVersion):t.irVersion:u.irVersion=l.longs===String?h.Long.prototype.toString.call(t.irVersion):l.longs===Number?new h.LongBits(t.irVersion.low>>>0,t.irVersion.high>>>0).toNumber():t.irVersion),t.producerName!=null&&t.hasOwnProperty("producerName")&&(u.producerName=t.producerName),t.producerVersion!=null&&t.hasOwnProperty("producerVersion")&&(u.producerVersion=t.producerVersion),t.domain!=null&&t.hasOwnProperty("domain")&&(u.domain=t.domain),t.modelVersion!=null&&t.hasOwnProperty("modelVersion")&&(typeof t.modelVersion=="number"?u.modelVersion=l.longs===String?String(t.modelVersion):t.modelVersion:u.modelVersion=l.longs===String?h.Long.prototype.toString.call(t.modelVersion):l.longs===Number?new h.LongBits(t.modelVersion.low>>>0,t.modelVersion.high>>>0).toNumber():t.modelVersion),t.docString!=null&&t.hasOwnProperty("docString")&&(u.docString=t.docString),t.graph!=null&&t.hasOwnProperty("graph")&&(u.graph=p.onnx.GraphProto.toObject(t.graph,l)),t.opsetImport&&t.opsetImport.length){u.opsetImport=[];for(var m=0;m<t.opsetImport.length;++m)u.opsetImport[m]=p.onnx.OperatorSetIdProto.toObject(t.opsetImport[m],l)}if(t.metadataProps&&t.metadataProps.length)for(u.metadataProps=[],m=0;m<t.metadataProps.length;++m)u.metadataProps[m]=p.onnx.StringStringEntryProto.toObject(t.metadataProps[m],l);if(t.trainingInfo&&t.trainingInfo.length)for(u.trainingInfo=[],m=0;m<t.trainingInfo.length;++m)u.trainingInfo[m]=p.onnx.TrainingInfoProto.toObject(t.trainingInfo[m],l);if(t.functions&&t.functions.length)for(u.functions=[],m=0;m<t.functions.length;++m)u.functions[m]=p.onnx.FunctionProto.toObject(t.functions[m],l);return u},s.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},s.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.ModelProto"},s}(),o.StringStringEntryProto=function(){function s(t){if(t)for(var l=Object.keys(t),u=0;u<l.length;++u)t[l[u]]!=null&&(this[l[u]]=t[l[u]])}return s.prototype.key="",s.prototype.value="",s.create=function(t){return new s(t)},s.encode=function(t,l){return l||(l=f.create()),t.key!=null&&Object.hasOwnProperty.call(t,"key")&&l.uint32(10).string(t.key),t.value!=null&&Object.hasOwnProperty.call(t,"value")&&l.uint32(18).string(t.value),l},s.encodeDelimited=function(t,l){return this.encode(t,l).ldelim()},s.decode=function(t,l){t instanceof d||(t=d.create(t));for(var u=l===void 0?t.len:t.pos+l,g=new p.onnx.StringStringEntryProto;t.pos<u;){var m=t.uint32();switch(m>>>3){case 1:g.key=t.string();break;case 2:g.value=t.string();break;default:t.skipType(7&m)}}return g},s.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},s.verify=function(t){return typeof t!="object"||t===null?"object expected":t.key!=null&&t.hasOwnProperty("key")&&!h.isString(t.key)?"key: string expected":t.value!=null&&t.hasOwnProperty("value")&&!h.isString(t.value)?"value: string expected":null},s.fromObject=function(t){if(t instanceof p.onnx.StringStringEntryProto)return t;var l=new p.onnx.StringStringEntryProto;return t.key!=null&&(l.key=String(t.key)),t.value!=null&&(l.value=String(t.value)),l},s.toObject=function(t,l){l||(l={});var u={};return l.defaults&&(u.key="",u.value=""),t.key!=null&&t.hasOwnProperty("key")&&(u.key=t.key),t.value!=null&&t.hasOwnProperty("value")&&(u.value=t.value),u},s.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},s.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.StringStringEntryProto"},s}(),o.TensorAnnotation=function(){function s(t){if(this.quantParameterTensorNames=[],t)for(var l=Object.keys(t),u=0;u<l.length;++u)t[l[u]]!=null&&(this[l[u]]=t[l[u]])}return s.prototype.tensorName="",s.prototype.quantParameterTensorNames=h.emptyArray,s.create=function(t){return new s(t)},s.encode=function(t,l){if(l||(l=f.create()),t.tensorName!=null&&Object.hasOwnProperty.call(t,"tensorName")&&l.uint32(10).string(t.tensorName),t.quantParameterTensorNames!=null&&t.quantParameterTensorNames.length)for(var u=0;u<t.quantParameterTensorNames.length;++u)p.onnx.StringStringEntryProto.encode(t.quantParameterTensorNames[u],l.uint32(18).fork()).ldelim();return l},s.encodeDelimited=function(t,l){return this.encode(t,l).ldelim()},s.decode=function(t,l){t instanceof d||(t=d.create(t));for(var u=l===void 0?t.len:t.pos+l,g=new p.onnx.TensorAnnotation;t.pos<u;){var m=t.uint32();switch(m>>>3){case 1:g.tensorName=t.string();break;case 2:g.quantParameterTensorNames&&g.quantParameterTensorNames.length||(g.quantParameterTensorNames=[]),g.quantParameterTensorNames.push(p.onnx.StringStringEntryProto.decode(t,t.uint32()));break;default:t.skipType(7&m)}}return g},s.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},s.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.tensorName!=null&&t.hasOwnProperty("tensorName")&&!h.isString(t.tensorName))return"tensorName: string expected";if(t.quantParameterTensorNames!=null&&t.hasOwnProperty("quantParameterTensorNames")){if(!Array.isArray(t.quantParameterTensorNames))return"quantParameterTensorNames: array expected";for(var l=0;l<t.quantParameterTensorNames.length;++l){var u=p.onnx.StringStringEntryProto.verify(t.quantParameterTensorNames[l]);if(u)return"quantParameterTensorNames."+u}}return null},s.fromObject=function(t){if(t instanceof p.onnx.TensorAnnotation)return t;var l=new p.onnx.TensorAnnotation;if(t.tensorName!=null&&(l.tensorName=String(t.tensorName)),t.quantParameterTensorNames){if(!Array.isArray(t.quantParameterTensorNames))throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: array expected");l.quantParameterTensorNames=[];for(var u=0;u<t.quantParameterTensorNames.length;++u){if(typeof t.quantParameterTensorNames[u]!="object")throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: object expected");l.quantParameterTensorNames[u]=p.onnx.StringStringEntryProto.fromObject(t.quantParameterTensorNames[u])}}return l},s.toObject=function(t,l){l||(l={});var u={};if((l.arrays||l.defaults)&&(u.quantParameterTensorNames=[]),l.defaults&&(u.tensorName=""),t.tensorName!=null&&t.hasOwnProperty("tensorName")&&(u.tensorName=t.tensorName),t.quantParameterTensorNames&&t.quantParameterTensorNames.length){u.quantParameterTensorNames=[];for(var g=0;g<t.quantParameterTensorNames.length;++g)u.quantParameterTensorNames[g]=p.onnx.StringStringEntryProto.toObject(t.quantParameterTensorNames[g],l)}return u},s.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},s.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.TensorAnnotation"},s}(),o.GraphProto=function(){function s(t){if(this.node=[],this.initializer=[],this.sparseInitializer=[],this.input=[],this.output=[],this.valueInfo=[],this.quantizationAnnotation=[],t)for(var l=Object.keys(t),u=0;u<l.length;++u)t[l[u]]!=null&&(this[l[u]]=t[l[u]])}return s.prototype.node=h.emptyArray,s.prototype.name="",s.prototype.initializer=h.emptyArray,s.prototype.sparseInitializer=h.emptyArray,s.prototype.docString="",s.prototype.input=h.emptyArray,s.prototype.output=h.emptyArray,s.prototype.valueInfo=h.emptyArray,s.prototype.quantizationAnnotation=h.emptyArray,s.create=function(t){return new s(t)},s.encode=function(t,l){if(l||(l=f.create()),t.node!=null&&t.node.length)for(var u=0;u<t.node.length;++u)p.onnx.NodeProto.encode(t.node[u],l.uint32(10).fork()).ldelim();if(t.name!=null&&Object.hasOwnProperty.call(t,"name")&&l.uint32(18).string(t.name),t.initializer!=null&&t.initializer.length)for(u=0;u<t.initializer.length;++u)p.onnx.TensorProto.encode(t.initializer[u],l.uint32(42).fork()).ldelim();if(t.docString!=null&&Object.hasOwnProperty.call(t,"docString")&&l.uint32(82).string(t.docString),t.input!=null&&t.input.length)for(u=0;u<t.input.length;++u)p.onnx.ValueInfoProto.encode(t.input[u],l.uint32(90).fork()).ldelim();if(t.output!=null&&t.output.length)for(u=0;u<t.output.length;++u)p.onnx.ValueInfoProto.encode(t.output[u],l.uint32(98).fork()).ldelim();if(t.valueInfo!=null&&t.valueInfo.length)for(u=0;u<t.valueInfo.length;++u)p.onnx.ValueInfoProto.encode(t.valueInfo[u],l.uint32(106).fork()).ldelim();if(t.quantizationAnnotation!=null&&t.quantizationAnnotation.length)for(u=0;u<t.quantizationAnnotation.length;++u)p.onnx.TensorAnnotation.encode(t.quantizationAnnotation[u],l.uint32(114).fork()).ldelim();if(t.sparseInitializer!=null&&t.sparseInitializer.length)for(u=0;u<t.sparseInitializer.length;++u)p.onnx.SparseTensorProto.encode(t.sparseInitializer[u],l.uint32(122).fork()).ldelim();return l},s.encodeDelimited=function(t,l){return this.encode(t,l).ldelim()},s.decode=function(t,l){t instanceof d||(t=d.create(t));for(var u=l===void 0?t.len:t.pos+l,g=new p.onnx.GraphProto;t.pos<u;){var m=t.uint32();switch(m>>>3){case 1:g.node&&g.node.length||(g.node=[]),g.node.push(p.onnx.NodeProto.decode(t,t.uint32()));break;case 2:g.name=t.string();break;case 5:g.initializer&&g.initializer.length||(g.initializer=[]),g.initializer.push(p.onnx.TensorProto.decode(t,t.uint32()));break;case 15:g.sparseInitializer&&g.sparseInitializer.length||(g.sparseInitializer=[]),g.sparseInitializer.push(p.onnx.SparseTensorProto.decode(t,t.uint32()));break;case 10:g.docString=t.string();break;case 11:g.input&&g.input.length||(g.input=[]),g.input.push(p.onnx.ValueInfoProto.decode(t,t.uint32()));break;case 12:g.output&&g.output.length||(g.output=[]),g.output.push(p.onnx.ValueInfoProto.decode(t,t.uint32()));break;case 13:g.valueInfo&&g.valueInfo.length||(g.valueInfo=[]),g.valueInfo.push(p.onnx.ValueInfoProto.decode(t,t.uint32()));break;case 14:g.quantizationAnnotation&&g.quantizationAnnotation.length||(g.quantizationAnnotation=[]),g.quantizationAnnotation.push(p.onnx.TensorAnnotation.decode(t,t.uint32()));break;default:t.skipType(7&m)}}return g},s.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},s.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.node!=null&&t.hasOwnProperty("node")){if(!Array.isArray(t.node))return"node: array expected";for(var l=0;l<t.node.length;++l)if(u=p.onnx.NodeProto.verify(t.node[l]))return"node."+u}if(t.name!=null&&t.hasOwnProperty("name")&&!h.isString(t.name))return"name: string expected";if(t.initializer!=null&&t.hasOwnProperty("initializer")){if(!Array.isArray(t.initializer))return"initializer: array expected";for(l=0;l<t.initializer.length;++l)if(u=p.onnx.TensorProto.verify(t.initializer[l]))return"initializer."+u}if(t.sparseInitializer!=null&&t.hasOwnProperty("sparseInitializer")){if(!Array.isArray(t.sparseInitializer))return"sparseInitializer: array expected";for(l=0;l<t.sparseInitializer.length;++l)if(u=p.onnx.SparseTensorProto.verify(t.sparseInitializer[l]))return"sparseInitializer."+u}if(t.docString!=null&&t.hasOwnProperty("docString")&&!h.isString(t.docString))return"docString: string expected";if(t.input!=null&&t.hasOwnProperty("input")){if(!Array.isArray(t.input))return"input: array expected";for(l=0;l<t.input.length;++l)if(u=p.onnx.ValueInfoProto.verify(t.input[l]))return"input."+u}if(t.output!=null&&t.hasOwnProperty("output")){if(!Array.isArray(t.output))return"output: array expected";for(l=0;l<t.output.length;++l)if(u=p.onnx.ValueInfoProto.verify(t.output[l]))return"output."+u}if(t.valueInfo!=null&&t.hasOwnProperty("valueInfo")){if(!Array.isArray(t.valueInfo))return"valueInfo: array expected";for(l=0;l<t.valueInfo.length;++l)if(u=p.onnx.ValueInfoProto.verify(t.valueInfo[l]))return"valueInfo."+u}if(t.quantizationAnnotation!=null&&t.hasOwnProperty("quantizationAnnotation")){if(!Array.isArray(t.quantizationAnnotation))return"quantizationAnnotation: array expected";for(l=0;l<t.quantizationAnnotation.length;++l){var u;if(u=p.onnx.TensorAnnotation.verify(t.quantizationAnnotation[l]))return"quantizationAnnotation."+u}}return null},s.fromObject=function(t){if(t instanceof p.onnx.GraphProto)return t;var l=new p.onnx.GraphProto;if(t.node){if(!Array.isArray(t.node))throw TypeError(".onnx.GraphProto.node: array expected");l.node=[];for(var u=0;u<t.node.length;++u){if(typeof t.node[u]!="object")throw TypeError(".onnx.GraphProto.node: object expected");l.node[u]=p.onnx.NodeProto.fromObject(t.node[u])}}if(t.name!=null&&(l.name=String(t.name)),t.initializer){if(!Array.isArray(t.initializer))throw TypeError(".onnx.GraphProto.initializer: array expected");for(l.initializer=[],u=0;u<t.initializer.length;++u){if(typeof t.initializer[u]!="object")throw TypeError(".onnx.GraphProto.initializer: object expected");l.initializer[u]=p.onnx.TensorProto.fromObject(t.initializer[u])}}if(t.sparseInitializer){if(!Array.isArray(t.sparseInitializer))throw TypeError(".onnx.GraphProto.sparseInitializer: array expected");for(l.sparseInitializer=[],u=0;u<t.sparseInitializer.length;++u){if(typeof t.sparseInitializer[u]!="object")throw TypeError(".onnx.GraphProto.sparseInitializer: object expected");l.sparseInitializer[u]=p.onnx.SparseTensorProto.fromObject(t.sparseInitializer[u])}}if(t.docString!=null&&(l.docString=String(t.docString)),t.input){if(!Array.isArray(t.input))throw TypeError(".onnx.GraphProto.input: array expected");for(l.input=[],u=0;u<t.input.length;++u){if(typeof t.input[u]!="object")throw TypeError(".onnx.GraphProto.input: object expected");l.input[u]=p.onnx.ValueInfoProto.fromObject(t.input[u])}}if(t.output){if(!Array.isArray(t.output))throw TypeError(".onnx.GraphProto.output: array expected");for(l.output=[],u=0;u<t.output.length;++u){if(typeof t.output[u]!="object")throw TypeError(".onnx.GraphProto.output: object expected");l.output[u]=p.onnx.ValueInfoProto.fromObject(t.output[u])}}if(t.valueInfo){if(!Array.isArray(t.valueInfo))throw TypeError(".onnx.GraphProto.valueInfo: array expected");for(l.valueInfo=[],u=0;u<t.valueInfo.length;++u){if(typeof t.valueInfo[u]!="object")throw TypeError(".onnx.GraphProto.valueInfo: object expected");l.valueInfo[u]=p.onnx.ValueInfoProto.fromObject(t.valueInfo[u])}}if(t.quantizationAnnotation){if(!Array.isArray(t.quantizationAnnotation))throw TypeError(".onnx.GraphProto.quantizationAnnotation: array expected");for(l.quantizationAnnotation=[],u=0;u<t.quantizationAnnotation.length;++u){if(typeof t.quantizationAnnotation[u]!="object")throw TypeError(".onnx.GraphProto.quantizationAnnotation: object expected");l.quantizationAnnotation[u]=p.onnx.TensorAnnotation.fromObject(t.quantizationAnnotation[u])}}return l},s.toObject=function(t,l){l||(l={});var u={};if((l.arrays||l.defaults)&&(u.node=[],u.initializer=[],u.input=[],u.output=[],u.valueInfo=[],u.quantizationAnnotation=[],u.sparseInitializer=[]),l.defaults&&(u.name="",u.docString=""),t.node&&t.node.length){u.node=[];for(var g=0;g<t.node.length;++g)u.node[g]=p.onnx.NodeProto.toObject(t.node[g],l)}if(t.name!=null&&t.hasOwnProperty("name")&&(u.name=t.name),t.initializer&&t.initializer.length)for(u.initializer=[],g=0;g<t.initializer.length;++g)u.initializer[g]=p.onnx.TensorProto.toObject(t.initializer[g],l);if(t.docString!=null&&t.hasOwnProperty("docString")&&(u.docString=t.docString),t.input&&t.input.length)for(u.input=[],g=0;g<t.input.length;++g)u.input[g]=p.onnx.ValueInfoProto.toObject(t.input[g],l);if(t.output&&t.output.length)for(u.output=[],g=0;g<t.output.length;++g)u.output[g]=p.onnx.ValueInfoProto.toObject(t.output[g],l);if(t.valueInfo&&t.valueInfo.length)for(u.valueInfo=[],g=0;g<t.valueInfo.length;++g)u.valueInfo[g]=p.onnx.ValueInfoProto.toObject(t.valueInfo[g],l);if(t.quantizationAnnotation&&t.quantizationAnnotation.length)for(u.quantizationAnnotation=[],g=0;g<t.quantizationAnnotation.length;++g)u.quantizationAnnotation[g]=p.onnx.TensorAnnotation.toObject(t.quantizationAnnotation[g],l);if(t.sparseInitializer&&t.sparseInitializer.length)for(u.sparseInitializer=[],g=0;g<t.sparseInitializer.length;++g)u.sparseInitializer[g]=p.onnx.SparseTensorProto.toObject(t.sparseInitializer[g],l);return u},s.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},s.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.GraphProto"},s}(),o.TensorProto=function(){function s(t){if(this.dims=[],this.floatData=[],this.int32Data=[],this.stringData=[],this.int64Data=[],this.externalData=[],this.doubleData=[],this.uint64Data=[],t)for(var l=Object.keys(t),u=0;u<l.length;++u)t[l[u]]!=null&&(this[l[u]]=t[l[u]])}return s.prototype.dims=h.emptyArray,s.prototype.dataType=0,s.prototype.segment=null,s.prototype.floatData=h.emptyArray,s.prototype.int32Data=h.emptyArray,s.prototype.stringData=h.emptyArray,s.prototype.int64Data=h.emptyArray,s.prototype.name="",s.prototype.docString="",s.prototype.rawData=h.newBuffer([]),s.prototype.externalData=h.emptyArray,s.prototype.dataLocation=0,s.prototype.doubleData=h.emptyArray,s.prototype.uint64Data=h.emptyArray,s.create=function(t){return new s(t)},s.encode=function(t,l){if(l||(l=f.create()),t.dims!=null&&t.dims.length){l.uint32(10).fork();for(var u=0;u<t.dims.length;++u)l.int64(t.dims[u]);l.ldelim()}if(t.dataType!=null&&Object.hasOwnProperty.call(t,"dataType")&&l.uint32(16).int32(t.dataType),t.segment!=null&&Object.hasOwnProperty.call(t,"segment")&&p.onnx.TensorProto.Segment.encode(t.segment,l.uint32(26).fork()).ldelim(),t.floatData!=null&&t.floatData.length){for(l.uint32(34).fork(),u=0;u<t.floatData.length;++u)l.float(t.floatData[u]);l.ldelim()}if(t.int32Data!=null&&t.int32Data.length){for(l.uint32(42).fork(),u=0;u<t.int32Data.length;++u)l.int32(t.int32Data[u]);l.ldelim()}if(t.stringData!=null&&t.stringData.length)for(u=0;u<t.stringData.length;++u)l.uint32(50).bytes(t.stringData[u]);if(t.int64Data!=null&&t.int64Data.length){for(l.uint32(58).fork(),u=0;u<t.int64Data.length;++u)l.int64(t.int64Data[u]);l.ldelim()}if(t.name!=null&&Object.hasOwnProperty.call(t,"name")&&l.uint32(66).string(t.name),t.rawData!=null&&Object.hasOwnProperty.call(t,"rawData")&&l.uint32(74).bytes(t.rawData),t.doubleData!=null&&t.doubleData.length){for(l.uint32(82).fork(),u=0;u<t.doubleData.length;++u)l.double(t.doubleData[u]);l.ldelim()}if(t.uint64Data!=null&&t.uint64Data.length){for(l.uint32(90).fork(),u=0;u<t.uint64Data.length;++u)l.uint64(t.uint64Data[u]);l.ldelim()}if(t.docString!=null&&Object.hasOwnProperty.call(t,"docString")&&l.uint32(98).string(t.docString),t.externalData!=null&&t.externalData.length)for(u=0;u<t.externalData.length;++u)p.onnx.StringStringEntryProto.encode(t.externalData[u],l.uint32(106).fork()).ldelim();return t.dataLocation!=null&&Object.hasOwnProperty.call(t,"dataLocation")&&l.uint32(112).int32(t.dataLocation),l},s.encodeDelimited=function(t,l){return this.encode(t,l).ldelim()},s.decode=function(t,l){t instanceof d||(t=d.create(t));for(var u=l===void 0?t.len:t.pos+l,g=new p.onnx.TensorProto;t.pos<u;){var m=t.uint32();switch(m>>>3){case 1:if(g.dims&&g.dims.length||(g.dims=[]),(7&m)==2)for(var _=t.uint32()+t.pos;t.pos<_;)g.dims.push(t.int64());else g.dims.push(t.int64());break;case 2:g.dataType=t.int32();break;case 3:g.segment=p.onnx.TensorProto.Segment.decode(t,t.uint32());break;case 4:if(g.floatData&&g.floatData.length||(g.floatData=[]),(7&m)==2)for(_=t.uint32()+t.pos;t.pos<_;)g.floatData.push(t.float());else g.floatData.push(t.float());break;case 5:if(g.int32Data&&g.int32Data.length||(g.int32Data=[]),(7&m)==2)for(_=t.uint32()+t.pos;t.pos<_;)g.int32Data.push(t.int32());else g.int32Data.push(t.int32());break;case 6:g.stringData&&g.stringData.length||(g.stringData=[]),g.stringData.push(t.bytes());break;case 7:if(g.int64Data&&g.int64Data.length||(g.int64Data=[]),(7&m)==2)for(_=t.uint32()+t.pos;t.pos<_;)g.int64Data.push(t.int64());else g.int64Data.push(t.int64());break;case 8:g.name=t.string();break;case 12:g.docString=t.string();break;case 9:g.rawData=t.bytes();break;case 13:g.externalData&&g.externalData.length||(g.externalData=[]),g.externalData.push(p.onnx.StringStringEntryProto.decode(t,t.uint32()));break;case 14:g.dataLocation=t.int32();break;case 10:if(g.doubleData&&g.doubleData.length||(g.doubleData=[]),(7&m)==2)for(_=t.uint32()+t.pos;t.pos<_;)g.doubleData.push(t.double());else g.doubleData.push(t.double());break;case 11:if(g.uint64Data&&g.uint64Data.length||(g.uint64Data=[]),(7&m)==2)for(_=t.uint32()+t.pos;t.pos<_;)g.uint64Data.push(t.uint64());else g.uint64Data.push(t.uint64());break;default:t.skipType(7&m)}}return g},s.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},s.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.dims!=null&&t.hasOwnProperty("dims")){if(!Array.isArray(t.dims))return"dims: array expected";for(var l=0;l<t.dims.length;++l)if(!(h.isInteger(t.dims[l])||t.dims[l]&&h.isInteger(t.dims[l].low)&&h.isInteger(t.dims[l].high)))return"dims: integer|Long[] expected"}if(t.dataType!=null&&t.hasOwnProperty("dataType")&&!h.isInteger(t.dataType))return"dataType: integer expected";if(t.segment!=null&&t.hasOwnProperty("segment")&&(u=p.onnx.TensorProto.Segment.verify(t.segment)))return"segment."+u;if(t.floatData!=null&&t.hasOwnProperty("floatData")){if(!Array.isArray(t.floatData))return"floatData: array expected";for(l=0;l<t.floatData.length;++l)if(typeof t.floatData[l]!="number")return"floatData: number[] expected"}if(t.int32Data!=null&&t.hasOwnProperty("int32Data")){if(!Array.isArray(t.int32Data))return"int32Data: array expected";for(l=0;l<t.int32Data.length;++l)if(!h.isInteger(t.int32Data[l]))return"int32Data: integer[] expected"}if(t.stringData!=null&&t.hasOwnProperty("stringData")){if(!Array.isArray(t.stringData))return"stringData: array expected";for(l=0;l<t.stringData.length;++l)if(!(t.stringData[l]&&typeof t.stringData[l].length=="number"||h.isString(t.stringData[l])))return"stringData: buffer[] expected"}if(t.int64Data!=null&&t.hasOwnProperty("int64Data")){if(!Array.isArray(t.int64Data))return"int64Data: array expected";for(l=0;l<t.int64Data.length;++l)if(!(h.isInteger(t.int64Data[l])||t.int64Data[l]&&h.isInteger(t.int64Data[l].low)&&h.isInteger(t.int64Data[l].high)))return"int64Data: integer|Long[] expected"}if(t.name!=null&&t.hasOwnProperty("name")&&!h.isString(t.name))return"name: string expected";if(t.docString!=null&&t.hasOwnProperty("docString")&&!h.isString(t.docString))return"docString: string expected";if(t.rawData!=null&&t.hasOwnProperty("rawData")&&!(t.rawData&&typeof t.rawData.length=="number"||h.isString(t.rawData)))return"rawData: buffer expected";if(t.externalData!=null&&t.hasOwnProperty("externalData")){if(!Array.isArray(t.externalData))return"externalData: array expected";for(l=0;l<t.externalData.length;++l){var u;if(u=p.onnx.StringStringEntryProto.verify(t.externalData[l]))return"externalData."+u}}if(t.dataLocation!=null&&t.hasOwnProperty("dataLocation"))switch(t.dataLocation){default:return"dataLocation: enum value expected";case 0:case 1:}if(t.doubleData!=null&&t.hasOwnProperty("doubleData")){if(!Array.isArray(t.doubleData))return"doubleData: array expected";for(l=0;l<t.doubleData.length;++l)if(typeof t.doubleData[l]!="number")return"doubleData: number[] expected"}if(t.uint64Data!=null&&t.hasOwnProperty("uint64Data")){if(!Array.isArray(t.uint64Data))return"uint64Data: array expected";for(l=0;l<t.uint64Data.length;++l)if(!(h.isInteger(t.uint64Data[l])||t.uint64Data[l]&&h.isInteger(t.uint64Data[l].low)&&h.isInteger(t.uint64Data[l].high)))return"uint64Data: integer|Long[] expected"}return null},s.fromObject=function(t){if(t instanceof p.onnx.TensorProto)return t;var l=new p.onnx.TensorProto;if(t.dims){if(!Array.isArray(t.dims))throw TypeError(".onnx.TensorProto.dims: array expected");l.dims=[];for(var u=0;u<t.dims.length;++u)h.Long?(l.dims[u]=h.Long.fromValue(t.dims[u])).unsigned=!1:typeof t.dims[u]=="string"?l.dims[u]=parseInt(t.dims[u],10):typeof t.dims[u]=="number"?l.dims[u]=t.dims[u]:typeof t.dims[u]=="object"&&(l.dims[u]=new h.LongBits(t.dims[u].low>>>0,t.dims[u].high>>>0).toNumber())}if(t.dataType!=null&&(l.dataType=0|t.dataType),t.segment!=null){if(typeof t.segment!="object")throw TypeError(".onnx.TensorProto.segment: object expected");l.segment=p.onnx.TensorProto.Segment.fromObject(t.segment)}if(t.floatData){if(!Array.isArray(t.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");for(l.floatData=[],u=0;u<t.floatData.length;++u)l.floatData[u]=Number(t.floatData[u])}if(t.int32Data){if(!Array.isArray(t.int32Data))throw TypeError(".onnx.TensorProto.int32Data: array expected");for(l.int32Data=[],u=0;u<t.int32Data.length;++u)l.int32Data[u]=0|t.int32Data[u]}if(t.stringData){if(!Array.isArray(t.stringData))throw TypeError(".onnx.TensorProto.stringData: array expected");for(l.stringData=[],u=0;u<t.stringData.length;++u)typeof t.stringData[u]=="string"?h.base64.decode(t.stringData[u],l.stringData[u]=h.newBuffer(h.base64.length(t.stringData[u])),0):t.stringData[u].length>=0&&(l.stringData[u]=t.stringData[u])}if(t.int64Data){if(!Array.isArray(t.int64Data))throw TypeError(".onnx.TensorProto.int64Data: array expected");for(l.int64Data=[],u=0;u<t.int64Data.length;++u)h.Long?(l.int64Data[u]=h.Long.fromValue(t.int64Data[u])).unsigned=!1:typeof t.int64Data[u]=="string"?l.int64Data[u]=parseInt(t.int64Data[u],10):typeof t.int64Data[u]=="number"?l.int64Data[u]=t.int64Data[u]:typeof t.int64Data[u]=="object"&&(l.int64Data[u]=new h.LongBits(t.int64Data[u].low>>>0,t.int64Data[u].high>>>0).toNumber())}if(t.name!=null&&(l.name=String(t.name)),t.docString!=null&&(l.docString=String(t.docString)),t.rawData!=null&&(typeof t.rawData=="string"?h.base64.decode(t.rawData,l.rawData=h.newBuffer(h.base64.length(t.rawData)),0):t.rawData.length>=0&&(l.rawData=t.rawData)),t.externalData){if(!Array.isArray(t.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");for(l.externalData=[],u=0;u<t.externalData.length;++u){if(typeof t.externalData[u]!="object")throw TypeError(".onnx.TensorProto.externalData: object expected");l.externalData[u]=p.onnx.StringStringEntryProto.fromObject(t.externalData[u])}}switch(t.dataLocation){default:if(typeof t.dataLocation=="number"){l.dataLocation=t.dataLocation;break}break;case"DEFAULT":case 0:l.dataLocation=0;break;case"EXTERNAL":case 1:l.dataLocation=1}if(t.doubleData){if(!Array.isArray(t.doubleData))throw TypeError(".onnx.TensorProto.doubleData: array expected");for(l.doubleData=[],u=0;u<t.doubleData.length;++u)l.doubleData[u]=Number(t.doubleData[u])}if(t.uint64Data){if(!Array.isArray(t.uint64Data))throw TypeError(".onnx.TensorProto.uint64Data: array expected");for(l.uint64Data=[],u=0;u<t.uint64Data.length;++u)h.Long?(l.uint64Data[u]=h.Long.fromValue(t.uint64Data[u])).unsigned=!0:typeof t.uint64Data[u]=="string"?l.uint64Data[u]=parseInt(t.uint64Data[u],10):typeof t.uint64Data[u]=="number"?l.uint64Data[u]=t.uint64Data[u]:typeof t.uint64Data[u]=="object"&&(l.uint64Data[u]=new h.LongBits(t.uint64Data[u].low>>>0,t.uint64Data[u].high>>>0).toNumber(!0))}return l},s.toObject=function(t,l){l||(l={});var u={};if((l.arrays||l.defaults)&&(u.dims=[],u.floatData=[],u.int32Data=[],u.stringData=[],u.int64Data=[],u.doubleData=[],u.uint64Data=[],u.externalData=[]),l.defaults&&(u.dataType=0,u.segment=null,u.name="",l.bytes===String?u.rawData="":(u.rawData=[],l.bytes!==Array&&(u.rawData=h.newBuffer(u.rawData))),u.docString="",u.dataLocation=l.enums===String?"DEFAULT":0),t.dims&&t.dims.length){u.dims=[];for(var g=0;g<t.dims.length;++g)typeof t.dims[g]=="number"?u.dims[g]=l.longs===String?String(t.dims[g]):t.dims[g]:u.dims[g]=l.longs===String?h.Long.prototype.toString.call(t.dims[g]):l.longs===Number?new h.LongBits(t.dims[g].low>>>0,t.dims[g].high>>>0).toNumber():t.dims[g]}if(t.dataType!=null&&t.hasOwnProperty("dataType")&&(u.dataType=t.dataType),t.segment!=null&&t.hasOwnProperty("segment")&&(u.segment=p.onnx.TensorProto.Segment.toObject(t.segment,l)),t.floatData&&t.floatData.length)for(u.floatData=[],g=0;g<t.floatData.length;++g)u.floatData[g]=l.json&&!isFinite(t.floatData[g])?String(t.floatData[g]):t.floatData[g];if(t.int32Data&&t.int32Data.length)for(u.int32Data=[],g=0;g<t.int32Data.length;++g)u.int32Data[g]=t.int32Data[g];if(t.stringData&&t.stringData.length)for(u.stringData=[],g=0;g<t.stringData.length;++g)u.stringData[g]=l.bytes===String?h.base64.encode(t.stringData[g],0,t.stringData[g].length):l.bytes===Array?Array.prototype.slice.call(t.stringData[g]):t.stringData[g];if(t.int64Data&&t.int64Data.length)for(u.int64Data=[],g=0;g<t.int64Data.length;++g)typeof t.int64Data[g]=="number"?u.int64Data[g]=l.longs===String?String(t.int64Data[g]):t.int64Data[g]:u.int64Data[g]=l.longs===String?h.Long.prototype.toString.call(t.int64Data[g]):l.longs===Number?new h.LongBits(t.int64Data[g].low>>>0,t.int64Data[g].high>>>0).toNumber():t.int64Data[g];if(t.name!=null&&t.hasOwnProperty("name")&&(u.name=t.name),t.rawData!=null&&t.hasOwnProperty("rawData")&&(u.rawData=l.bytes===String?h.base64.encode(t.rawData,0,t.rawData.length):l.bytes===Array?Array.prototype.slice.call(t.rawData):t.rawData),t.doubleData&&t.doubleData.length)for(u.doubleData=[],g=0;g<t.doubleData.length;++g)u.doubleData[g]=l.json&&!isFinite(t.doubleData[g])?String(t.doubleData[g]):t.doubleData[g];if(t.uint64Data&&t.uint64Data.length)for(u.uint64Data=[],g=0;g<t.uint64Data.length;++g)typeof t.uint64Data[g]=="number"?u.uint64Data[g]=l.longs===String?String(t.uint64Data[g]):t.uint64Data[g]:u.uint64Data[g]=l.longs===String?h.Long.prototype.toString.call(t.uint64Data[g]):l.longs===Number?new h.LongBits(t.uint64Data[g].low>>>0,t.uint64Data[g].high>>>0).toNumber(!0):t.uint64Data[g];if(t.docString!=null&&t.hasOwnProperty("docString")&&(u.docString=t.docString),t.externalData&&t.externalData.length)for(u.externalData=[],g=0;g<t.externalData.length;++g)u.externalData[g]=p.onnx.StringStringEntryProto.toObject(t.externalData[g],l);return t.dataLocation!=null&&t.hasOwnProperty("dataLocation")&&(u.dataLocation=l.enums===String?p.onnx.TensorProto.DataLocation[t.dataLocation]===void 0?t.dataLocation:p.onnx.TensorProto.DataLocation[t.dataLocation]:t.dataLocation),u},s.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},s.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.TensorProto"},s.DataType=function(){var t={},l=Object.create(t);return l[t[0]="UNDEFINED"]=0,l[t[1]="FLOAT"]=1,l[t[2]="UINT8"]=2,l[t[3]="INT8"]=3,l[t[4]="UINT16"]=4,l[t[5]="INT16"]=5,l[t[6]="INT32"]=6,l[t[7]="INT64"]=7,l[t[8]="STRING"]=8,l[t[9]="BOOL"]=9,l[t[10]="FLOAT16"]=10,l[t[11]="DOUBLE"]=11,l[t[12]="UINT32"]=12,l[t[13]="UINT64"]=13,l[t[14]="COMPLEX64"]=14,l[t[15]="COMPLEX128"]=15,l[t[16]="BFLOAT16"]=16,l[t[17]="FLOAT8E4M3FN"]=17,l[t[18]="FLOAT8E4M3FNUZ"]=18,l[t[19]="FLOAT8E5M2"]=19,l[t[20]="FLOAT8E5M2FNUZ"]=20,l}(),s.Segment=function(){function t(l){if(l)for(var u=Object.keys(l),g=0;g<u.length;++g)l[u[g]]!=null&&(this[u[g]]=l[u[g]])}return t.prototype.begin=h.Long?h.Long.fromBits(0,0,!1):0,t.prototype.end=h.Long?h.Long.fromBits(0,0,!1):0,t.create=function(l){return new t(l)},t.encode=function(l,u){return u||(u=f.create()),l.begin!=null&&Object.hasOwnProperty.call(l,"begin")&&u.uint32(8).int64(l.begin),l.end!=null&&Object.hasOwnProperty.call(l,"end")&&u.uint32(16).int64(l.end),u},t.encodeDelimited=function(l,u){return this.encode(l,u).ldelim()},t.decode=function(l,u){l instanceof d||(l=d.create(l));for(var g=u===void 0?l.len:l.pos+u,m=new p.onnx.TensorProto.Segment;l.pos<g;){var _=l.uint32();switch(_>>>3){case 1:m.begin=l.int64();break;case 2:m.end=l.int64();break;default:l.skipType(7&_)}}return m},t.decodeDelimited=function(l){return l instanceof d||(l=new d(l)),this.decode(l,l.uint32())},t.verify=function(l){return typeof l!="object"||l===null?"object expected":l.begin!=null&&l.hasOwnProperty("begin")&&!(h.isInteger(l.begin)||l.begin&&h.isInteger(l.begin.low)&&h.isInteger(l.begin.high))?"begin: integer|Long expected":l.end!=null&&l.hasOwnProperty("end")&&!(h.isInteger(l.end)||l.end&&h.isInteger(l.end.low)&&h.isInteger(l.end.high))?"end: integer|Long expected":null},t.fromObject=function(l){if(l instanceof p.onnx.TensorProto.Segment)return l;var u=new p.onnx.TensorProto.Segment;return l.begin!=null&&(h.Long?(u.begin=h.Long.fromValue(l.begin)).unsigned=!1:typeof l.begin=="string"?u.begin=parseInt(l.begin,10):typeof l.begin=="number"?u.begin=l.begin:typeof l.begin=="object"&&(u.begin=new h.LongBits(l.begin.low>>>0,l.begin.high>>>0).toNumber())),l.end!=null&&(h.Long?(u.end=h.Long.fromValue(l.end)).unsigned=!1:typeof l.end=="string"?u.end=parseInt(l.end,10):typeof l.end=="number"?u.end=l.end:typeof l.end=="object"&&(u.end=new h.LongBits(l.end.low>>>0,l.end.high>>>0).toNumber())),u},t.toObject=function(l,u){u||(u={});var g={};if(u.defaults){if(h.Long){var m=new h.Long(0,0,!1);g.begin=u.longs===String?m.toString():u.longs===Number?m.toNumber():m}else g.begin=u.longs===String?"0":0;h.Long?(m=new h.Long(0,0,!1),g.end=u.longs===String?m.toString():u.longs===Number?m.toNumber():m):g.end=u.longs===String?"0":0}return l.begin!=null&&l.hasOwnProperty("begin")&&(typeof l.begin=="number"?g.begin=u.longs===String?String(l.begin):l.begin:g.begin=u.longs===String?h.Long.prototype.toString.call(l.begin):u.longs===Number?new h.LongBits(l.begin.low>>>0,l.begin.high>>>0).toNumber():l.begin),l.end!=null&&l.hasOwnProperty("end")&&(typeof l.end=="number"?g.end=u.longs===String?String(l.end):l.end:g.end=u.longs===String?h.Long.prototype.toString.call(l.end):u.longs===Number?new h.LongBits(l.end.low>>>0,l.end.high>>>0).toNumber():l.end),g},t.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},t.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TensorProto.Segment"},t}(),s.DataLocation=function(){var t={},l=Object.create(t);return l[t[0]="DEFAULT"]=0,l[t[1]="EXTERNAL"]=1,l}(),s}(),o.SparseTensorProto=function(){function s(t){if(this.dims=[],t)for(var l=Object.keys(t),u=0;u<l.length;++u)t[l[u]]!=null&&(this[l[u]]=t[l[u]])}return s.prototype.values=null,s.prototype.indices=null,s.prototype.dims=h.emptyArray,s.create=function(t){return new s(t)},s.encode=function(t,l){if(l||(l=f.create()),t.values!=null&&Object.hasOwnProperty.call(t,"values")&&p.onnx.TensorProto.encode(t.values,l.uint32(10).fork()).ldelim(),t.indices!=null&&Object.hasOwnProperty.call(t,"indices")&&p.onnx.TensorProto.encode(t.indices,l.uint32(18).fork()).ldelim(),t.dims!=null&&t.dims.length){l.uint32(26).fork();for(var u=0;u<t.dims.length;++u)l.int64(t.dims[u]);l.ldelim()}return l},s.encodeDelimited=function(t,l){return this.encode(t,l).ldelim()},s.decode=function(t,l){t instanceof d||(t=d.create(t));for(var u=l===void 0?t.len:t.pos+l,g=new p.onnx.SparseTensorProto;t.pos<u;){var m=t.uint32();switch(m>>>3){case 1:g.values=p.onnx.TensorProto.decode(t,t.uint32());break;case 2:g.indices=p.onnx.TensorProto.decode(t,t.uint32());break;case 3:if(g.dims&&g.dims.length||(g.dims=[]),(7&m)==2)for(var _=t.uint32()+t.pos;t.pos<_;)g.dims.push(t.int64());else g.dims.push(t.int64());break;default:t.skipType(7&m)}}return g},s.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},s.verify=function(t){if(typeof t!="object"||t===null)return"object expected";var l;if(t.values!=null&&t.hasOwnProperty("values")&&(l=p.onnx.TensorProto.verify(t.values)))return"values."+l;if(t.indices!=null&&t.hasOwnProperty("indices")&&(l=p.onnx.TensorProto.verify(t.indices)))return"indices."+l;if(t.dims!=null&&t.hasOwnProperty("dims")){if(!Array.isArray(t.dims))return"dims: array expected";for(var u=0;u<t.dims.length;++u)if(!(h.isInteger(t.dims[u])||t.dims[u]&&h.isInteger(t.dims[u].low)&&h.isInteger(t.dims[u].high)))return"dims: integer|Long[] expected"}return null},s.fromObject=function(t){if(t instanceof p.onnx.SparseTensorProto)return t;var l=new p.onnx.SparseTensorProto;if(t.values!=null){if(typeof t.values!="object")throw TypeError(".onnx.SparseTensorProto.values: object expected");l.values=p.onnx.TensorProto.fromObject(t.values)}if(t.indices!=null){if(typeof t.indices!="object")throw TypeError(".onnx.SparseTensorProto.indices: object expected");l.indices=p.onnx.TensorProto.fromObject(t.indices)}if(t.dims){if(!Array.isArray(t.dims))throw TypeError(".onnx.SparseTensorProto.dims: array expected");l.dims=[];for(var u=0;u<t.dims.length;++u)h.Long?(l.dims[u]=h.Long.fromValue(t.dims[u])).unsigned=!1:typeof t.dims[u]=="string"?l.dims[u]=parseInt(t.dims[u],10):typeof t.dims[u]=="number"?l.dims[u]=t.dims[u]:typeof t.dims[u]=="object"&&(l.dims[u]=new h.LongBits(t.dims[u].low>>>0,t.dims[u].high>>>0).toNumber())}return l},s.toObject=function(t,l){l||(l={});var u={};if((l.arrays||l.defaults)&&(u.dims=[]),l.defaults&&(u.values=null,u.indices=null),t.values!=null&&t.hasOwnProperty("values")&&(u.values=p.onnx.TensorProto.toObject(t.values,l)),t.indices!=null&&t.hasOwnProperty("indices")&&(u.indices=p.onnx.TensorProto.toObject(t.indices,l)),t.dims&&t.dims.length){u.dims=[];for(var g=0;g<t.dims.length;++g)typeof t.dims[g]=="number"?u.dims[g]=l.longs===String?String(t.dims[g]):t.dims[g]:u.dims[g]=l.longs===String?h.Long.prototype.toString.call(t.dims[g]):l.longs===Number?new h.LongBits(t.dims[g].low>>>0,t.dims[g].high>>>0).toNumber():t.dims[g]}return u},s.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},s.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.SparseTensorProto"},s}(),o.TensorShapeProto=function(){function s(t){if(this.dim=[],t)for(var l=Object.keys(t),u=0;u<l.length;++u)t[l[u]]!=null&&(this[l[u]]=t[l[u]])}return s.prototype.dim=h.emptyArray,s.create=function(t){return new s(t)},s.encode=function(t,l){if(l||(l=f.create()),t.dim!=null&&t.dim.length)for(var u=0;u<t.dim.length;++u)p.onnx.TensorShapeProto.Dimension.encode(t.dim[u],l.uint32(10).fork()).ldelim();return l},s.encodeDelimited=function(t,l){return this.encode(t,l).ldelim()},s.decode=function(t,l){t instanceof d||(t=d.create(t));for(var u=l===void 0?t.len:t.pos+l,g=new p.onnx.TensorShapeProto;t.pos<u;){var m=t.uint32();m>>>3==1?(g.dim&&g.dim.length||(g.dim=[]),g.dim.push(p.onnx.TensorShapeProto.Dimension.decode(t,t.uint32()))):t.skipType(7&m)}return g},s.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},s.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.dim!=null&&t.hasOwnProperty("dim")){if(!Array.isArray(t.dim))return"dim: array expected";for(var l=0;l<t.dim.length;++l){var u=p.onnx.TensorShapeProto.Dimension.verify(t.dim[l]);if(u)return"dim."+u}}return null},s.fromObject=function(t){if(t instanceof p.onnx.TensorShapeProto)return t;var l=new p.onnx.TensorShapeProto;if(t.dim){if(!Array.isArray(t.dim))throw TypeError(".onnx.TensorShapeProto.dim: array expected");l.dim=[];for(var u=0;u<t.dim.length;++u){if(typeof t.dim[u]!="object")throw TypeError(".onnx.TensorShapeProto.dim: object expected");l.dim[u]=p.onnx.TensorShapeProto.Dimension.fromObject(t.dim[u])}}return l},s.toObject=function(t,l){l||(l={});var u={};if((l.arrays||l.defaults)&&(u.dim=[]),t.dim&&t.dim.length){u.dim=[];for(var g=0;g<t.dim.length;++g)u.dim[g]=p.onnx.TensorShapeProto.Dimension.toObject(t.dim[g],l)}return u},s.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},s.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.TensorShapeProto"},s.Dimension=function(){function t(u){if(u)for(var g=Object.keys(u),m=0;m<g.length;++m)u[g[m]]!=null&&(this[g[m]]=u[g[m]])}var l;return t.prototype.dimValue=null,t.prototype.dimParam=null,t.prototype.denotation="",Object.defineProperty(t.prototype,"value",{get:h.oneOfGetter(l=["dimValue","dimParam"]),set:h.oneOfSetter(l)}),t.create=function(u){return new t(u)},t.encode=function(u,g){return g||(g=f.create()),u.dimValue!=null&&Object.hasOwnProperty.call(u,"dimValue")&&g.uint32(8).int64(u.dimValue),u.dimParam!=null&&Object.hasOwnProperty.call(u,"dimParam")&&g.uint32(18).string(u.dimParam),u.denotation!=null&&Object.hasOwnProperty.call(u,"denotation")&&g.uint32(26).string(u.denotation),g},t.encodeDelimited=function(u,g){return this.encode(u,g).ldelim()},t.decode=function(u,g){u instanceof d||(u=d.create(u));for(var m=g===void 0?u.len:u.pos+g,_=new p.onnx.TensorShapeProto.Dimension;u.pos<m;){var b=u.uint32();switch(b>>>3){case 1:_.dimValue=u.int64();break;case 2:_.dimParam=u.string();break;case 3:_.denotation=u.string();break;default:u.skipType(7&b)}}return _},t.decodeDelimited=function(u){return u instanceof d||(u=new d(u)),this.decode(u,u.uint32())},t.verify=function(u){if(typeof u!="object"||u===null)return"object expected";var g={};if(u.dimValue!=null&&u.hasOwnProperty("dimValue")&&(g.value=1,!(h.isInteger(u.dimValue)||u.dimValue&&h.isInteger(u.dimValue.low)&&h.isInteger(u.dimValue.high))))return"dimValue: integer|Long expected";if(u.dimParam!=null&&u.hasOwnProperty("dimParam")){if(g.value===1)return"value: multiple values";if(g.value=1,!h.isString(u.dimParam))return"dimParam: string expected"}return u.denotation!=null&&u.hasOwnProperty("denotation")&&!h.isString(u.denotation)?"denotation: string expected":null},t.fromObject=function(u){if(u instanceof p.onnx.TensorShapeProto.Dimension)return u;var g=new p.onnx.TensorShapeProto.Dimension;return u.dimValue!=null&&(h.Long?(g.dimValue=h.Long.fromValue(u.dimValue)).unsigned=!1:typeof u.dimValue=="string"?g.dimValue=parseInt(u.dimValue,10):typeof u.dimValue=="number"?g.dimValue=u.dimValue:typeof u.dimValue=="object"&&(g.dimValue=new h.LongBits(u.dimValue.low>>>0,u.dimValue.high>>>0).toNumber())),u.dimParam!=null&&(g.dimParam=String(u.dimParam)),u.denotation!=null&&(g.denotation=String(u.denotation)),g},t.toObject=function(u,g){g||(g={});var m={};return g.defaults&&(m.denotation=""),u.dimValue!=null&&u.hasOwnProperty("dimValue")&&(typeof u.dimValue=="number"?m.dimValue=g.longs===String?String(u.dimValue):u.dimValue:m.dimValue=g.longs===String?h.Long.prototype.toString.call(u.dimValue):g.longs===Number?new h.LongBits(u.dimValue.low>>>0,u.dimValue.high>>>0).toNumber():u.dimValue,g.oneofs&&(m.value="dimValue")),u.dimParam!=null&&u.hasOwnProperty("dimParam")&&(m.dimParam=u.dimParam,g.oneofs&&(m.value="dimParam")),u.denotation!=null&&u.hasOwnProperty("denotation")&&(m.denotation=u.denotation),m},t.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},t.getTypeUrl=function(u){return u===void 0&&(u="type.googleapis.com"),u+"/onnx.TensorShapeProto.Dimension"},t}(),s}(),o.TypeProto=function(){function s(l){if(l)for(var u=Object.keys(l),g=0;g<u.length;++g)l[u[g]]!=null&&(this[u[g]]=l[u[g]])}var t;return s.prototype.tensorType=null,s.prototype.sequenceType=null,s.prototype.mapType=null,s.prototype.optionalType=null,s.prototype.sparseTensorType=null,s.prototype.denotation="",Object.defineProperty(s.prototype,"value",{get:h.oneOfGetter(t=["tensorType","sequenceType","mapType","optionalType","sparseTensorType"]),set:h.oneOfSetter(t)}),s.create=function(l){return new s(l)},s.encode=function(l,u){return u||(u=f.create()),l.tensorType!=null&&Object.hasOwnProperty.call(l,"tensorType")&&p.onnx.TypeProto.Tensor.encode(l.tensorType,u.uint32(10).fork()).ldelim(),l.sequenceType!=null&&Object.hasOwnProperty.call(l,"sequenceType")&&p.onnx.TypeProto.Sequence.encode(l.sequenceType,u.uint32(34).fork()).ldelim(),l.mapType!=null&&Object.hasOwnProperty.call(l,"mapType")&&p.onnx.TypeProto.Map.encode(l.mapType,u.uint32(42).fork()).ldelim(),l.denotation!=null&&Object.hasOwnProperty.call(l,"denotation")&&u.uint32(50).string(l.denotation),l.sparseTensorType!=null&&Object.hasOwnProperty.call(l,"sparseTensorType")&&p.onnx.TypeProto.SparseTensor.encode(l.sparseTensorType,u.uint32(66).fork()).ldelim(),l.optionalType!=null&&Object.hasOwnProperty.call(l,"optionalType")&&p.onnx.TypeProto.Optional.encode(l.optionalType,u.uint32(74).fork()).ldelim(),u},s.encodeDelimited=function(l,u){return this.encode(l,u).ldelim()},s.decode=function(l,u){l instanceof d||(l=d.create(l));for(var g=u===void 0?l.len:l.pos+u,m=new p.onnx.TypeProto;l.pos<g;){var _=l.uint32();switch(_>>>3){case 1:m.tensorType=p.onnx.TypeProto.Tensor.decode(l,l.uint32());break;case 4:m.sequenceType=p.onnx.TypeProto.Sequence.decode(l,l.uint32());break;case 5:m.mapType=p.onnx.TypeProto.Map.decode(l,l.uint32());break;case 9:m.optionalType=p.onnx.TypeProto.Optional.decode(l,l.uint32());break;case 8:m.sparseTensorType=p.onnx.TypeProto.SparseTensor.decode(l,l.uint32());break;case 6:m.denotation=l.string();break;default:l.skipType(7&_)}}return m},s.decodeDelimited=function(l){return l instanceof d||(l=new d(l)),this.decode(l,l.uint32())},s.verify=function(l){if(typeof l!="object"||l===null)return"object expected";var u={};if(l.tensorType!=null&&l.hasOwnProperty("tensorType")&&(u.value=1,g=p.onnx.TypeProto.Tensor.verify(l.tensorType)))return"tensorType."+g;if(l.sequenceType!=null&&l.hasOwnProperty("sequenceType")){if(u.value===1)return"value: multiple values";if(u.value=1,g=p.onnx.TypeProto.Sequence.verify(l.sequenceType))return"sequenceType."+g}if(l.mapType!=null&&l.hasOwnProperty("mapType")){if(u.value===1)return"value: multiple values";if(u.value=1,g=p.onnx.TypeProto.Map.verify(l.mapType))return"mapType."+g}if(l.optionalType!=null&&l.hasOwnProperty("optionalType")){if(u.value===1)return"value: multiple values";if(u.value=1,g=p.onnx.TypeProto.Optional.verify(l.optionalType))return"optionalType."+g}if(l.sparseTensorType!=null&&l.hasOwnProperty("sparseTensorType")){if(u.value===1)return"value: multiple values";var g;if(u.value=1,g=p.onnx.TypeProto.SparseTensor.verify(l.sparseTensorType))return"sparseTensorType."+g}return l.denotation!=null&&l.hasOwnProperty("denotation")&&!h.isString(l.denotation)?"denotation: string expected":null},s.fromObject=function(l){if(l instanceof p.onnx.TypeProto)return l;var u=new p.onnx.TypeProto;if(l.tensorType!=null){if(typeof l.tensorType!="object")throw TypeError(".onnx.TypeProto.tensorType: object expected");u.tensorType=p.onnx.TypeProto.Tensor.fromObject(l.tensorType)}if(l.sequenceType!=null){if(typeof l.sequenceType!="object")throw TypeError(".onnx.TypeProto.sequenceType: object expected");u.sequenceType=p.onnx.TypeProto.Sequence.fromObject(l.sequenceType)}if(l.mapType!=null){if(typeof l.mapType!="object")throw TypeError(".onnx.TypeProto.mapType: object expected");u.mapType=p.onnx.TypeProto.Map.fromObject(l.mapType)}if(l.optionalType!=null){if(typeof l.optionalType!="object")throw TypeError(".onnx.TypeProto.optionalType: object expected");u.optionalType=p.onnx.TypeProto.Optional.fromObject(l.optionalType)}if(l.sparseTensorType!=null){if(typeof l.sparseTensorType!="object")throw TypeError(".onnx.TypeProto.sparseTensorType: object expected");u.sparseTensorType=p.onnx.TypeProto.SparseTensor.fromObject(l.sparseTensorType)}return l.denotation!=null&&(u.denotation=String(l.denotation)),u},s.toObject=function(l,u){u||(u={});var g={};return u.defaults&&(g.denotation=""),l.tensorType!=null&&l.hasOwnProperty("tensorType")&&(g.tensorType=p.onnx.TypeProto.Tensor.toObject(l.tensorType,u),u.oneofs&&(g.value="tensorType")),l.sequenceType!=null&&l.hasOwnProperty("sequenceType")&&(g.sequenceType=p.onnx.TypeProto.Sequence.toObject(l.sequenceType,u),u.oneofs&&(g.value="sequenceType")),l.mapType!=null&&l.hasOwnProperty("mapType")&&(g.mapType=p.onnx.TypeProto.Map.toObject(l.mapType,u),u.oneofs&&(g.value="mapType")),l.denotation!=null&&l.hasOwnProperty("denotation")&&(g.denotation=l.denotation),l.sparseTensorType!=null&&l.hasOwnProperty("sparseTensorType")&&(g.sparseTensorType=p.onnx.TypeProto.SparseTensor.toObject(l.sparseTensorType,u),u.oneofs&&(g.value="sparseTensorType")),l.optionalType!=null&&l.hasOwnProperty("optionalType")&&(g.optionalType=p.onnx.TypeProto.Optional.toObject(l.optionalType,u),u.oneofs&&(g.value="optionalType")),g},s.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},s.getTypeUrl=function(l){return l===void 0&&(l="type.googleapis.com"),l+"/onnx.TypeProto"},s.Tensor=function(){function l(u){if(u)for(var g=Object.keys(u),m=0;m<g.length;++m)u[g[m]]!=null&&(this[g[m]]=u[g[m]])}return l.prototype.elemType=0,l.prototype.shape=null,l.create=function(u){return new l(u)},l.encode=function(u,g){return g||(g=f.create()),u.elemType!=null&&Object.hasOwnProperty.call(u,"elemType")&&g.uint32(8).int32(u.elemType),u.shape!=null&&Object.hasOwnProperty.call(u,"shape")&&p.onnx.TensorShapeProto.encode(u.shape,g.uint32(18).fork()).ldelim(),g},l.encodeDelimited=function(u,g){return this.encode(u,g).ldelim()},l.decode=function(u,g){u instanceof d||(u=d.create(u));for(var m=g===void 0?u.len:u.pos+g,_=new p.onnx.TypeProto.Tensor;u.pos<m;){var b=u.uint32();switch(b>>>3){case 1:_.elemType=u.int32();break;case 2:_.shape=p.onnx.TensorShapeProto.decode(u,u.uint32());break;default:u.skipType(7&b)}}return _},l.decodeDelimited=function(u){return u instanceof d||(u=new d(u)),this.decode(u,u.uint32())},l.verify=function(u){if(typeof u!="object"||u===null)return"object expected";if(u.elemType!=null&&u.hasOwnProperty("elemType")&&!h.isInteger(u.elemType))return"elemType: integer expected";if(u.shape!=null&&u.hasOwnProperty("shape")){var g=p.onnx.TensorShapeProto.verify(u.shape);if(g)return"shape."+g}return null},l.fromObject=function(u){if(u instanceof p.onnx.TypeProto.Tensor)return u;var g=new p.onnx.TypeProto.Tensor;if(u.elemType!=null&&(g.elemType=0|u.elemType),u.shape!=null){if(typeof u.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");g.shape=p.onnx.TensorShapeProto.fromObject(u.shape)}return g},l.toObject=function(u,g){g||(g={});var m={};return g.defaults&&(m.elemType=0,m.shape=null),u.elemType!=null&&u.hasOwnProperty("elemType")&&(m.elemType=u.elemType),u.shape!=null&&u.hasOwnProperty("shape")&&(m.shape=p.onnx.TensorShapeProto.toObject(u.shape,g)),m},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(u){return u===void 0&&(u="type.googleapis.com"),u+"/onnx.TypeProto.Tensor"},l}(),s.Sequence=function(){function l(u){if(u)for(var g=Object.keys(u),m=0;m<g.length;++m)u[g[m]]!=null&&(this[g[m]]=u[g[m]])}return l.prototype.elemType=null,l.create=function(u){return new l(u)},l.encode=function(u,g){return g||(g=f.create()),u.elemType!=null&&Object.hasOwnProperty.call(u,"elemType")&&p.onnx.TypeProto.encode(u.elemType,g.uint32(10).fork()).ldelim(),g},l.encodeDelimited=function(u,g){return this.encode(u,g).ldelim()},l.decode=function(u,g){u instanceof d||(u=d.create(u));for(var m=g===void 0?u.len:u.pos+g,_=new p.onnx.TypeProto.Sequence;u.pos<m;){var b=u.uint32();b>>>3==1?_.elemType=p.onnx.TypeProto.decode(u,u.uint32()):u.skipType(7&b)}return _},l.decodeDelimited=function(u){return u instanceof d||(u=new d(u)),this.decode(u,u.uint32())},l.verify=function(u){if(typeof u!="object"||u===null)return"object expected";if(u.elemType!=null&&u.hasOwnProperty("elemType")){var g=p.onnx.TypeProto.verify(u.elemType);if(g)return"elemType."+g}return null},l.fromObject=function(u){if(u instanceof p.onnx.TypeProto.Sequence)return u;var g=new p.onnx.TypeProto.Sequence;if(u.elemType!=null){if(typeof u.elemType!="object")throw TypeError(".onnx.TypeProto.Sequence.elemType: object expected");g.elemType=p.onnx.TypeProto.fromObject(u.elemType)}return g},l.toObject=function(u,g){g||(g={});var m={};return g.defaults&&(m.elemType=null),u.elemType!=null&&u.hasOwnProperty("elemType")&&(m.elemType=p.onnx.TypeProto.toObject(u.elemType,g)),m},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(u){return u===void 0&&(u="type.googleapis.com"),u+"/onnx.TypeProto.Sequence"},l}(),s.Map=function(){function l(u){if(u)for(var g=Object.keys(u),m=0;m<g.length;++m)u[g[m]]!=null&&(this[g[m]]=u[g[m]])}return l.prototype.keyType=0,l.prototype.valueType=null,l.create=function(u){return new l(u)},l.encode=function(u,g){return g||(g=f.create()),u.keyType!=null&&Object.hasOwnProperty.call(u,"keyType")&&g.uint32(8).int32(u.keyType),u.valueType!=null&&Object.hasOwnProperty.call(u,"valueType")&&p.onnx.TypeProto.encode(u.valueType,g.uint32(18).fork()).ldelim(),g},l.encodeDelimited=function(u,g){return this.encode(u,g).ldelim()},l.decode=function(u,g){u instanceof d||(u=d.create(u));for(var m=g===void 0?u.len:u.pos+g,_=new p.onnx.TypeProto.Map;u.pos<m;){var b=u.uint32();switch(b>>>3){case 1:_.keyType=u.int32();break;case 2:_.valueType=p.onnx.TypeProto.decode(u,u.uint32());break;default:u.skipType(7&b)}}return _},l.decodeDelimited=function(u){return u instanceof d||(u=new d(u)),this.decode(u,u.uint32())},l.verify=function(u){if(typeof u!="object"||u===null)return"object expected";if(u.keyType!=null&&u.hasOwnProperty("keyType")&&!h.isInteger(u.keyType))return"keyType: integer expected";if(u.valueType!=null&&u.hasOwnProperty("valueType")){var g=p.onnx.TypeProto.verify(u.valueType);if(g)return"valueType."+g}return null},l.fromObject=function(u){if(u instanceof p.onnx.TypeProto.Map)return u;var g=new p.onnx.TypeProto.Map;if(u.keyType!=null&&(g.keyType=0|u.keyType),u.valueType!=null){if(typeof u.valueType!="object")throw TypeError(".onnx.TypeProto.Map.valueType: object expected");g.valueType=p.onnx.TypeProto.fromObject(u.valueType)}return g},l.toObject=function(u,g){g||(g={});var m={};return g.defaults&&(m.keyType=0,m.valueType=null),u.keyType!=null&&u.hasOwnProperty("keyType")&&(m.keyType=u.keyType),u.valueType!=null&&u.hasOwnProperty("valueType")&&(m.valueType=p.onnx.TypeProto.toObject(u.valueType,g)),m},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(u){return u===void 0&&(u="type.googleapis.com"),u+"/onnx.TypeProto.Map"},l}(),s.Optional=function(){function l(u){if(u)for(var g=Object.keys(u),m=0;m<g.length;++m)u[g[m]]!=null&&(this[g[m]]=u[g[m]])}return l.prototype.elemType=null,l.create=function(u){return new l(u)},l.encode=function(u,g){return g||(g=f.create()),u.elemType!=null&&Object.hasOwnProperty.call(u,"elemType")&&p.onnx.TypeProto.encode(u.elemType,g.uint32(10).fork()).ldelim(),g},l.encodeDelimited=function(u,g){return this.encode(u,g).ldelim()},l.decode=function(u,g){u instanceof d||(u=d.create(u));for(var m=g===void 0?u.len:u.pos+g,_=new p.onnx.TypeProto.Optional;u.pos<m;){var b=u.uint32();b>>>3==1?_.elemType=p.onnx.TypeProto.decode(u,u.uint32()):u.skipType(7&b)}return _},l.decodeDelimited=function(u){return u instanceof d||(u=new d(u)),this.decode(u,u.uint32())},l.verify=function(u){if(typeof u!="object"||u===null)return"object expected";if(u.elemType!=null&&u.hasOwnProperty("elemType")){var g=p.onnx.TypeProto.verify(u.elemType);if(g)return"elemType."+g}return null},l.fromObject=function(u){if(u instanceof p.onnx.TypeProto.Optional)return u;var g=new p.onnx.TypeProto.Optional;if(u.elemType!=null){if(typeof u.elemType!="object")throw TypeError(".onnx.TypeProto.Optional.elemType: object expected");g.elemType=p.onnx.TypeProto.fromObject(u.elemType)}return g},l.toObject=function(u,g){g||(g={});var m={};return g.defaults&&(m.elemType=null),u.elemType!=null&&u.hasOwnProperty("elemType")&&(m.elemType=p.onnx.TypeProto.toObject(u.elemType,g)),m},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(u){return u===void 0&&(u="type.googleapis.com"),u+"/onnx.TypeProto.Optional"},l}(),s.SparseTensor=function(){function l(u){if(u)for(var g=Object.keys(u),m=0;m<g.length;++m)u[g[m]]!=null&&(this[g[m]]=u[g[m]])}return l.prototype.elemType=0,l.prototype.shape=null,l.create=function(u){return new l(u)},l.encode=function(u,g){return g||(g=f.create()),u.elemType!=null&&Object.hasOwnProperty.call(u,"elemType")&&g.uint32(8).int32(u.elemType),u.shape!=null&&Object.hasOwnProperty.call(u,"shape")&&p.onnx.TensorShapeProto.encode(u.shape,g.uint32(18).fork()).ldelim(),g},l.encodeDelimited=function(u,g){return this.encode(u,g).ldelim()},l.decode=function(u,g){u instanceof d||(u=d.create(u));for(var m=g===void 0?u.len:u.pos+g,_=new p.onnx.TypeProto.SparseTensor;u.pos<m;){var b=u.uint32();switch(b>>>3){case 1:_.elemType=u.int32();break;case 2:_.shape=p.onnx.TensorShapeProto.decode(u,u.uint32());break;default:u.skipType(7&b)}}return _},l.decodeDelimited=function(u){return u instanceof d||(u=new d(u)),this.decode(u,u.uint32())},l.verify=function(u){if(typeof u!="object"||u===null)return"object expected";if(u.elemType!=null&&u.hasOwnProperty("elemType")&&!h.isInteger(u.elemType))return"elemType: integer expected";if(u.shape!=null&&u.hasOwnProperty("shape")){var g=p.onnx.TensorShapeProto.verify(u.shape);if(g)return"shape."+g}return null},l.fromObject=function(u){if(u instanceof p.onnx.TypeProto.SparseTensor)return u;var g=new p.onnx.TypeProto.SparseTensor;if(u.elemType!=null&&(g.elemType=0|u.elemType),u.shape!=null){if(typeof u.shape!="object")throw TypeError(".onnx.TypeProto.SparseTensor.shape: object expected");g.shape=p.onnx.TensorShapeProto.fromObject(u.shape)}return g},l.toObject=function(u,g){g||(g={});var m={};return g.defaults&&(m.elemType=0,m.shape=null),u.elemType!=null&&u.hasOwnProperty("elemType")&&(m.elemType=u.elemType),u.shape!=null&&u.hasOwnProperty("shape")&&(m.shape=p.onnx.TensorShapeProto.toObject(u.shape,g)),m},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(u){return u===void 0&&(u="type.googleapis.com"),u+"/onnx.TypeProto.SparseTensor"},l}(),s}(),o.OperatorSetIdProto=function(){function s(t){if(t)for(var l=Object.keys(t),u=0;u<l.length;++u)t[l[u]]!=null&&(this[l[u]]=t[l[u]])}return s.prototype.domain="",s.prototype.version=h.Long?h.Long.fromBits(0,0,!1):0,s.create=function(t){return new s(t)},s.encode=function(t,l){return l||(l=f.create()),t.domain!=null&&Object.hasOwnProperty.call(t,"domain")&&l.uint32(10).string(t.domain),t.version!=null&&Object.hasOwnProperty.call(t,"version")&&l.uint32(16).int64(t.version),l},s.encodeDelimited=function(t,l){return this.encode(t,l).ldelim()},s.decode=function(t,l){t instanceof d||(t=d.create(t));for(var u=l===void 0?t.len:t.pos+l,g=new p.onnx.OperatorSetIdProto;t.pos<u;){var m=t.uint32();switch(m>>>3){case 1:g.domain=t.string();break;case 2:g.version=t.int64();break;default:t.skipType(7&m)}}return g},s.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},s.verify=function(t){return typeof t!="object"||t===null?"object expected":t.domain!=null&&t.hasOwnProperty("domain")&&!h.isString(t.domain)?"domain: string expected":t.version!=null&&t.hasOwnProperty("version")&&!(h.isInteger(t.version)||t.version&&h.isInteger(t.version.low)&&h.isInteger(t.version.high))?"version: integer|Long expected":null},s.fromObject=function(t){if(t instanceof p.onnx.OperatorSetIdProto)return t;var l=new p.onnx.OperatorSetIdProto;return t.domain!=null&&(l.domain=String(t.domain)),t.version!=null&&(h.Long?(l.version=h.Long.fromValue(t.version)).unsigned=!1:typeof t.version=="string"?l.version=parseInt(t.version,10):typeof t.version=="number"?l.version=t.version:typeof t.version=="object"&&(l.version=new h.LongBits(t.version.low>>>0,t.version.high>>>0).toNumber())),l},s.toObject=function(t,l){l||(l={});var u={};if(l.defaults)if(u.domain="",h.Long){var g=new h.Long(0,0,!1);u.version=l.longs===String?g.toString():l.longs===Number?g.toNumber():g}else u.version=l.longs===String?"0":0;return t.domain!=null&&t.hasOwnProperty("domain")&&(u.domain=t.domain),t.version!=null&&t.hasOwnProperty("version")&&(typeof t.version=="number"?u.version=l.longs===String?String(t.version):t.version:u.version=l.longs===String?h.Long.prototype.toString.call(t.version):l.longs===Number?new h.LongBits(t.version.low>>>0,t.version.high>>>0).toNumber():t.version),u},s.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},s.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.OperatorSetIdProto"},s}(),o.OperatorStatus=function(){var s={},t=Object.create(s);return t[s[0]="EXPERIMENTAL"]=0,t[s[1]="STABLE"]=1,t}(),o.FunctionProto=function(){function s(t){if(this.input=[],this.output=[],this.attribute=[],this.attributeProto=[],this.node=[],this.opsetImport=[],t)for(var l=Object.keys(t),u=0;u<l.length;++u)t[l[u]]!=null&&(this[l[u]]=t[l[u]])}return s.prototype.name="",s.prototype.input=h.emptyArray,s.prototype.output=h.emptyArray,s.prototype.attribute=h.emptyArray,s.prototype.attributeProto=h.emptyArray,s.prototype.node=h.emptyArray,s.prototype.docString="",s.prototype.opsetImport=h.emptyArray,s.prototype.domain="",s.create=function(t){return new s(t)},s.encode=function(t,l){if(l||(l=f.create()),t.name!=null&&Object.hasOwnProperty.call(t,"name")&&l.uint32(10).string(t.name),t.input!=null&&t.input.length)for(var u=0;u<t.input.length;++u)l.uint32(34).string(t.input[u]);if(t.output!=null&&t.output.length)for(u=0;u<t.output.length;++u)l.uint32(42).string(t.output[u]);if(t.attribute!=null&&t.attribute.length)for(u=0;u<t.attribute.length;++u)l.uint32(50).string(t.attribute[u]);if(t.node!=null&&t.node.length)for(u=0;u<t.node.length;++u)p.onnx.NodeProto.encode(t.node[u],l.uint32(58).fork()).ldelim();if(t.docString!=null&&Object.hasOwnProperty.call(t,"docString")&&l.uint32(66).string(t.docString),t.opsetImport!=null&&t.opsetImport.length)for(u=0;u<t.opsetImport.length;++u)p.onnx.OperatorSetIdProto.encode(t.opsetImport[u],l.uint32(74).fork()).ldelim();if(t.domain!=null&&Object.hasOwnProperty.call(t,"domain")&&l.uint32(82).string(t.domain),t.attributeProto!=null&&t.attributeProto.length)for(u=0;u<t.attributeProto.length;++u)p.onnx.AttributeProto.encode(t.attributeProto[u],l.uint32(90).fork()).ldelim();return l},s.encodeDelimited=function(t,l){return this.encode(t,l).ldelim()},s.decode=function(t,l){t instanceof d||(t=d.create(t));for(var u=l===void 0?t.len:t.pos+l,g=new p.onnx.FunctionProto;t.pos<u;){var m=t.uint32();switch(m>>>3){case 1:g.name=t.string();break;case 4:g.input&&g.input.length||(g.input=[]),g.input.push(t.string());break;case 5:g.output&&g.output.length||(g.output=[]),g.output.push(t.string());break;case 6:g.attribute&&g.attribute.length||(g.attribute=[]),g.attribute.push(t.string());break;case 11:g.attributeProto&&g.attributeProto.length||(g.attributeProto=[]),g.attributeProto.push(p.onnx.AttributeProto.decode(t,t.uint32()));break;case 7:g.node&&g.node.length||(g.node=[]),g.node.push(p.onnx.NodeProto.decode(t,t.uint32()));break;case 8:g.docString=t.string();break;case 9:g.opsetImport&&g.opsetImport.length||(g.opsetImport=[]),g.opsetImport.push(p.onnx.OperatorSetIdProto.decode(t,t.uint32()));break;case 10:g.domain=t.string();break;default:t.skipType(7&m)}}return g},s.decodeDelimited=function(t){return t instanceof d||(t=new d(t)),this.decode(t,t.uint32())},s.verify=function(t){if(typeof t!="object"||t===null)return"object expected";if(t.name!=null&&t.hasOwnProperty("name")&&!h.isString(t.name))return"name: string expected";if(t.input!=null&&t.hasOwnProperty("input")){if(!Array.isArray(t.input))return"input: array expected";for(var l=0;l<t.input.length;++l)if(!h.isString(t.input[l]))return"input: string[] expected"}if(t.output!=null&&t.hasOwnProperty("output")){if(!Array.isArray(t.output))return"output: array expected";for(l=0;l<t.output.length;++l)if(!h.isString(t.output[l]))return"output: string[] expected"}if(t.attribute!=null&&t.hasOwnProperty("attribute")){if(!Array.isArray(t.attribute))return"attribute: array expected";for(l=0;l<t.attribute.length;++l)if(!h.isString(t.attribute[l]))return"attribute: string[] expected"}if(t.attributeProto!=null&&t.hasOwnProperty("attributeProto")){if(!Array.isArray(t.attributeProto))return"attributeProto: array expected";for(l=0;l<t.attributeProto.length;++l)if(u=p.onnx.AttributeProto.verify(t.attributeProto[l]))return"attributeProto."+u}if(t.node!=null&&t.hasOwnProperty("node")){if(!Array.isArray(t.node))return"node: array expected";for(l=0;l<t.node.length;++l)if(u=p.onnx.NodeProto.verify(t.node[l]))return"node."+u}if(t.docString!=null&&t.hasOwnProperty("docString")&&!h.isString(t.docString))return"docString: string expected";if(t.opsetImport!=null&&t.hasOwnProperty("opsetImport")){if(!Array.isArray(t.opsetImport))return"opsetImport: array expected";for(l=0;l<t.opsetImport.length;++l){var u;if(u=p.onnx.OperatorSetIdProto.verify(t.opsetImport[l]))return"opsetImport."+u}}return t.domain!=null&&t.hasOwnProperty("domain")&&!h.isString(t.domain)?"domain: string expected":null},s.fromObject=function(t){if(t instanceof p.onnx.FunctionProto)return t;var l=new p.onnx.FunctionProto;if(t.name!=null&&(l.name=String(t.name)),t.input){if(!Array.isArray(t.input))throw TypeError(".onnx.FunctionProto.input: array expected");l.input=[];for(var u=0;u<t.input.length;++u)l.input[u]=String(t.input[u])}if(t.output){if(!Array.isArray(t.output))throw TypeError(".onnx.FunctionProto.output: array expected");for(l.output=[],u=0;u<t.output.length;++u)l.output[u]=String(t.output[u])}if(t.attribute){if(!Array.isArray(t.attribute))throw TypeError(".onnx.FunctionProto.attribute: array expected");for(l.attribute=[],u=0;u<t.attribute.length;++u)l.attribute[u]=String(t.attribute[u])}if(t.attributeProto){if(!Array.isArray(t.attributeProto))throw TypeError(".onnx.FunctionProto.attributeProto: array expected");for(l.attributeProto=[],u=0;u<t.attributeProto.length;++u){if(typeof t.attributeProto[u]!="object")throw TypeError(".onnx.FunctionProto.attributeProto: object expected");l.attributeProto[u]=p.onnx.AttributeProto.fromObject(t.attributeProto[u])}}if(t.node){if(!Array.isArray(t.node))throw TypeError(".onnx.FunctionProto.node: array expected");for(l.node=[],u=0;u<t.node.length;++u){if(typeof t.node[u]!="object")throw TypeError(".onnx.FunctionProto.node: object expected");l.node[u]=p.onnx.NodeProto.fromObject(t.node[u])}}if(t.docString!=null&&(l.docString=String(t.docString)),t.opsetImport){if(!Array.isArray(t.opsetImport))throw TypeError(".onnx.FunctionProto.opsetImport: array expected");for(l.opsetImport=[],u=0;u<t.opsetImport.length;++u){if(typeof t.opsetImport[u]!="object")throw TypeError(".onnx.FunctionProto.opsetImport: object expected");l.opsetImport[u]=p.onnx.OperatorSetIdProto.fromObject(t.opsetImport[u])}}return t.domain!=null&&(l.domain=String(t.domain)),l},s.toObject=function(t,l){l||(l={});var u={};if((l.arrays||l.defaults)&&(u.input=[],u.output=[],u.attribute=[],u.node=[],u.opsetImport=[],u.attributeProto=[]),l.defaults&&(u.name="",u.docString="",u.domain=""),t.name!=null&&t.hasOwnProperty("name")&&(u.name=t.name),t.input&&t.input.length){u.input=[];for(var g=0;g<t.input.length;++g)u.input[g]=t.input[g]}if(t.output&&t.output.length)for(u.output=[],g=0;g<t.output.length;++g)u.output[g]=t.output[g];if(t.attribute&&t.attribute.length)for(u.attribute=[],g=0;g<t.attribute.length;++g)u.attribute[g]=t.attribute[g];if(t.node&&t.node.length)for(u.node=[],g=0;g<t.node.length;++g)u.node[g]=p.onnx.NodeProto.toObject(t.node[g],l);if(t.docString!=null&&t.hasOwnProperty("docString")&&(u.docString=t.docString),t.opsetImport&&t.opsetImport.length)for(u.opsetImport=[],g=0;g<t.opsetImport.length;++g)u.opsetImport[g]=p.onnx.OperatorSetIdProto.toObject(t.opsetImport[g],l);if(t.domain!=null&&t.hasOwnProperty("domain")&&(u.domain=t.domain),t.attributeProto&&t.attributeProto.length)for(u.attributeProto=[],g=0;g<t.attributeProto.length;++g)u.attributeProto[g]=p.onnx.AttributeProto.toObject(t.attributeProto[g],l);return u},s.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},s.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/onnx.FunctionProto"},s}(),o),c.exports=p},3474:(c,e,n)=>{var r,i=(r=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0,typeof __filename<"u"&&(r=r||__filename),function(o={}){function a(){return K.buffer!=te.buffer&&xe(),te}function d(){return K.buffer!=te.buffer&&xe(),oe}function f(){return K.buffer!=te.buffer&&xe(),ae}function h(){return K.buffer!=te.buffer&&xe(),ce}function p(){return K.buffer!=te.buffer&&xe(),fe}var s,t,l=o;l.ready=new Promise((O,C)=>{s=O,t=C});var u,g,m,_=Object.assign({},l),b="./this.program",y=(O,C)=>{throw C},v=typeof window=="object",T=typeof importScripts=="function",w=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",S=l.ENVIRONMENT_IS_PTHREAD||!1,x="";function P(O){return l.locateFile?l.locateFile(O,x):x+O}if(w){var I=n(1384),N=n(908);let O;x=T?N.dirname(x)+"/":__dirname+"/",u=(C,F)=>(C=C.startsWith("file://")?new URL(C):N.normalize(C),I.readFileSync(C,F?void 0:"utf8")),m=C=>((C=u(C,!0)).buffer||(C=new Uint8Array(C)),C),g=(C,F,G,H=!0)=>{C=C.startsWith("file://")?new URL(C):N.normalize(C),I.readFile(C,H?void 0:"utf8",(re,se)=>{re?G(re):F(H?se.buffer:se)})},!l.thisProgram&&1<process.argv.length&&(b=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),y=(C,F)=>{throw process.exitCode=C,F},l.inspect=()=>"[Emscripten Module object]";try{O=n(9925)}catch(C){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),C}commonjsGlobal.Worker=O.Worker}else(v||T)&&(T?x=self.location.href:typeof document<"u"&&document.currentScript&&(x=document.currentScript.src),r&&(x=r),x=x.indexOf("blob:")!==0?x.substr(0,x.replace(/[?#].*/,"").lastIndexOf("/")+1):"",w||(u=O=>{var C=new XMLHttpRequest;return C.open("GET",O,!1),C.send(null),C.responseText},T&&(m=O=>{var C=new XMLHttpRequest;return C.open("GET",O,!1),C.responseType="arraybuffer",C.send(null),new Uint8Array(C.response)}),g=(O,C,F)=>{var G=new XMLHttpRequest;G.open("GET",O,!0),G.responseType="arraybuffer",G.onload=()=>{G.status==200||G.status==0&&G.response?C(G.response):F()},G.onerror=F,G.send(null)}));w&&typeof performance>"u"&&(commonjsGlobal.performance=n(6953).performance);var L=console.log.bind(console),E=console.error.bind(console);w&&(L=(...O)=>I.writeSync(1,O.join(" ")+`
`),E=(...O)=>I.writeSync(2,O.join(" ")+`
`));var M,k=l.print||L,A=l.printErr||E;Object.assign(l,_),_=null,l.thisProgram&&(b=l.thisProgram),l.quit&&(y=l.quit),l.wasmBinary&&(M=l.wasmBinary);var R=l.noExitRuntime||!0;typeof WebAssembly!="object"&&ke("no native wasm support detected");var K,Z,J,X,te,oe,ae,ce,fe,he=!1;function xe(){var O=K.buffer;l.HEAP8=te=new Int8Array(O),l.HEAP16=new Int16Array(O),l.HEAP32=ae=new Int32Array(O),l.HEAPU8=oe=new Uint8Array(O),l.HEAPU16=new Uint16Array(O),l.HEAPU32=ce=new Uint32Array(O),l.HEAPF32=new Float32Array(O),l.HEAPF64=fe=new Float64Array(O)}var we=l.INITIAL_MEMORY||16777216;if(5242880<=we||ke("INITIAL_MEMORY should be larger than STACK_SIZE, was "+we+"! (STACK_SIZE=5242880)"),S)K=l.wasmMemory;else if(l.wasmMemory)K=l.wasmMemory;else if(!((K=new WebAssembly.Memory({initial:we/65536,maximum:65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw A("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),w&&A("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");xe(),we=K.buffer.byteLength;var Re,be=[],Ne=[],ge=[],ye=0;function Oe(){return R||0<ye}var Pe,Ae,$e=0,Ce=null;function Ge(){$e++,l.monitorRunDependencies&&l.monitorRunDependencies($e)}function je(){if($e--,l.monitorRunDependencies&&l.monitorRunDependencies($e),$e==0&&Ce){var O=Ce;Ce=null,O()}}function ke(O){throw l.onAbort&&l.onAbort(O),A(O="Aborted("+O+")"),he=!0,X=1,O=new WebAssembly.RuntimeError(O+". Build with -sASSERTIONS for more info."),t(O),O}function Ee(O){return O.startsWith("data:application/octet-stream;base64,")}function ze(O){if(O==Pe&&M)return new Uint8Array(M);if(m)return m(O);throw"both async and sync fetching of the wasm failed"}function et(O,C,F){return function(G){if(!M&&(v||T)){if(typeof fetch=="function"&&!G.startsWith("file://"))return fetch(G,{credentials:"same-origin"}).then(H=>{if(!H.ok)throw"failed to load wasm binary file at '"+G+"'";return H.arrayBuffer()}).catch(()=>ze(G));if(g)return new Promise((H,re)=>{g(G,se=>H(new Uint8Array(se)),re)})}return Promise.resolve().then(()=>ze(G))}(O).then(G=>WebAssembly.instantiate(G,C)).then(G=>G).then(F,G=>{A("failed to asynchronously prepare wasm: "+G),ke(G)})}function Ve(O){this.name="ExitStatus",this.message=`Program terminated with exit(${O})`,this.status=O}function Ze(O){O.terminate(),O.onmessage=()=>{}}function He(O){(O=le.Fa[O])||ke(),le.fb(O)}function We(O){var C=le.Za();if(!C)return 6;le.Ia.push(C),le.Fa[O.Ha]=C,C.Ha=O.Ha;var F={cmd:"run",start_routine:O.gb,arg:O.Ya,pthread_ptr:O.Ha};return w&&C.unref(),C.postMessage(F,O.mb),0}Ee(Pe="ort-wasm-threaded.wasm")||(Pe=P(Pe));var Ye=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,qe=(O,C,F)=>{var G=(C>>>=0)+F;for(F=C;O[F]&&!(F>=G);)++F;if(16<F-C&&O.buffer&&Ye)return Ye.decode(O.buffer instanceof SharedArrayBuffer?O.slice(C,F):O.subarray(C,F));for(G="";C<F;){var H=O[C++];if(128&H){var re=63&O[C++];if((224&H)==192)G+=String.fromCharCode((31&H)<<6|re);else{var se=63&O[C++];65536>(H=(240&H)==224?(15&H)<<12|re<<6|se:(7&H)<<18|re<<12|se<<6|63&O[C++])?G+=String.fromCharCode(H):(H-=65536,G+=String.fromCharCode(55296|H>>10,56320|1023&H))}}else G+=String.fromCharCode(H)}return G},Ue=(O,C)=>(O>>>=0)?qe(d(),O,C):"";function Xe(O){if(S)return _e(1,1,O);X=O,Oe()||(le.hb(),l.onExit&&l.onExit(O),he=!0),y(O,new Ve(O))}var Ke=O=>{if(X=O,S)throw Je(O),"unwind";Xe(O)},le={La:[],Ia:[],Ta:[],Fa:{},Pa:function(){S?le.ab():le.$a()},$a:function(){be.unshift(()=>{Ge(),le.bb(()=>je())})},ab:function(){le.receiveObjectTransfer=le.eb,le.threadInitTLS=le.Sa,le.setExitStatus=le.Ra,R=!1},Ra:function(O){X=O},rb:["$terminateWorker"],hb:function(){for(var O of le.Ia)Ze(O);for(O of le.La)Ze(O);le.La=[],le.Ia=[],le.Fa=[]},fb:function(O){var C=O.Ha;delete le.Fa[C],le.La.push(O),le.Ia.splice(le.Ia.indexOf(O),1),O.Ha=0,ft(C)},eb:function(){},Sa:function(){le.Ta.forEach(O=>O())},cb:O=>new Promise(C=>{O.onmessage=H=>{var re=(H=H.data).cmd;if(H.targetThread&&H.targetThread!=ot()){var se=le.Fa[H.qb];se?se.postMessage(H,H.transferList):A('Internal error! Worker sent a message "'+re+'" to target pthread '+H.targetThread+", but that thread no longer exists!")}else re==="checkMailbox"?it():re==="spawnThread"?We(H):re==="cleanupThread"?He(H.thread):re==="killThread"?(H=H.thread,re=le.Fa[H],delete le.Fa[H],Ze(re),ft(H),le.Ia.splice(le.Ia.indexOf(re),1),re.Ha=0):re==="cancelThread"?le.Fa[H.thread].postMessage({cmd:"cancel"}):re==="loaded"?(O.loaded=!0,C(O)):re==="alert"?alert("Thread "+H.threadId+": "+H.text):H.target==="setimmediate"?O.postMessage(H):re==="callHandler"?l[H.handler](...H.args):re&&A("worker sent an unknown command "+re)},O.onerror=H=>{throw A("worker sent an error! "+H.filename+":"+H.lineno+": "+H.message),H},w&&(O.on("message",function(H){O.onmessage({data:H})}),O.on("error",function(H){O.onerror(H)}));var F,G=[];for(F of["onExit","onAbort","print","printErr"])l.hasOwnProperty(F)&&G.push(F);O.postMessage({cmd:"load",handlers:G,urlOrBlob:l.mainScriptUrlOrBlob||r,wasmMemory:K,wasmModule:J})}),bb:function(O){O()},Xa:function(){var O=P("ort-wasm-threaded.worker.js");O=new Worker(O),le.La.push(O)},Za:function(){return le.La.length==0&&(le.Xa(),le.cb(le.La[0])),le.La.pop()}};l.PThread=le;var Be=O=>{for(;0<O.length;)O.shift()(l)};function Je(O){if(S)return _e(2,0,O);Ke(O)}l.establishStackSpace=function(){var O=ot(),C=f()[O+52>>2>>>0];O=f()[O+56>>2>>>0],jt(C,C-O),st(C)};var $=[];function U(O){this.Oa=O-24,this.Wa=function(C){h()[this.Oa+4>>2>>>0]=C},this.Va=function(C){h()[this.Oa+8>>2>>>0]=C},this.Pa=function(C,F){this.Ua(),this.Wa(C),this.Va(F)},this.Ua=function(){h()[this.Oa+16>>2>>>0]=0}}function V(O,C,F,G){return S?_e(3,1,O,C,F,G):q(O,C,F,G)}function q(O,C,F,G){if(O>>>=0,C>>>=0,F>>>=0,G>>>=0,typeof SharedArrayBuffer>"u")return A("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var H=[];return S&&H.length===0?V(O,C,F,G):(O={gb:F,Ha:O,Ya:G,mb:H},S?(O.ob="spawnThread",postMessage(O,H),0):We(O))}function ee(O,C,F){return S?_e(4,1,O,C,F):0}function D(O,C){if(S)return _e(5,1,O,C)}l.invokeEntryPoint=function(O,C){var F=$[O];F||(O>=$.length&&($.length=O+1),$[O]=F=Re.get(O)),O=F(C),Oe()?le.Ra(O):ht(O)};var j=O=>{for(var C=0,F=0;F<O.length;++F){var G=O.charCodeAt(F);127>=G?C++:2047>=G?C+=2:55296<=G&&57343>=G?(C+=4,++F):C+=3}return C},Y=(O,C,F,G)=>{if(!(0<G))return 0;var H=F>>>=0;G=F+G-1;for(var re=0;re<O.length;++re){var se=O.charCodeAt(re);if(55296<=se&&57343>=se&&(se=65536+((1023&se)<<10)|1023&O.charCodeAt(++re)),127>=se){if(F>=G)break;C[F++>>>0]=se}else{if(2047>=se){if(F+1>=G)break;C[F++>>>0]=192|se>>6}else{if(65535>=se){if(F+2>=G)break;C[F++>>>0]=224|se>>12}else{if(F+3>=G)break;C[F++>>>0]=240|se>>18,C[F++>>>0]=128|se>>12&63}C[F++>>>0]=128|se>>6&63}C[F++>>>0]=128|63&se}}return C[F>>>0]=0,F-H},Q=(O,C,F)=>Y(O,d(),C,F);function ne(O,C){if(S)return _e(6,1,O,C)}function ie(O,C,F){if(S)return _e(7,1,O,C,F)}function ue(O,C,F){return S?_e(8,1,O,C,F):0}function Se(O,C){if(S)return _e(9,1,O,C)}function B(O,C,F){if(S)return _e(10,1,O,C,F)}function de(O,C,F,G){if(S)return _e(11,1,O,C,F,G)}function me(O,C,F,G){if(S)return _e(12,1,O,C,F,G)}function Le(O,C,F,G){if(S)return _e(13,1,O,C,F,G)}function nt(O){if(S)return _e(14,1,O)}function mt(O,C){if(S)return _e(15,1,O,C)}function _t(O,C,F){if(S)return _e(16,1,O,C,F)}var Zt=O=>{if(!he)try{if(O(),!Oe())try{S?ht(X):Ke(X)}catch(C){C instanceof Ve||C=="unwind"||y(1,C)}}catch(C){C instanceof Ve||C=="unwind"||y(1,C)}};function lt(O){O>>>=0,typeof Atomics.nb=="function"&&(Atomics.nb(f(),O>>2,O).value.then(it),O+=128,Atomics.store(f(),O>>2,1))}function it(){var O=ot();O&&(lt(O),Zt(()=>Ft()))}l.__emscripten_thread_mailbox_await=lt,l.checkMailbox=it;var tt=O=>O%4==0&&(O%100!=0||O%400==0),bt=[0,31,60,91,121,152,182,213,244,274,305,335],yt=[0,31,59,90,120,151,181,212,243,273,304,334];function vt(O,C,F,G,H,re,se,ve){return S?_e(17,1,O,C,F,G,H,re,se,ve):-52}function Tt(O,C,F,G,H,re,se){if(S)return _e(18,1,O,C,F,G,H,re,se)}var wt=O=>{var C=j(O)+1,F=Dt(C);return F&&Q(O,F,C),F},Ht=O=>{var C=pt();return O=O(),st(C),O};function _e(O,C){var F=arguments.length-2,G=arguments;return Ht(()=>{for(var H=gt(8*F),re=H>>3,se=0;se<F;se++){var ve=G[2+se];p()[re+se>>>0]=ve}return Lt(O,F,H,C)})}var ct,ut=[],dt={},St=()=>{if(!ct){var O,C={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:b||"./this.program"};for(O in dt)dt[O]===void 0?delete C[O]:C[O]=dt[O];var F=[];for(O in C)F.push(`${O}=${C[O]}`);ct=F}return ct};function xt(O,C){if(S)return _e(19,1,O,C);O>>>=0,C>>>=0;var F=0;return St().forEach(function(G,H){var re=C+F;for(H=h()[O+4*H>>2>>>0]=re,re=0;re<G.length;++re)a()[H++>>0>>>0]=G.charCodeAt(re);a()[H>>0>>>0]=0,F+=G.length+1}),0}function Ot(O,C){if(S)return _e(20,1,O,C);O>>>=0,C>>>=0;var F=St();h()[O>>2>>>0]=F.length;var G=0;return F.forEach(function(H){G+=H.length+1}),h()[C>>2>>>0]=G,0}function Et(O){return S?_e(21,1,O):52}function Pt(O,C,F,G){return S?_e(22,1,O,C,F,G):52}function kt(O,C,F,G,H){return S?_e(23,1,O,C,F,G,H):70}var Wt=[null,[],[]];function It(O,C,F,G){if(S)return _e(24,1,O,C,F,G);C>>>=0,F>>>=0,G>>>=0;for(var H=0,re=0;re<F;re++){var se=h()[C>>2>>>0],ve=h()[C+4>>2>>>0];C+=8;for(var Fe=0;Fe<ve;Fe++){var Ie=d()[se+Fe>>>0],De=Wt[O];Ie===0||Ie===10?((O===1?k:A)(qe(De,0)),De.length=0):De.push(Ie)}H+=ve}return h()[G>>2>>>0]=H,0}var At=O=>(At=(()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return G=>(G.set(crypto.getRandomValues(new Uint8Array(G.byteLength))),G);if(w)try{var C=n(760);if(C.randomFillSync)return G=>C.randomFillSync(G);var F=C.randomBytes;return G=>(G.set(F(G.byteLength)),G)}catch{}ke("initRandomDevice")})())(O),Ct=[31,29,31,30,31,30,31,31,30,31,30,31],$t=[31,28,31,30,31,30,31,31,30,31,30,31],qt=(O,C)=>{a().set(O,C>>>0)};function Nt(O,C,F,G){function H(W,pe,Te){for(W=typeof W=="number"?W.toString():W||"";W.length<pe;)W=Te[0]+W;return W}function re(W,pe){return H(W,pe,"0")}function se(W,pe){function Te(Bt){return 0>Bt?-1:0<Bt?1:0}var Qe;return(Qe=Te(W.getFullYear()-pe.getFullYear()))===0&&(Qe=Te(W.getMonth()-pe.getMonth()))===0&&(Qe=Te(W.getDate()-pe.getDate())),Qe}function ve(W){switch(W.getDay()){case 0:return new Date(W.getFullYear()-1,11,29);case 1:return W;case 2:return new Date(W.getFullYear(),0,3);case 3:return new Date(W.getFullYear(),0,2);case 4:return new Date(W.getFullYear(),0,1);case 5:return new Date(W.getFullYear()-1,11,31);case 6:return new Date(W.getFullYear()-1,11,30)}}function Fe(W){var pe=W.Ja;for(W=new Date(new Date(W.Ka+1900,0,1).getTime());0<pe;){var Te=W.getMonth(),Qe=(tt(W.getFullYear())?Ct:$t)[Te];if(!(pe>Qe-W.getDate())){W.setDate(W.getDate()+pe);break}pe-=Qe-W.getDate()+1,W.setDate(1),11>Te?W.setMonth(Te+1):(W.setMonth(0),W.setFullYear(W.getFullYear()+1))}return Te=new Date(W.getFullYear()+1,0,4),pe=ve(new Date(W.getFullYear(),0,4)),Te=ve(Te),0>=se(pe,W)?0>=se(Te,W)?W.getFullYear()+1:W.getFullYear():W.getFullYear()-1}O>>>=0,C>>>=0,F>>>=0,G>>>=0;var Ie=f()[G+40>>2>>>0];for(var De in G={kb:f()[G>>2>>>0],jb:f()[G+4>>2>>>0],Ma:f()[G+8>>2>>>0],Qa:f()[G+12>>2>>>0],Na:f()[G+16>>2>>>0],Ka:f()[G+20>>2>>>0],Ga:f()[G+24>>2>>>0],Ja:f()[G+28>>2>>>0],sb:f()[G+32>>2>>>0],ib:f()[G+36>>2>>>0],lb:Ie?Ue(Ie):""},F=Ue(F),Ie={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})F=F.replace(new RegExp(De,"g"),Ie[De]);var Gt="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Vt="January February March April May June July August September October November December".split(" ");for(De in Ie={"%a":W=>Gt[W.Ga].substring(0,3),"%A":W=>Gt[W.Ga],"%b":W=>Vt[W.Na].substring(0,3),"%B":W=>Vt[W.Na],"%C":W=>re((W.Ka+1900)/100|0,2),"%d":W=>re(W.Qa,2),"%e":W=>H(W.Qa,2," "),"%g":W=>Fe(W).toString().substring(2),"%G":W=>Fe(W),"%H":W=>re(W.Ma,2),"%I":W=>((W=W.Ma)==0?W=12:12<W&&(W-=12),re(W,2)),"%j":W=>{for(var pe=0,Te=0;Te<=W.Na-1;pe+=(tt(W.Ka+1900)?Ct:$t)[Te++]);return re(W.Qa+pe,3)},"%m":W=>re(W.Na+1,2),"%M":W=>re(W.jb,2),"%n":()=>`
`,"%p":W=>0<=W.Ma&&12>W.Ma?"AM":"PM","%S":W=>re(W.kb,2),"%t":()=>"	","%u":W=>W.Ga||7,"%U":W=>re(Math.floor((W.Ja+7-W.Ga)/7),2),"%V":W=>{var pe=Math.floor((W.Ja+7-(W.Ga+6)%7)/7);if(2>=(W.Ga+371-W.Ja-2)%7&&pe++,pe)pe==53&&((Te=(W.Ga+371-W.Ja)%7)==4||Te==3&&tt(W.Ka)||(pe=1));else{pe=52;var Te=(W.Ga+7-W.Ja-1)%7;(Te==4||Te==5&&tt(W.Ka%400-1))&&pe++}return re(pe,2)},"%w":W=>W.Ga,"%W":W=>re(Math.floor((W.Ja+7-(W.Ga+6)%7)/7),2),"%y":W=>(W.Ka+1900).toString().substring(2),"%Y":W=>W.Ka+1900,"%z":W=>{var pe=0<=(W=W.ib);return W=Math.abs(W)/60,(pe?"+":"-")+("0000"+(W/60*100+W%60)).slice(-4)},"%Z":W=>W.lb,"%%":()=>"%"},F=F.replace(/%%/g,"\0\0"),Ie)F.includes(De)&&(F=F.replace(new RegExp(De,"g"),Ie[De](G)));return De=function(W){var pe=Array(j(W)+1);return Y(W,pe,0,pe.length),pe}(F=F.replace(/\0\0/g,"%")),De.length>C?0:(qt(De,O),De.length-1)}le.Pa();var Kt=[null,Xe,Je,V,ee,D,ne,ie,ue,Se,B,de,me,Le,nt,mt,_t,vt,Tt,xt,Ot,Et,Pt,kt,It],Yt={b:function(O,C,F){throw new U(O>>>=0).Pa(C>>>0,F>>>0),O},N:function(O){Rt(O>>>0,!T,1,!v,131072,!1),le.Sa()},k:function(O){O>>>=0,S?postMessage({cmd:"cleanupThread",thread:O}):He(O)},I:q,h:ee,T:D,E:ne,G:ie,U:ue,R:Se,J:B,Q:de,o:me,F:Le,C:nt,S:mt,D:_t,q:()=>!0,A:function(O,C){(O>>>=0)==C>>>0?setTimeout(()=>it()):S?postMessage({targetThread:O,cmd:"checkMailbox"}):(O=le.Fa[O])&&O.postMessage({cmd:"checkMailbox"})},L:function(){return-1},M:lt,p:function(O){w&&le.Fa[O>>>0].ref()},t:function(O,C,F){O=C+2097152>>>0<4194305-!!O?(O>>>0)+4294967296*C:NaN,F>>>=0,O=new Date(1e3*O),f()[F>>2>>>0]=O.getUTCSeconds(),f()[F+4>>2>>>0]=O.getUTCMinutes(),f()[F+8>>2>>>0]=O.getUTCHours(),f()[F+12>>2>>>0]=O.getUTCDate(),f()[F+16>>2>>>0]=O.getUTCMonth(),f()[F+20>>2>>>0]=O.getUTCFullYear()-1900,f()[F+24>>2>>>0]=O.getUTCDay(),O=(O.getTime()-Date.UTC(O.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,f()[F+28>>2>>>0]=O},u:function(O,C,F){O=C+2097152>>>0<4194305-!!O?(O>>>0)+4294967296*C:NaN,F>>>=0,O=new Date(1e3*O),f()[F>>2>>>0]=O.getSeconds(),f()[F+4>>2>>>0]=O.getMinutes(),f()[F+8>>2>>>0]=O.getHours(),f()[F+12>>2>>>0]=O.getDate(),f()[F+16>>2>>>0]=O.getMonth(),f()[F+20>>2>>>0]=O.getFullYear()-1900,f()[F+24>>2>>>0]=O.getDay(),C=(tt(O.getFullYear())?bt:yt)[O.getMonth()]+O.getDate()-1|0,f()[F+28>>2>>>0]=C,f()[F+36>>2>>>0]=-60*O.getTimezoneOffset(),C=new Date(O.getFullYear(),6,1).getTimezoneOffset();var G=new Date(O.getFullYear(),0,1).getTimezoneOffset();O=0|(C!=G&&O.getTimezoneOffset()==Math.min(G,C)),f()[F+32>>2>>>0]=O},v:function(O){O>>>=0;var C=new Date(f()[O+20>>2>>>0]+1900,f()[O+16>>2>>>0],f()[O+12>>2>>>0],f()[O+8>>2>>>0],f()[O+4>>2>>>0],f()[O>>2>>>0],0),F=f()[O+32>>2>>>0],G=C.getTimezoneOffset(),H=new Date(C.getFullYear(),6,1).getTimezoneOffset(),re=new Date(C.getFullYear(),0,1).getTimezoneOffset(),se=Math.min(re,H);return 0>F?f()[O+32>>2>>>0]=+(H!=re&&se==G):0<F!=(se==G)&&(H=Math.max(re,H),C.setTime(C.getTime()+6e4*((0<F?se:H)-G))),f()[O+24>>2>>>0]=C.getDay(),F=(tt(C.getFullYear())?bt:yt)[C.getMonth()]+C.getDate()-1|0,f()[O+28>>2>>>0]=F,f()[O>>2>>>0]=C.getSeconds(),f()[O+4>>2>>>0]=C.getMinutes(),f()[O+8>>2>>>0]=C.getHours(),f()[O+12>>2>>>0]=C.getDate(),f()[O+16>>2>>>0]=C.getMonth(),f()[O+20>>2>>>0]=C.getYear(),O=C.getTime()/1e3,Mt((Ae=O,1<=+Math.abs(Ae)?0<Ae?+Math.floor(Ae/4294967296)>>>0:~~+Math.ceil((Ae-+(~~Ae>>>0))/4294967296)>>>0:0)),O>>>0},r:vt,s:Tt,z:function(O,C,F){function G(Ie){return(Ie=Ie.toTimeString().match(/\(([A-Za-z ]+)\)$/))?Ie[1]:"GMT"}O>>>=0,C>>>=0,F>>>=0;var H=new Date().getFullYear(),re=new Date(H,0,1),se=new Date(H,6,1);H=re.getTimezoneOffset();var ve=se.getTimezoneOffset(),Fe=Math.max(H,ve);h()[O>>2>>>0]=60*Fe,f()[C>>2>>>0]=+(H!=ve),O=G(re),C=G(se),O=wt(O),C=wt(C),ve<H?(h()[F>>2>>>0]=O,h()[F+4>>2>>>0]=C):(h()[F>>2>>>0]=C,h()[F+4>>2>>>0]=O)},c:()=>{ke("")},l:function(){},i:function(){return Date.now()},V:()=>{throw ye+=1,"unwind"},B:function(){return 4294901760},e:()=>performance.timeOrigin+performance.now(),f:function(){return w?n(3993).cpus().length:navigator.hardwareConcurrency},K:function(O,C,F,G){for(le.pb=C>>>0,ut.length=F,C=G>>>0>>3,G=0;G<F;G++)ut[G]=p()[C+G>>>0];return Kt[O].apply(null,ut)},y:function(O){O>>>=0;var C=d().length;if(O<=C||4294901760<O)return!1;for(var F=1;4>=F;F*=2){var G=C*(1+.2/F);G=Math.min(G,O+100663296);var H=Math;G=Math.max(O,G);e:{H=H.min.call(H,4294901760,G+(65536-G%65536)%65536)-K.buffer.byteLength+65535>>>16;try{K.grow(H),xe();var re=1;break e}catch{}re=void 0}if(re)return!0}return!1},O:xt,P:Ot,j:Ke,g:Et,n:Pt,w:kt,m:It,x:function(O,C){return O>>>=0,C>>>=0,At(d().subarray(O>>>0,O+C>>>0)),0},a:K||l.wasmMemory,H:Nt,d:function(O,C,F,G){return Nt(O>>>0,C>>>0,F>>>0,G>>>0)}};(function(){function O(F,G){return F=F.exports,Z=F=function(H){var re=ve=>()=>ve()>>>0,se=ve=>Fe=>ve(Fe)>>>0;return(H=Object.assign({},H)).__errno_location=re(H.__errno_location),H.pthread_self=re(H.pthread_self),H.malloc=se(H.malloc),H.stackSave=re(H.stackSave),H.stackAlloc=se(H.stackAlloc),H}(F),le.Ta.push(Z.sa),Re=Z.ta,Ne.unshift(Z.W),J=G,je(),F}var C={a:Yt};if(Ge(),l.instantiateWasm)try{return l.instantiateWasm(C,O)}catch(F){A("Module.instantiateWasm callback failed with error: "+F),t(F)}(function(F,G){var H=Pe;return M||typeof WebAssembly.instantiateStreaming!="function"||Ee(H)||H.startsWith("file://")||w||typeof fetch!="function"?et(H,F,G):fetch(H,{credentials:"same-origin"}).then(re=>WebAssembly.instantiateStreaming(re,F).then(G,function(se){return A("wasm streaming compile failed: "+se),A("falling back to ArrayBuffer instantiation"),et(H,F,G)}))})(C,function(F){O(F.instance,F.module)}).catch(t)})(),l._OrtInit=(O,C)=>(l._OrtInit=Z.X)(O,C),l._OrtGetLastError=(O,C)=>(l._OrtGetLastError=Z.Y)(O,C),l._OrtCreateSessionOptions=(O,C,F,G,H,re,se,ve,Fe,Ie)=>(l._OrtCreateSessionOptions=Z.Z)(O,C,F,G,H,re,se,ve,Fe,Ie),l._OrtAppendExecutionProvider=(O,C)=>(l._OrtAppendExecutionProvider=Z._)(O,C),l._OrtAddSessionConfigEntry=(O,C,F)=>(l._OrtAddSessionConfigEntry=Z.$)(O,C,F),l._OrtReleaseSessionOptions=O=>(l._OrtReleaseSessionOptions=Z.aa)(O),l._OrtCreateSession=(O,C,F)=>(l._OrtCreateSession=Z.ba)(O,C,F),l._OrtReleaseSession=O=>(l._OrtReleaseSession=Z.ca)(O),l._OrtGetInputOutputCount=(O,C,F)=>(l._OrtGetInputOutputCount=Z.da)(O,C,F),l._OrtGetInputName=(O,C)=>(l._OrtGetInputName=Z.ea)(O,C),l._OrtGetOutputName=(O,C)=>(l._OrtGetOutputName=Z.fa)(O,C),l._OrtFree=O=>(l._OrtFree=Z.ga)(O),l._OrtCreateTensor=(O,C,F,G,H)=>(l._OrtCreateTensor=Z.ha)(O,C,F,G,H),l._OrtGetTensorData=(O,C,F,G,H)=>(l._OrtGetTensorData=Z.ia)(O,C,F,G,H),l._OrtReleaseTensor=O=>(l._OrtReleaseTensor=Z.ja)(O),l._OrtCreateRunOptions=(O,C,F,G)=>(l._OrtCreateRunOptions=Z.ka)(O,C,F,G),l._OrtAddRunConfigEntry=(O,C,F)=>(l._OrtAddRunConfigEntry=Z.la)(O,C,F),l._OrtReleaseRunOptions=O=>(l._OrtReleaseRunOptions=Z.ma)(O),l._OrtRun=(O,C,F,G,H,re,se,ve)=>(l._OrtRun=Z.na)(O,C,F,G,H,re,se,ve),l._OrtEndProfiling=O=>(l._OrtEndProfiling=Z.oa)(O);var ot=l._pthread_self=()=>(ot=l._pthread_self=Z.pa)(),Dt=l._malloc=O=>(Dt=l._malloc=Z.qa)(O);l._free=O=>(l._free=Z.ra)(O),l.__emscripten_tls_init=()=>(l.__emscripten_tls_init=Z.sa)();var Rt=l.__emscripten_thread_init=(O,C,F,G,H,re)=>(Rt=l.__emscripten_thread_init=Z.ua)(O,C,F,G,H,re);l.__emscripten_thread_crashed=()=>(l.__emscripten_thread_crashed=Z.va)();var at,Lt=(O,C,F,G)=>(Lt=Z.wa)(O,C,F,G),ft=O=>(ft=Z.xa)(O),ht=l.__emscripten_thread_exit=O=>(ht=l.__emscripten_thread_exit=Z.ya)(O),Ft=l.__emscripten_check_mailbox=()=>(Ft=l.__emscripten_check_mailbox=Z.za)(),Mt=O=>(Mt=Z.Aa)(O),jt=(O,C)=>(jt=Z.Ba)(O,C),pt=()=>(pt=Z.Ca)(),st=O=>(st=Z.Da)(O),gt=O=>(gt=Z.Ea)(O);function Ut(){function O(){if(!at&&(at=!0,l.calledRun=!0,!he)&&(S||Be(Ne),s(l),l.onRuntimeInitialized&&l.onRuntimeInitialized(),!S)){if(l.postRun)for(typeof l.postRun=="function"&&(l.postRun=[l.postRun]);l.postRun.length;){var C=l.postRun.shift();ge.unshift(C)}Be(ge)}}if(!(0<$e))if(S)s(l),S||Be(Ne),startWorker(l);else{if(l.preRun)for(typeof l.preRun=="function"&&(l.preRun=[l.preRun]);l.preRun.length;)be.unshift(l.preRun.shift());Be(be),0<$e||(l.setStatus?(l.setStatus("Running..."),setTimeout(function(){setTimeout(function(){l.setStatus("")},1),O()},1)):O())}}if(l.keepRuntimeAlive=Oe,l.wasmMemory=K,l.stackAlloc=gt,l.stackSave=pt,l.stackRestore=st,l.UTF8ToString=Ue,l.stringToUTF8=Q,l.lengthBytesUTF8=j,l.ExitStatus=Ve,l.PThread=le,Ce=function O(){at||Ut(),at||(Ce=O)},l.preInit)for(typeof l.preInit=="function"&&(l.preInit=[l.preInit]);0<l.preInit.length;)l.preInit.pop()();return Ut(),o.ready});c.exports=i},932:(c,e,n)=>{var r,i=(r=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0,typeof __filename<"u"&&(r=r||__filename),function(o={}){var a,d,f=o;f.ready=new Promise(($,U)=>{a=$,d=U});var h,p,s,t=Object.assign({},f),l="./this.program",u=($,U)=>{throw U},g=typeof window=="object",m=typeof importScripts=="function",_=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",b="";if(_){var y=n(1384),v=n(908);b=m?v.dirname(b)+"/":__dirname+"/",h=($,U)=>($=$.startsWith("file://")?new URL($):v.normalize($),y.readFileSync($,U?void 0:"utf8")),s=$=>(($=h($,!0)).buffer||($=new Uint8Array($)),$),p=($,U,V,q=!0)=>{$=$.startsWith("file://")?new URL($):v.normalize($),y.readFile($,q?void 0:"utf8",(ee,D)=>{ee?V(ee):U(q?D.buffer:D)})},!f.thisProgram&&1<process.argv.length&&(l=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),u=($,U)=>{throw process.exitCode=$,U},f.inspect=()=>"[Emscripten Module object]"}else(g||m)&&(m?b=self.location.href:typeof document<"u"&&document.currentScript&&(b=document.currentScript.src),r&&(b=r),b=b.indexOf("blob:")!==0?b.substr(0,b.replace(/[?#].*/,"").lastIndexOf("/")+1):"",h=$=>{var U=new XMLHttpRequest;return U.open("GET",$,!1),U.send(null),U.responseText},m&&(s=$=>{var U=new XMLHttpRequest;return U.open("GET",$,!1),U.responseType="arraybuffer",U.send(null),new Uint8Array(U.response)}),p=($,U,V)=>{var q=new XMLHttpRequest;q.open("GET",$,!0),q.responseType="arraybuffer",q.onload=()=>{q.status==200||q.status==0&&q.response?U(q.response):V()},q.onerror=V,q.send(null)});var T,w=f.print||console.log.bind(console),S=f.printErr||console.error.bind(console);Object.assign(f,t),t=null,f.thisProgram&&(l=f.thisProgram),f.quit&&(u=f.quit),f.wasmBinary&&(T=f.wasmBinary);var x=f.noExitRuntime||!0;typeof WebAssembly!="object"&&ce("no native wasm support detected");var P,I,N,L,E,M,k=!1;function A(){var $=P.buffer;f.HEAP8=N=new Int8Array($),f.HEAP16=new Int16Array($),f.HEAP32=E=new Int32Array($),f.HEAPU8=L=new Uint8Array($),f.HEAPU16=new Uint16Array($),f.HEAPU32=M=new Uint32Array($),f.HEAPF32=new Float32Array($),f.HEAPF64=new Float64Array($)}var R=[],K=[],Z=[];function J(){var $=f.preRun.shift();R.unshift($)}var X,te,oe=0,ae=null;function ce($){throw f.onAbort&&f.onAbort($),S($="Aborted("+$+")"),k=!0,$=new WebAssembly.RuntimeError($+". Build with -sASSERTIONS for more info."),d($),$}function fe($){return $.startsWith("data:application/octet-stream;base64,")}if(!fe(X="ort-wasm.wasm")){var he=X;X=f.locateFile?f.locateFile(he,b):b+he}function xe($){if($==X&&T)return new Uint8Array(T);if(s)return s($);throw"both async and sync fetching of the wasm failed"}function we($,U,V){return function(q){if(!T&&(g||m)){if(typeof fetch=="function"&&!q.startsWith("file://"))return fetch(q,{credentials:"same-origin"}).then(ee=>{if(!ee.ok)throw"failed to load wasm binary file at '"+q+"'";return ee.arrayBuffer()}).catch(()=>xe(q));if(p)return new Promise((ee,D)=>{p(q,j=>ee(new Uint8Array(j)),D)})}return Promise.resolve().then(()=>xe(q))}($).then(q=>WebAssembly.instantiate(q,U)).then(q=>q).then(V,q=>{S("failed to asynchronously prepare wasm: "+q),ce(q)})}function Re($){this.name="ExitStatus",this.message=`Program terminated with exit(${$})`,this.status=$}var be=$=>{for(;0<$.length;)$.shift()(f)};function Ne($){this.qa=$-24,this.va=function(U){M[this.qa+4>>2>>>0]=U},this.ua=function(U){M[this.qa+8>>2>>>0]=U},this.sa=function(U,V){this.ta(),this.va(U),this.ua(V)},this.ta=function(){M[this.qa+16>>2>>>0]=0}}var ge,ye=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Oe=($,U,V)=>{var q=(U>>>=0)+V;for(V=U;$[V]&&!(V>=q);)++V;if(16<V-U&&$.buffer&&ye)return ye.decode($.subarray(U,V));for(q="";U<V;){var ee=$[U++];if(128&ee){var D=63&$[U++];if((224&ee)==192)q+=String.fromCharCode((31&ee)<<6|D);else{var j=63&$[U++];65536>(ee=(240&ee)==224?(15&ee)<<12|D<<6|j:(7&ee)<<18|D<<12|j<<6|63&$[U++])?q+=String.fromCharCode(ee):(ee-=65536,q+=String.fromCharCode(55296|ee>>10,56320|1023&ee))}}else q+=String.fromCharCode(ee)}return q},Pe=($,U)=>($>>>=0)?Oe(L,$,U):"",Ae=$=>{for(var U=0,V=0;V<$.length;++V){var q=$.charCodeAt(V);127>=q?U++:2047>=q?U+=2:55296<=q&&57343>=q?(U+=4,++V):U+=3}return U},$e=($,U,V,q)=>{if(!(0<q))return 0;var ee=V>>>=0;q=V+q-1;for(var D=0;D<$.length;++D){var j=$.charCodeAt(D);if(55296<=j&&57343>=j&&(j=65536+((1023&j)<<10)|1023&$.charCodeAt(++D)),127>=j){if(V>=q)break;U[V++>>>0]=j}else{if(2047>=j){if(V+1>=q)break;U[V++>>>0]=192|j>>6}else{if(65535>=j){if(V+2>=q)break;U[V++>>>0]=224|j>>12}else{if(V+3>=q)break;U[V++>>>0]=240|j>>18,U[V++>>>0]=128|j>>12&63}U[V++>>>0]=128|j>>6&63}U[V++>>>0]=128|63&j}}return U[V>>>0]=0,V-ee},Ce=$=>$%4==0&&($%100!=0||$%400==0),Ge=[0,31,60,91,121,152,182,213,244,274,305,335],je=[0,31,59,90,120,151,181,212,243,273,304,334],ke=$=>{var U=Ae($)+1,V=qe(U);return V&&$e($,L,V,U),V},Ee={},ze=()=>{if(!ge){var $,U={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:l||"./this.program"};for($ in Ee)Ee[$]===void 0?delete U[$]:U[$]=Ee[$];var V=[];for($ in U)V.push(`${$}=${U[$]}`);ge=V}return ge},et=[null,[],[]],Ve=$=>(Ve=(()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return q=>crypto.getRandomValues(q);if(_)try{var U=n(760);if(U.randomFillSync)return q=>U.randomFillSync(q);var V=U.randomBytes;return q=>(q.set(V(q.byteLength)),q)}catch{}ce("initRandomDevice")})())($),Ze=[31,29,31,30,31,30,31,31,30,31,30,31],He=[31,28,31,30,31,30,31,31,30,31,30,31];function We($,U,V,q){function ee(B,de,me){for(B=typeof B=="number"?B.toString():B||"";B.length<de;)B=me[0]+B;return B}function D(B,de){return ee(B,de,"0")}function j(B,de){function me(nt){return 0>nt?-1:0<nt?1:0}var Le;return(Le=me(B.getFullYear()-de.getFullYear()))===0&&(Le=me(B.getMonth()-de.getMonth()))===0&&(Le=me(B.getDate()-de.getDate())),Le}function Y(B){switch(B.getDay()){case 0:return new Date(B.getFullYear()-1,11,29);case 1:return B;case 2:return new Date(B.getFullYear(),0,3);case 3:return new Date(B.getFullYear(),0,2);case 4:return new Date(B.getFullYear(),0,1);case 5:return new Date(B.getFullYear()-1,11,31);case 6:return new Date(B.getFullYear()-1,11,30)}}function Q(B){var de=B.ma;for(B=new Date(new Date(B.na+1900,0,1).getTime());0<de;){var me=B.getMonth(),Le=(Ce(B.getFullYear())?Ze:He)[me];if(!(de>Le-B.getDate())){B.setDate(B.getDate()+de);break}de-=Le-B.getDate()+1,B.setDate(1),11>me?B.setMonth(me+1):(B.setMonth(0),B.setFullYear(B.getFullYear()+1))}return me=new Date(B.getFullYear()+1,0,4),de=Y(new Date(B.getFullYear(),0,4)),me=Y(me),0>=j(de,B)?0>=j(me,B)?B.getFullYear()+1:B.getFullYear():B.getFullYear()-1}$>>>=0,U>>>=0,V>>>=0;var ne=E[40+(q>>>=0)>>2>>>0];for(var ie in q={ya:E[q>>2>>>0],xa:E[q+4>>2>>>0],oa:E[q+8>>2>>>0],ra:E[q+12>>2>>>0],pa:E[q+16>>2>>>0],na:E[q+20>>2>>>0],ha:E[q+24>>2>>>0],ma:E[q+28>>2>>>0],Aa:E[q+32>>2>>>0],wa:E[q+36>>2>>>0],za:ne?Pe(ne):""},V=Pe(V),ne={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})V=V.replace(new RegExp(ie,"g"),ne[ie]);var ue="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Se="January February March April May June July August September October November December".split(" ");for(ie in ne={"%a":B=>ue[B.ha].substring(0,3),"%A":B=>ue[B.ha],"%b":B=>Se[B.pa].substring(0,3),"%B":B=>Se[B.pa],"%C":B=>D((B.na+1900)/100|0,2),"%d":B=>D(B.ra,2),"%e":B=>ee(B.ra,2," "),"%g":B=>Q(B).toString().substring(2),"%G":B=>Q(B),"%H":B=>D(B.oa,2),"%I":B=>((B=B.oa)==0?B=12:12<B&&(B-=12),D(B,2)),"%j":B=>{for(var de=0,me=0;me<=B.pa-1;de+=(Ce(B.na+1900)?Ze:He)[me++]);return D(B.ra+de,3)},"%m":B=>D(B.pa+1,2),"%M":B=>D(B.xa,2),"%n":()=>`
`,"%p":B=>0<=B.oa&&12>B.oa?"AM":"PM","%S":B=>D(B.ya,2),"%t":()=>"	","%u":B=>B.ha||7,"%U":B=>D(Math.floor((B.ma+7-B.ha)/7),2),"%V":B=>{var de=Math.floor((B.ma+7-(B.ha+6)%7)/7);if(2>=(B.ha+371-B.ma-2)%7&&de++,de)de==53&&((me=(B.ha+371-B.ma)%7)==4||me==3&&Ce(B.na)||(de=1));else{de=52;var me=(B.ha+7-B.ma-1)%7;(me==4||me==5&&Ce(B.na%400-1))&&de++}return D(de,2)},"%w":B=>B.ha,"%W":B=>D(Math.floor((B.ma+7-(B.ha+6)%7)/7),2),"%y":B=>(B.na+1900).toString().substring(2),"%Y":B=>B.na+1900,"%z":B=>{var de=0<=(B=B.wa);return B=Math.abs(B)/60,(de?"+":"-")+("0000"+(B/60*100+B%60)).slice(-4)},"%Z":B=>B.za,"%%":()=>"%"},V=V.replace(/%%/g,"\0\0"),ne)V.includes(ie)&&(V=V.replace(new RegExp(ie,"g"),ne[ie](q)));return ie=function(B){var de=Array(Ae(B)+1);return $e(B,de,0,de.length),de}(V=V.replace(/\0\0/g,"%")),ie.length>U?0:(N.set(ie,$>>>0),ie.length-1)}var Ye={a:function($,U,V){throw new Ne($>>>=0).sa(U>>>0,V>>>0),$},e:function(){return 0},I:function(){},y:function(){},A:function(){},K:function(){return 0},G:function(){},B:function(){},F:function(){},g:function(){},z:function(){},w:function(){},H:function(){},x:function(){},k:()=>!0,n:function($,U,V){$=U+2097152>>>0<4194305-!!$?($>>>0)+4294967296*U:NaN,V>>>=0,$=new Date(1e3*$),E[V>>2>>>0]=$.getUTCSeconds(),E[V+4>>2>>>0]=$.getUTCMinutes(),E[V+8>>2>>>0]=$.getUTCHours(),E[V+12>>2>>>0]=$.getUTCDate(),E[V+16>>2>>>0]=$.getUTCMonth(),E[V+20>>2>>>0]=$.getUTCFullYear()-1900,E[V+24>>2>>>0]=$.getUTCDay(),E[V+28>>2>>>0]=($.getTime()-Date.UTC($.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},o:function($,U,V){$=U+2097152>>>0<4194305-!!$?($>>>0)+4294967296*U:NaN,V>>>=0,$=new Date(1e3*$),E[V>>2>>>0]=$.getSeconds(),E[V+4>>2>>>0]=$.getMinutes(),E[V+8>>2>>>0]=$.getHours(),E[V+12>>2>>>0]=$.getDate(),E[V+16>>2>>>0]=$.getMonth(),E[V+20>>2>>>0]=$.getFullYear()-1900,E[V+24>>2>>>0]=$.getDay(),E[V+28>>2>>>0]=(Ce($.getFullYear())?Ge:je)[$.getMonth()]+$.getDate()-1|0,E[V+36>>2>>>0]=-60*$.getTimezoneOffset(),U=new Date($.getFullYear(),6,1).getTimezoneOffset();var q=new Date($.getFullYear(),0,1).getTimezoneOffset();E[V+32>>2>>>0]=0|(U!=q&&$.getTimezoneOffset()==Math.min(q,U))},p:function($){$>>>=0;var U=new Date(E[$+20>>2>>>0]+1900,E[$+16>>2>>>0],E[$+12>>2>>>0],E[$+8>>2>>>0],E[$+4>>2>>>0],E[$>>2>>>0],0),V=E[$+32>>2>>>0],q=U.getTimezoneOffset(),ee=new Date(U.getFullYear(),6,1).getTimezoneOffset(),D=new Date(U.getFullYear(),0,1).getTimezoneOffset(),j=Math.min(D,ee);return 0>V?E[$+32>>2>>>0]=+(ee!=D&&j==q):0<V!=(j==q)&&(ee=Math.max(D,ee),U.setTime(U.getTime()+6e4*((0<V?j:ee)-q))),E[$+24>>2>>>0]=U.getDay(),E[$+28>>2>>>0]=(Ce(U.getFullYear())?Ge:je)[U.getMonth()]+U.getDate()-1|0,E[$>>2>>>0]=U.getSeconds(),E[$+4>>2>>>0]=U.getMinutes(),E[$+8>>2>>>0]=U.getHours(),E[$+12>>2>>>0]=U.getDate(),E[$+16>>2>>>0]=U.getMonth(),E[$+20>>2>>>0]=U.getYear(),$=U.getTime()/1e3,Xe((te=$,1<=+Math.abs(te)?0<te?+Math.floor(te/4294967296)>>>0:~~+Math.ceil((te-+(~~te>>>0))/4294967296)>>>0:0)),$>>>0},l:function(){return-52},m:function(){},u:function($,U,V){function q(Q){return(Q=Q.toTimeString().match(/\(([A-Za-z ]+)\)$/))?Q[1]:"GMT"}V>>>=0;var ee=new Date().getFullYear(),D=new Date(ee,0,1),j=new Date(ee,6,1);ee=D.getTimezoneOffset();var Y=j.getTimezoneOffset();M[$>>>0>>2>>>0]=60*Math.max(ee,Y),E[U>>>0>>2>>>0]=+(ee!=Y),$=q(D),U=q(j),$=ke($),U=ke(U),Y<ee?(M[V>>2>>>0]=$,M[V+4>>2>>>0]=U):(M[V>>2>>>0]=U,M[V+4>>2>>>0]=$)},d:()=>{ce("")},h:function(){return Date.now()},v:function(){return 4294901760},b:()=>performance.now(),J:function($,U,V){return U>>>=0,L.copyWithin($>>>0>>>0,U>>>0,U+(V>>>0)>>>0)},t:function($){$>>>=0;var U=L.length;if(4294901760<$)return!1;for(var V=1;4>=V;V*=2){var q=U*(1+.2/V);q=Math.min(q,$+100663296);var ee=Math;q=Math.max($,q);e:{ee=ee.min.call(ee,4294901760,q+(65536-q%65536)%65536)-P.buffer.byteLength+65535>>>16;try{P.grow(ee),A();var D=1;break e}catch{}D=void 0}if(D)return!0}return!1},D:function($,U){$>>>=0,U>>>=0;var V=0;return ze().forEach(function(q,ee){var D=U+V;for(ee=M[$+4*ee>>2>>>0]=D,D=0;D<q.length;++D)N[ee++>>0>>>0]=q.charCodeAt(D);N[ee>>0>>>0]=0,V+=q.length+1}),0},E:function($,U){$>>>=0,U>>>=0;var V=ze();M[$>>2>>>0]=V.length;var q=0;return V.forEach(function(ee){q+=ee.length+1}),M[U>>2>>>0]=q,0},s:$=>{x||(f.onExit&&f.onExit($),k=!0),u($,new Re($))},f:()=>52,j:function(){return 52},q:function(){return 70},i:function($,U,V,q){U>>>=0,V>>>=0,q>>>=0;for(var ee=0,D=0;D<V;D++){var j=M[U>>2>>>0],Y=M[U+4>>2>>>0];U+=8;for(var Q=0;Q<Y;Q++){var ne=L[j+Q>>>0],ie=et[$];ne===0||ne===10?(($===1?w:S)(Oe(ie,0)),ie.length=0):ie.push(ne)}ee+=Y}return M[q>>2>>>0]=ee,0},r:function($,U){return $>>>=0,Ve(L.subarray($>>>0,$+(U>>>0)>>>0)),0},C:We,c:function($,U,V,q){return We($>>>0,U>>>0,V>>>0,q>>>0)}};(function(){function $(V){if(V=V.exports,I=V=function(ee){var D=Y=>()=>Y()>>>0,j=Y=>Q=>Y(Q)>>>0;return(ee=Object.assign({},ee)).__errno_location=D(ee.__errno_location),ee.malloc=j(ee.malloc),ee.stackSave=D(ee.stackSave),ee.stackAlloc=j(ee.stackAlloc),ee}(V),P=I.L,A(),K.unshift(I.M),oe--,f.monitorRunDependencies&&f.monitorRunDependencies(oe),oe==0&&ae){var q=ae;ae=null,q()}return V}var U={a:Ye};if(oe++,f.monitorRunDependencies&&f.monitorRunDependencies(oe),f.instantiateWasm)try{return f.instantiateWasm(U,$)}catch(V){S("Module.instantiateWasm callback failed with error: "+V),d(V)}(function(V,q){var ee=X;return T||typeof WebAssembly.instantiateStreaming!="function"||fe(ee)||ee.startsWith("file://")||_||typeof fetch!="function"?we(ee,V,q):fetch(ee,{credentials:"same-origin"}).then(D=>WebAssembly.instantiateStreaming(D,V).then(q,function(j){return S("wasm streaming compile failed: "+j),S("falling back to ArrayBuffer instantiation"),we(ee,V,q)}))})(U,function(V){$(V.instance)}).catch(d)})(),f._OrtInit=($,U)=>(f._OrtInit=I.N)($,U),f._OrtGetLastError=($,U)=>(f._OrtGetLastError=I.O)($,U),f._OrtCreateSessionOptions=($,U,V,q,ee,D,j,Y,Q,ne)=>(f._OrtCreateSessionOptions=I.P)($,U,V,q,ee,D,j,Y,Q,ne),f._OrtAppendExecutionProvider=($,U)=>(f._OrtAppendExecutionProvider=I.Q)($,U),f._OrtAddSessionConfigEntry=($,U,V)=>(f._OrtAddSessionConfigEntry=I.R)($,U,V),f._OrtReleaseSessionOptions=$=>(f._OrtReleaseSessionOptions=I.S)($),f._OrtCreateSession=($,U,V)=>(f._OrtCreateSession=I.T)($,U,V),f._OrtReleaseSession=$=>(f._OrtReleaseSession=I.U)($),f._OrtGetInputOutputCount=($,U,V)=>(f._OrtGetInputOutputCount=I.V)($,U,V),f._OrtGetInputName=($,U)=>(f._OrtGetInputName=I.W)($,U),f._OrtGetOutputName=($,U)=>(f._OrtGetOutputName=I.X)($,U),f._OrtFree=$=>(f._OrtFree=I.Y)($),f._OrtCreateTensor=($,U,V,q,ee)=>(f._OrtCreateTensor=I.Z)($,U,V,q,ee),f._OrtGetTensorData=($,U,V,q,ee)=>(f._OrtGetTensorData=I._)($,U,V,q,ee),f._OrtReleaseTensor=$=>(f._OrtReleaseTensor=I.$)($),f._OrtCreateRunOptions=($,U,V,q)=>(f._OrtCreateRunOptions=I.aa)($,U,V,q),f._OrtAddRunConfigEntry=($,U,V)=>(f._OrtAddRunConfigEntry=I.ba)($,U,V),f._OrtReleaseRunOptions=$=>(f._OrtReleaseRunOptions=I.ca)($),f._OrtRun=($,U,V,q,ee,D,j,Y)=>(f._OrtRun=I.da)($,U,V,q,ee,D,j,Y),f._OrtEndProfiling=$=>(f._OrtEndProfiling=I.ea)($);var qe=f._malloc=$=>(qe=f._malloc=I.fa)($);f._free=$=>(f._free=I.ga)($);var Ue,Xe=$=>(Xe=I.ia)($),Ke=()=>(Ke=I.ja)(),le=$=>(le=I.ka)($),Be=$=>(Be=I.la)($);function Je(){function $(){if(!Ue&&(Ue=!0,f.calledRun=!0,!k)){if(be(K),a(f),f.onRuntimeInitialized&&f.onRuntimeInitialized(),f.postRun)for(typeof f.postRun=="function"&&(f.postRun=[f.postRun]);f.postRun.length;){var U=f.postRun.shift();Z.unshift(U)}be(Z)}}if(!(0<oe)){if(f.preRun)for(typeof f.preRun=="function"&&(f.preRun=[f.preRun]);f.preRun.length;)J();be(R),0<oe||(f.setStatus?(f.setStatus("Running..."),setTimeout(function(){setTimeout(function(){f.setStatus("")},1),$()},1)):$())}}if(f.stackAlloc=Be,f.stackSave=Ke,f.stackRestore=le,f.UTF8ToString=Pe,f.stringToUTF8=($,U,V)=>$e($,L,U,V),f.lengthBytesUTF8=Ae,ae=function $(){Ue||Je(),Ue||(ae=$)},f.preInit)for(typeof f.preInit=="function"&&(f.preInit=[f.preInit]);0<f.preInit.length;)f.preInit.pop()();return Je(),o.ready});c.exports=i},4537:c=>{c.exports=function(e,n){for(var r=new Array(arguments.length-1),i=0,o=2,a=!0;o<arguments.length;)r[i++]=arguments[o++];return new Promise(function(d,f){r[i]=function(h){if(a)if(a=!1,h)f(h);else{for(var p=new Array(arguments.length-1),s=0;s<p.length;)p[s++]=arguments[s];d.apply(null,p)}};try{e.apply(n||null,r)}catch(h){a&&(a=!1,f(h))}})}},7419:(c,e)=>{var n=e;n.length=function(d){var f=d.length;if(!f)return 0;for(var h=0;--f%4>1&&d.charAt(f)==="=";)++h;return Math.ceil(3*d.length)/4-h};for(var r=new Array(64),i=new Array(123),o=0;o<64;)i[r[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;n.encode=function(d,f,h){for(var p,s=null,t=[],l=0,u=0;f<h;){var g=d[f++];switch(u){case 0:t[l++]=r[g>>2],p=(3&g)<<4,u=1;break;case 1:t[l++]=r[p|g>>4],p=(15&g)<<2,u=2;break;case 2:t[l++]=r[p|g>>6],t[l++]=r[63&g],u=0}l>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,t)),l=0)}return u&&(t[l++]=r[p],t[l++]=61,u===1&&(t[l++]=61)),s?(l&&s.push(String.fromCharCode.apply(String,t.slice(0,l))),s.join("")):String.fromCharCode.apply(String,t.slice(0,l))};var a="invalid encoding";n.decode=function(d,f,h){for(var p,s=h,t=0,l=0;l<d.length;){var u=d.charCodeAt(l++);if(u===61&&t>1)break;if((u=i[u])===void 0)throw Error(a);switch(t){case 0:p=u,t=1;break;case 1:f[h++]=p<<2|(48&u)>>4,p=u,t=2;break;case 2:f[h++]=(15&p)<<4|(60&u)>>2,p=u,t=3;break;case 3:f[h++]=(3&p)<<6|u,t=0}}if(t===1)throw Error(a);return h-s},n.test=function(d){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(d)}},9211:c=>{function e(){this._listeners={}}c.exports=e,e.prototype.on=function(n,r,i){return(this._listeners[n]||(this._listeners[n]=[])).push({fn:r,ctx:i||this}),this},e.prototype.off=function(n,r){if(n===void 0)this._listeners={};else if(r===void 0)this._listeners[n]=[];else for(var i=this._listeners[n],o=0;o<i.length;)i[o].fn===r?i.splice(o,1):++o;return this},e.prototype.emit=function(n){var r=this._listeners[n];if(r){for(var i=[],o=1;o<arguments.length;)i.push(arguments[o++]);for(o=0;o<r.length;)r[o].fn.apply(r[o++].ctx,i)}return this}},945:c=>{function e(a){return typeof Float32Array<"u"?function(){var d=new Float32Array([-0]),f=new Uint8Array(d.buffer),h=f[3]===128;function p(u,g,m){d[0]=u,g[m]=f[0],g[m+1]=f[1],g[m+2]=f[2],g[m+3]=f[3]}function s(u,g,m){d[0]=u,g[m]=f[3],g[m+1]=f[2],g[m+2]=f[1],g[m+3]=f[0]}function t(u,g){return f[0]=u[g],f[1]=u[g+1],f[2]=u[g+2],f[3]=u[g+3],d[0]}function l(u,g){return f[3]=u[g],f[2]=u[g+1],f[1]=u[g+2],f[0]=u[g+3],d[0]}a.writeFloatLE=h?p:s,a.writeFloatBE=h?s:p,a.readFloatLE=h?t:l,a.readFloatBE=h?l:t}():function(){function d(h,p,s,t){var l=p<0?1:0;if(l&&(p=-p),p===0)h(1/p>0?0:2147483648,s,t);else if(isNaN(p))h(2143289344,s,t);else if(p>34028234663852886e22)h((l<<31|2139095040)>>>0,s,t);else if(p<11754943508222875e-54)h((l<<31|Math.round(p/1401298464324817e-60))>>>0,s,t);else{var u=Math.floor(Math.log(p)/Math.LN2);h((l<<31|u+127<<23|8388607&Math.round(p*Math.pow(2,-u)*8388608))>>>0,s,t)}}function f(h,p,s){var t=h(p,s),l=2*(t>>31)+1,u=t>>>23&255,g=8388607&t;return u===255?g?NaN:l*(1/0):u===0?1401298464324817e-60*l*g:l*Math.pow(2,u-150)*(g+8388608)}a.writeFloatLE=d.bind(null,n),a.writeFloatBE=d.bind(null,r),a.readFloatLE=f.bind(null,i),a.readFloatBE=f.bind(null,o)}(),typeof Float64Array<"u"?function(){var d=new Float64Array([-0]),f=new Uint8Array(d.buffer),h=f[7]===128;function p(u,g,m){d[0]=u,g[m]=f[0],g[m+1]=f[1],g[m+2]=f[2],g[m+3]=f[3],g[m+4]=f[4],g[m+5]=f[5],g[m+6]=f[6],g[m+7]=f[7]}function s(u,g,m){d[0]=u,g[m]=f[7],g[m+1]=f[6],g[m+2]=f[5],g[m+3]=f[4],g[m+4]=f[3],g[m+5]=f[2],g[m+6]=f[1],g[m+7]=f[0]}function t(u,g){return f[0]=u[g],f[1]=u[g+1],f[2]=u[g+2],f[3]=u[g+3],f[4]=u[g+4],f[5]=u[g+5],f[6]=u[g+6],f[7]=u[g+7],d[0]}function l(u,g){return f[7]=u[g],f[6]=u[g+1],f[5]=u[g+2],f[4]=u[g+3],f[3]=u[g+4],f[2]=u[g+5],f[1]=u[g+6],f[0]=u[g+7],d[0]}a.writeDoubleLE=h?p:s,a.writeDoubleBE=h?s:p,a.readDoubleLE=h?t:l,a.readDoubleBE=h?l:t}():function(){function d(h,p,s,t,l,u){var g=t<0?1:0;if(g&&(t=-t),t===0)h(0,l,u+p),h(1/t>0?0:2147483648,l,u+s);else if(isNaN(t))h(0,l,u+p),h(2146959360,l,u+s);else if(t>17976931348623157e292)h(0,l,u+p),h((g<<31|2146435072)>>>0,l,u+s);else{var m;if(t<22250738585072014e-324)h((m=t/5e-324)>>>0,l,u+p),h((g<<31|m/4294967296)>>>0,l,u+s);else{var _=Math.floor(Math.log(t)/Math.LN2);_===1024&&(_=1023),h(4503599627370496*(m=t*Math.pow(2,-_))>>>0,l,u+p),h((g<<31|_+1023<<20|1048576*m&1048575)>>>0,l,u+s)}}}function f(h,p,s,t,l){var u=h(t,l+p),g=h(t,l+s),m=2*(g>>31)+1,_=g>>>20&2047,b=4294967296*(1048575&g)+u;return _===2047?b?NaN:m*(1/0):_===0?5e-324*m*b:m*Math.pow(2,_-1075)*(b+4503599627370496)}a.writeDoubleLE=d.bind(null,n,0,4),a.writeDoubleBE=d.bind(null,r,4,0),a.readDoubleLE=f.bind(null,i,0,4),a.readDoubleBE=f.bind(null,o,4,0)}(),a}function n(a,d,f){d[f]=255&a,d[f+1]=a>>>8&255,d[f+2]=a>>>16&255,d[f+3]=a>>>24}function r(a,d,f){d[f]=a>>>24,d[f+1]=a>>>16&255,d[f+2]=a>>>8&255,d[f+3]=255&a}function i(a,d){return(a[d]|a[d+1]<<8|a[d+2]<<16|a[d+3]<<24)>>>0}function o(a,d){return(a[d]<<24|a[d+1]<<16|a[d+2]<<8|a[d+3])>>>0}c.exports=e(e)},7199:module=>{function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(c){}return null}module.exports=inquire},6662:c=>{c.exports=function(e,n,r){var i=r||8192,o=i>>>1,a=null,d=i;return function(f){if(f<1||f>o)return e(f);d+f>i&&(a=e(i),d=0);var h=n.call(a,d,d+=f);return 7&d&&(d=1+(7|d)),h}}},4997:(c,e)=>{var n=e;n.length=function(r){for(var i=0,o=0,a=0;a<r.length;++a)(o=r.charCodeAt(a))<128?i+=1:o<2048?i+=2:(64512&o)==55296&&(64512&r.charCodeAt(a+1))==56320?(++a,i+=4):i+=3;return i},n.read=function(r,i,o){if(o-i<1)return"";for(var a,d=null,f=[],h=0;i<o;)(a=r[i++])<128?f[h++]=a:a>191&&a<224?f[h++]=(31&a)<<6|63&r[i++]:a>239&&a<365?(a=((7&a)<<18|(63&r[i++])<<12|(63&r[i++])<<6|63&r[i++])-65536,f[h++]=55296+(a>>10),f[h++]=56320+(1023&a)):f[h++]=(15&a)<<12|(63&r[i++])<<6|63&r[i++],h>8191&&((d||(d=[])).push(String.fromCharCode.apply(String,f)),h=0);return d?(h&&d.push(String.fromCharCode.apply(String,f.slice(0,h))),d.join("")):String.fromCharCode.apply(String,f.slice(0,h))},n.write=function(r,i,o){for(var a,d,f=o,h=0;h<r.length;++h)(a=r.charCodeAt(h))<128?i[o++]=a:a<2048?(i[o++]=a>>6|192,i[o++]=63&a|128):(64512&a)==55296&&(64512&(d=r.charCodeAt(h+1)))==56320?(a=65536+((1023&a)<<10)+(1023&d),++h,i[o++]=a>>18|240,i[o++]=a>>12&63|128,i[o++]=a>>6&63|128,i[o++]=63&a|128):(i[o++]=a>>12|224,i[o++]=a>>6&63|128,i[o++]=63&a|128);return o-f}},3442:(c,e)=>{e.__esModule=!0;var n=function(){function r(i){if(!i)throw new TypeError("Invalid argument; `value` has no value.");this.value=r.EMPTY,i&&r.isGuid(i)&&(this.value=i)}return r.isGuid=function(i){var o=i.toString();return i&&(i instanceof r||r.validator.test(o))},r.create=function(){return new r([r.gen(2),r.gen(1),r.gen(1),r.gen(1),r.gen(3)].join("-"))},r.createEmpty=function(){return new r("emptyguid")},r.parse=function(i){return new r(i)},r.raw=function(){return[r.gen(2),r.gen(1),r.gen(1),r.gen(1),r.gen(3)].join("-")},r.gen=function(i){for(var o="",a=0;a<i;a++)o+=(65536*(1+Math.random())|0).toString(16).substring(1);return o},r.prototype.equals=function(i){return r.isGuid(i)&&this.value===i.toString()},r.prototype.isEmpty=function(){return this.value===r.EMPTY},r.prototype.toString=function(){return this.value},r.prototype.toJSON=function(){return{value:this.value}},r.validator=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),r.EMPTY="00000000-0000-0000-0000-000000000000",r}();e.Guid=n},2100:(c,e,n)=>{c.exports=n(9482)},9482:(c,e,n)=>{var r=e;function i(){r.util._configure(),r.Writer._configure(r.BufferWriter),r.Reader._configure(r.BufferReader)}r.build="minimal",r.Writer=n(1173),r.BufferWriter=n(3155),r.Reader=n(1408),r.BufferReader=n(593),r.util=n(9693),r.rpc=n(5994),r.roots=n(5054),r.configure=i,i()},1408:(c,e,n)=>{c.exports=f;var r,i=n(9693),o=i.LongBits,a=i.utf8;function d(g,m){return RangeError("index out of range: "+g.pos+" + "+(m||1)+" > "+g.len)}function f(g){this.buf=g,this.pos=0,this.len=g.length}var h,p=typeof Uint8Array<"u"?function(g){if(g instanceof Uint8Array||Array.isArray(g))return new f(g);throw Error("illegal buffer")}:function(g){if(Array.isArray(g))return new f(g);throw Error("illegal buffer")},s=function(){return i.Buffer?function(g){return(f.create=function(m){return i.Buffer.isBuffer(m)?new r(m):p(m)})(g)}:p};function t(){var g=new o(0,0),m=0;if(!(this.len-this.pos>4)){for(;m<3;++m){if(this.pos>=this.len)throw d(this);if(g.lo=(g.lo|(127&this.buf[this.pos])<<7*m)>>>0,this.buf[this.pos++]<128)return g}return g.lo=(g.lo|(127&this.buf[this.pos++])<<7*m)>>>0,g}for(;m<4;++m)if(g.lo=(g.lo|(127&this.buf[this.pos])<<7*m)>>>0,this.buf[this.pos++]<128)return g;if(g.lo=(g.lo|(127&this.buf[this.pos])<<28)>>>0,g.hi=(g.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return g;if(m=0,this.len-this.pos>4){for(;m<5;++m)if(g.hi=(g.hi|(127&this.buf[this.pos])<<7*m+3)>>>0,this.buf[this.pos++]<128)return g}else for(;m<5;++m){if(this.pos>=this.len)throw d(this);if(g.hi=(g.hi|(127&this.buf[this.pos])<<7*m+3)>>>0,this.buf[this.pos++]<128)return g}throw Error("invalid varint encoding")}function l(g,m){return(g[m-4]|g[m-3]<<8|g[m-2]<<16|g[m-1]<<24)>>>0}function u(){if(this.pos+8>this.len)throw d(this,8);return new o(l(this.buf,this.pos+=4),l(this.buf,this.pos+=4))}f.create=s(),f.prototype._slice=i.Array.prototype.subarray||i.Array.prototype.slice,f.prototype.uint32=(h=4294967295,function(){if(h=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(h=(h|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(h=(h|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(h=(h|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(h=(h|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return h;if((this.pos+=5)>this.len)throw this.pos=this.len,d(this,10);return h}),f.prototype.int32=function(){return 0|this.uint32()},f.prototype.sint32=function(){var g=this.uint32();return g>>>1^-(1&g)|0},f.prototype.bool=function(){return this.uint32()!==0},f.prototype.fixed32=function(){if(this.pos+4>this.len)throw d(this,4);return l(this.buf,this.pos+=4)},f.prototype.sfixed32=function(){if(this.pos+4>this.len)throw d(this,4);return 0|l(this.buf,this.pos+=4)},f.prototype.float=function(){if(this.pos+4>this.len)throw d(this,4);var g=i.float.readFloatLE(this.buf,this.pos);return this.pos+=4,g},f.prototype.double=function(){if(this.pos+8>this.len)throw d(this,4);var g=i.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,g},f.prototype.bytes=function(){var g=this.uint32(),m=this.pos,_=this.pos+g;if(_>this.len)throw d(this,g);return this.pos+=g,Array.isArray(this.buf)?this.buf.slice(m,_):m===_?new this.buf.constructor(0):this._slice.call(this.buf,m,_)},f.prototype.string=function(){var g=this.bytes();return a.read(g,0,g.length)},f.prototype.skip=function(g){if(typeof g=="number"){if(this.pos+g>this.len)throw d(this,g);this.pos+=g}else do if(this.pos>=this.len)throw d(this);while(128&this.buf[this.pos++]);return this},f.prototype.skipType=function(g){switch(g){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(g=7&this.uint32())!=4;)this.skipType(g);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+g+" at offset "+this.pos)}return this},f._configure=function(g){r=g,f.create=s(),r._configure();var m=i.Long?"toLong":"toNumber";i.merge(f.prototype,{int64:function(){return t.call(this)[m](!1)},uint64:function(){return t.call(this)[m](!0)},sint64:function(){return t.call(this).zzDecode()[m](!1)},fixed64:function(){return u.call(this)[m](!0)},sfixed64:function(){return u.call(this)[m](!1)}})}},593:(c,e,n)=>{c.exports=o;var r=n(1408);(o.prototype=Object.create(r.prototype)).constructor=o;var i=n(9693);function o(a){r.call(this,a)}o._configure=function(){i.Buffer&&(o.prototype._slice=i.Buffer.prototype.slice)},o.prototype.string=function(){var a=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+a,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+a,this.len))},o._configure()},5054:c=>{c.exports={}},5994:(c,e,n)=>{e.Service=n(7948)},7948:(c,e,n)=>{c.exports=i;var r=n(9693);function i(o,a,d){if(typeof o!="function")throw TypeError("rpcImpl must be a function");r.EventEmitter.call(this),this.rpcImpl=o,this.requestDelimited=!!a,this.responseDelimited=!!d}(i.prototype=Object.create(r.EventEmitter.prototype)).constructor=i,i.prototype.rpcCall=function o(a,d,f,h,p){if(!h)throw TypeError("request must be specified");var s=this;if(!p)return r.asPromise(o,s,a,d,f,h);if(s.rpcImpl)try{return s.rpcImpl(a,d[s.requestDelimited?"encodeDelimited":"encode"](h).finish(),function(t,l){if(t)return s.emit("error",t,a),p(t);if(l!==null){if(!(l instanceof f))try{l=f[s.responseDelimited?"decodeDelimited":"decode"](l)}catch(u){return s.emit("error",u,a),p(u)}return s.emit("data",l,a),p(null,l)}s.end(!0)})}catch(t){return s.emit("error",t,a),void setTimeout(function(){p(t)},0)}else setTimeout(function(){p(Error("already ended"))},0)},i.prototype.end=function(o){return this.rpcImpl&&(o||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},1945:(c,e,n)=>{c.exports=i;var r=n(9693);function i(f,h){this.lo=f>>>0,this.hi=h>>>0}var o=i.zero=new i(0,0);o.toNumber=function(){return 0},o.zzEncode=o.zzDecode=function(){return this},o.length=function(){return 1};var a=i.zeroHash="\0\0\0\0\0\0\0\0";i.fromNumber=function(f){if(f===0)return o;var h=f<0;h&&(f=-f);var p=f>>>0,s=(f-p)/4294967296>>>0;return h&&(s=~s>>>0,p=~p>>>0,++p>4294967295&&(p=0,++s>4294967295&&(s=0))),new i(p,s)},i.from=function(f){if(typeof f=="number")return i.fromNumber(f);if(r.isString(f)){if(!r.Long)return i.fromNumber(parseInt(f,10));f=r.Long.fromString(f)}return f.low||f.high?new i(f.low>>>0,f.high>>>0):o},i.prototype.toNumber=function(f){if(!f&&this.hi>>>31){var h=1+~this.lo>>>0,p=~this.hi>>>0;return h||(p=p+1>>>0),-(h+4294967296*p)}return this.lo+4294967296*this.hi},i.prototype.toLong=function(f){return r.Long?new r.Long(0|this.lo,0|this.hi,!!f):{low:0|this.lo,high:0|this.hi,unsigned:!!f}};var d=String.prototype.charCodeAt;i.fromHash=function(f){return f===a?o:new i((d.call(f,0)|d.call(f,1)<<8|d.call(f,2)<<16|d.call(f,3)<<24)>>>0,(d.call(f,4)|d.call(f,5)<<8|d.call(f,6)<<16|d.call(f,7)<<24)>>>0)},i.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},i.prototype.zzEncode=function(){var f=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^f)>>>0,this.lo=(this.lo<<1^f)>>>0,this},i.prototype.zzDecode=function(){var f=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^f)>>>0,this.hi=(this.hi>>>1^f)>>>0,this},i.prototype.length=function(){var f=this.lo,h=(this.lo>>>28|this.hi<<4)>>>0,p=this.hi>>>24;return p===0?h===0?f<16384?f<128?1:2:f<2097152?3:4:h<16384?h<128?5:6:h<2097152?7:8:p<128?9:10}},9693:function(c,e,n){var r=e;function i(a,d,f){for(var h=Object.keys(d),p=0;p<h.length;++p)a[h[p]]!==void 0&&f||(a[h[p]]=d[h[p]]);return a}function o(a){function d(f,h){if(!(this instanceof d))return new d(f,h);Object.defineProperty(this,"message",{get:function(){return f}}),Error.captureStackTrace?Error.captureStackTrace(this,d):Object.defineProperty(this,"stack",{value:new Error().stack||""}),h&&i(this,h)}return d.prototype=Object.create(Error.prototype,{constructor:{value:d,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return a},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),d}r.asPromise=n(4537),r.base64=n(7419),r.EventEmitter=n(9211),r.float=n(945),r.inquire=n(7199),r.utf8=n(4997),r.pool=n(6662),r.LongBits=n(1945),r.isNode=!!(typeof commonjsGlobal<"u"&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),r.global=r.isNode&&commonjsGlobal||typeof window<"u"&&window||typeof self<"u"&&self||this,r.emptyArray=Object.freeze?Object.freeze([]):[],r.emptyObject=Object.freeze?Object.freeze({}):{},r.isInteger=Number.isInteger||function(a){return typeof a=="number"&&isFinite(a)&&Math.floor(a)===a},r.isString=function(a){return typeof a=="string"||a instanceof String},r.isObject=function(a){return a&&typeof a=="object"},r.isset=r.isSet=function(a,d){var f=a[d];return!(f==null||!a.hasOwnProperty(d))&&(typeof f!="object"||(Array.isArray(f)?f.length:Object.keys(f).length)>0)},r.Buffer=function(){try{var a=r.inquire("buffer").Buffer;return a.prototype.utf8Write?a:null}catch{return null}}(),r._Buffer_from=null,r._Buffer_allocUnsafe=null,r.newBuffer=function(a){return typeof a=="number"?r.Buffer?r._Buffer_allocUnsafe(a):new r.Array(a):r.Buffer?r._Buffer_from(a):typeof Uint8Array>"u"?a:new Uint8Array(a)},r.Array=typeof Uint8Array<"u"?Uint8Array:Array,r.Long=r.global.dcodeIO&&r.global.dcodeIO.Long||r.global.Long||r.inquire("long"),r.key2Re=/^true|false|0|1$/,r.key32Re=/^-?(?:0|[1-9][0-9]*)$/,r.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,r.longToHash=function(a){return a?r.LongBits.from(a).toHash():r.LongBits.zeroHash},r.longFromHash=function(a,d){var f=r.LongBits.fromHash(a);return r.Long?r.Long.fromBits(f.lo,f.hi,d):f.toNumber(!!d)},r.merge=i,r.lcFirst=function(a){return a.charAt(0).toLowerCase()+a.substring(1)},r.newError=o,r.ProtocolError=o("ProtocolError"),r.oneOfGetter=function(a){for(var d={},f=0;f<a.length;++f)d[a[f]]=1;return function(){for(var h=Object.keys(this),p=h.length-1;p>-1;--p)if(d[h[p]]===1&&this[h[p]]!==void 0&&this[h[p]]!==null)return h[p]}},r.oneOfSetter=function(a){return function(d){for(var f=0;f<a.length;++f)a[f]!==d&&delete this[a[f]]}},r.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},r._configure=function(){var a=r.Buffer;a?(r._Buffer_from=a.from!==Uint8Array.from&&a.from||function(d,f){return new a(d,f)},r._Buffer_allocUnsafe=a.allocUnsafe||function(d){return new a(d)}):r._Buffer_from=r._Buffer_allocUnsafe=null}},1173:(c,e,n)=>{c.exports=s;var r,i=n(9693),o=i.LongBits,a=i.base64,d=i.utf8;function f(b,y,v){this.fn=b,this.len=y,this.next=void 0,this.val=v}function h(){}function p(b){this.head=b.head,this.tail=b.tail,this.len=b.len,this.next=b.states}function s(){this.len=0,this.head=new f(h,0,0),this.tail=this.head,this.states=null}var t=function(){return i.Buffer?function(){return(s.create=function(){return new r})()}:function(){return new s}};function l(b,y,v){y[v]=255&b}function u(b,y){this.len=b,this.next=void 0,this.val=y}function g(b,y,v){for(;b.hi;)y[v++]=127&b.lo|128,b.lo=(b.lo>>>7|b.hi<<25)>>>0,b.hi>>>=7;for(;b.lo>127;)y[v++]=127&b.lo|128,b.lo=b.lo>>>7;y[v++]=b.lo}function m(b,y,v){y[v]=255&b,y[v+1]=b>>>8&255,y[v+2]=b>>>16&255,y[v+3]=b>>>24}s.create=t(),s.alloc=function(b){return new i.Array(b)},i.Array!==Array&&(s.alloc=i.pool(s.alloc,i.Array.prototype.subarray)),s.prototype._push=function(b,y,v){return this.tail=this.tail.next=new f(b,y,v),this.len+=y,this},u.prototype=Object.create(f.prototype),u.prototype.fn=function(b,y,v){for(;b>127;)y[v++]=127&b|128,b>>>=7;y[v]=b},s.prototype.uint32=function(b){return this.len+=(this.tail=this.tail.next=new u((b>>>=0)<128?1:b<16384?2:b<2097152?3:b<268435456?4:5,b)).len,this},s.prototype.int32=function(b){return b<0?this._push(g,10,o.fromNumber(b)):this.uint32(b)},s.prototype.sint32=function(b){return this.uint32((b<<1^b>>31)>>>0)},s.prototype.uint64=function(b){var y=o.from(b);return this._push(g,y.length(),y)},s.prototype.int64=s.prototype.uint64,s.prototype.sint64=function(b){var y=o.from(b).zzEncode();return this._push(g,y.length(),y)},s.prototype.bool=function(b){return this._push(l,1,b?1:0)},s.prototype.fixed32=function(b){return this._push(m,4,b>>>0)},s.prototype.sfixed32=s.prototype.fixed32,s.prototype.fixed64=function(b){var y=o.from(b);return this._push(m,4,y.lo)._push(m,4,y.hi)},s.prototype.sfixed64=s.prototype.fixed64,s.prototype.float=function(b){return this._push(i.float.writeFloatLE,4,b)},s.prototype.double=function(b){return this._push(i.float.writeDoubleLE,8,b)};var _=i.Array.prototype.set?function(b,y,v){y.set(b,v)}:function(b,y,v){for(var T=0;T<b.length;++T)y[v+T]=b[T]};s.prototype.bytes=function(b){var y=b.length>>>0;if(!y)return this._push(l,1,0);if(i.isString(b)){var v=s.alloc(y=a.length(b));a.decode(b,v,0),b=v}return this.uint32(y)._push(_,y,b)},s.prototype.string=function(b){var y=d.length(b);return y?this.uint32(y)._push(d.write,y,b):this._push(l,1,0)},s.prototype.fork=function(){return this.states=new p(this),this.head=this.tail=new f(h,0,0),this.len=0,this},s.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new f(h,0,0),this.len=0),this},s.prototype.ldelim=function(){var b=this.head,y=this.tail,v=this.len;return this.reset().uint32(v),v&&(this.tail.next=b.next,this.tail=y,this.len+=v),this},s.prototype.finish=function(){for(var b=this.head.next,y=this.constructor.alloc(this.len),v=0;b;)b.fn(b.val,y,v),v+=b.len,b=b.next;return y},s._configure=function(b){r=b,s.create=t(),r._configure()}},3155:(c,e,n)=>{c.exports=o;var r=n(1173);(o.prototype=Object.create(r.prototype)).constructor=o;var i=n(9693);function o(){r.call(this)}function a(d,f,h){d.length<40?i.utf8.write(d,f,h):f.utf8Write?f.utf8Write(d,h):f.write(d,h)}o._configure=function(){o.alloc=i._Buffer_allocUnsafe,o.writeBytesBuffer=i.Buffer&&i.Buffer.prototype instanceof Uint8Array&&i.Buffer.prototype.set.name==="set"?function(d,f,h){f.set(d,h)}:function(d,f,h){if(d.copy)d.copy(f,h,0,d.length);else for(var p=0;p<d.length;)f[h++]=d[p++]}},o.prototype.bytes=function(d){i.isString(d)&&(d=i._Buffer_from(d,"base64"));var f=d.length>>>0;return this.uint32(f),f&&this._push(o.writeBytesBuffer,f,d),this},o.prototype.string=function(d){var f=i.Buffer.byteLength(d);return this.uint32(f),f&&this._push(a,f,d),this},o._configure()},4154:c=>{c.exports=`"use strict";var e={},a="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node;if(a){var r=require("worker_threads"),t=r.parentPort;t.on("message",(e=>onmessage({data:e})));var s=require("fs");Object.assign(global,{self:global,require:require,Module:e,location:{href:__filename},Worker:r.Worker,importScripts:e=>(0,eval)(s.readFileSync(e,"utf8")+"//# sourceURL="+e),postMessage:e=>t.postMessage(e),performance:global.performance||{now:Date.now}})}var o=!1,d=function(){var e=Array.prototype.slice.call(arguments).join(" ");a?s.writeSync(2,e+"\\n"):console.error(e)};self.alert=function(){var a=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:a,threadId:e._pthread_self()})},e.instantiateWasm=(a,r)=>{var t=e.wasmModule;return e.wasmModule=null,r(new WebAssembly.Instance(t,a))},self.onunhandledrejection=e=>{throw e.reason??e},self.onmessage=function a(r){try{if("load"===r.data.cmd){let s=[];self.onmessage=e=>s.push(e),self.startWorker=r=>{e=r,postMessage({cmd:"loaded"});for(let e of s)a(e);self.onmessage=a},e.wasmModule=r.data.wasmModule;for(const a of r.data.handlers)e[a]=(...e)=>{postMessage({cmd:"callHandler",handler:a,args:e})};if(e.wasmMemory=r.data.wasmMemory,e.buffer=e.wasmMemory.buffer,e.ENVIRONMENT_IS_PTHREAD=!0,"string"==typeof r.data.urlOrBlob)importScripts(r.data.urlOrBlob);else{var t=URL.createObjectURL(r.data.urlOrBlob);importScripts(t),URL.revokeObjectURL(t)}ortWasmThreaded(e)}else if("run"===r.data.cmd){e.__emscripten_thread_init(r.data.pthread_ptr,0,0,1),e.__emscripten_thread_mailbox_await(r.data.pthread_ptr),e.establishStackSpace(),e.PThread.receiveObjectTransfer(r.data),e.PThread.threadInitTLS(),o||(o=!0);try{e.invokeEntryPoint(r.data.start_routine,r.data.arg)}catch(e){if("unwind"!=e)throw e}}else"cancel"===r.data.cmd?e._pthread_self()&&e.__emscripten_thread_exit(-1):"setimmediate"===r.data.target||("checkMailbox"===r.data.cmd?o&&e.checkMailbox():r.data.cmd&&(d("worker.js received unknown command "+r.data.cmd),d(r.data)))}catch(a){throw e.__emscripten_thread_crashed&&e.__emscripten_thread_crashed(),a}};
`},7067:()=>{},1296:()=>{},760:()=>{},1384:()=>{},3993:()=>{},908:()=>{},6953:()=>{},9925:()=>{},2806:()=>{},6449:()=>{},2850:()=>{},5381:()=>{},685:(c,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveBackend=e.registerBackend=void 0;const n={},r=[];e.registerBackend=(i,o,a)=>{if(!o||typeof o.init!="function"||typeof o.createSessionHandler!="function")throw new TypeError("not a valid backend");{const d=n[i];if(d===void 0)n[i]={backend:o,priority:a};else{if(d.priority>a)return;if(d.priority===a&&d.backend!==o)throw new Error(`cannot register backend "${i}" using priority ${a}`)}if(a>=0){const f=r.indexOf(i);f!==-1&&r.splice(f,1);for(let h=0;h<r.length;h++)if(n[r[h]].priority<=a)return void r.splice(h,0,i);r.push(i)}}},e.resolveBackend=async i=>{const o=i.length===0?r:i,a=[];for(const d of o){const f=n[d];if(f){if(f.initialized)return f.backend;if(f.aborted)continue;const h=!!f.initPromise;try{return h||(f.initPromise=f.backend.init()),await f.initPromise,f.initialized=!0,f.backend}catch(p){h||a.push({name:d,err:p}),f.aborted=!0}finally{delete f.initPromise}}}throw new Error(`no available backend found. ERR: ${a.map(d=>`[${d.name}] ${d.err}`).join(", ")}`)}},4798:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.registerBackend=void 0;var r=n(685);Object.defineProperty(e,"registerBackend",{enumerable:!0,get:function(){return r.registerBackend}})},3121:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.env=void 0;const r=n(9104);let i="warning";e.env={wasm:{},webgl:{},webgpu:{},versions:{common:r.version},set logLevel(o){if(o!==void 0){if(typeof o!="string"||["verbose","info","warning","error","fatal"].indexOf(o)===-1)throw new Error(`Unsupported logging level: ${o}`);i=o}},get logLevel(){return i}},Object.defineProperty(e.env,"logLevel",{enumerable:!0})},2457:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.env=void 0;const r=n(3121);e.env=r.env},2235:function(c,e,n){var r=this&&this.__createBinding||(Object.create?function(o,a,d,f){f===void 0&&(f=d);var h=Object.getOwnPropertyDescriptor(a,d);h&&!("get"in h?!a.__esModule:h.writable||h.configurable)||(h={enumerable:!0,get:function(){return a[d]}}),Object.defineProperty(o,f,h)}:function(o,a,d,f){f===void 0&&(f=d),o[f]=a[d]}),i=this&&this.__exportStar||function(o,a){for(var d in o)d==="default"||Object.prototype.hasOwnProperty.call(a,d)||r(a,o,d)};Object.defineProperty(e,"__esModule",{value:!0}),i(n(4798),e),i(n(2457),e),i(n(3974),e),i(n(963),e),i(n(7852),e)},8036:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.InferenceSession=void 0;const r=n(685),i=n(963);class o{constructor(d){this.handler=d}async run(d,f,h){const p={};let s={};if(typeof d!="object"||d===null||d instanceof i.Tensor||Array.isArray(d))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let t=!0;if(typeof f=="object"){if(f===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(f instanceof i.Tensor)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(f)){if(f.length===0)throw new TypeError("'fetches' cannot be an empty array.");t=!1;for(const g of f){if(typeof g!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(g)===-1)throw new RangeError(`'fetches' contains invalid output name: ${g}.`);p[g]=null}if(typeof h=="object"&&h!==null)s=h;else if(h!==void 0)throw new TypeError("'options' must be an object.")}else{let g=!1;const m=Object.getOwnPropertyNames(f);for(const _ of this.outputNames)if(m.indexOf(_)!==-1){const b=f[_];(b===null||b instanceof i.Tensor)&&(g=!0,t=!1,p[_]=b)}if(g){if(typeof h=="object"&&h!==null)s=h;else if(h!==void 0)throw new TypeError("'options' must be an object.")}else s=f}}else if(f!==void 0)throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(const g of this.inputNames)if(d[g]===void 0)throw new Error(`input '${g}' is missing in 'feeds'.`);if(t)for(const g of this.outputNames)p[g]=null;const l=await this.handler.run(d,p,s),u={};for(const g in l)Object.hasOwnProperty.call(l,g)&&(u[g]=new i.Tensor(l[g].type,l[g].data,l[g].dims));return u}async release(){return this.handler.dispose()}static async create(d,f,h,p){let s,t={};if(typeof d=="string"){if(s=d,typeof f=="object"&&f!==null)t=f;else if(f!==void 0)throw new TypeError("'options' must be an object.")}else if(d instanceof Uint8Array){if(s=d,typeof f=="object"&&f!==null)t=f;else if(f!==void 0)throw new TypeError("'options' must be an object.")}else{if(!(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer))throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");{const m=d;let _=0,b=d.byteLength;if(typeof f=="object"&&f!==null)t=f;else if(typeof f=="number"){if(_=f,!Number.isSafeInteger(_))throw new RangeError("'byteOffset' must be an integer.");if(_<0||_>=m.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${m.byteLength}).`);if(b=d.byteLength-_,typeof h=="number"){if(b=h,!Number.isSafeInteger(b))throw new RangeError("'byteLength' must be an integer.");if(b<=0||_+b>m.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${m.byteLength-_}].`);if(typeof p=="object"&&p!==null)t=p;else if(p!==void 0)throw new TypeError("'options' must be an object.")}else if(h!==void 0)throw new TypeError("'byteLength' must be a number.")}else if(f!==void 0)throw new TypeError("'options' must be an object.");s=new Uint8Array(m,_,b)}}const l=(t.executionProviders||[]).map(m=>typeof m=="string"?m:m.name),u=await(0,r.resolveBackend)(l),g=await u.createSessionHandler(s,t);return new o(g)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}e.InferenceSession=o},3974:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.InferenceSession=void 0;const r=n(8036);e.InferenceSession=r.InferenceSession},7852:(c,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},2350:(c,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tensorToImageData=e.tensorToDataURL=void 0,e.tensorToDataURL=(n,r)=>{const i=document.createElement("canvas");i.width=n.dims[3],i.height=n.dims[2];const o=i.getContext("2d");if(o!=null){let a,d;(r==null?void 0:r.tensorLayout)!==void 0&&r.tensorLayout==="NHWC"?(a=n.dims[2],d=n.dims[3]):(a=n.dims[3],d=n.dims[2]);const f=(r==null?void 0:r.format)!==void 0?r.format:"RGB",h=r==null?void 0:r.norm;let p,s;h===void 0||h.mean===void 0?p=[255,255,255,255]:typeof h.mean=="number"?p=[h.mean,h.mean,h.mean,h.mean]:(p=[h.mean[0],h.mean[1],h.mean[2],0],h.mean[3]!==void 0&&(p[3]=h.mean[3])),h===void 0||h.bias===void 0?s=[0,0,0,0]:typeof h.bias=="number"?s=[h.bias,h.bias,h.bias,h.bias]:(s=[h.bias[0],h.bias[1],h.bias[2],0],h.bias[3]!==void 0&&(s[3]=h.bias[3]));const t=d*a;let l=0,u=t,g=2*t,m=-1;f==="RGBA"?(l=0,u=t,g=2*t,m=3*t):f==="RGB"?(l=0,u=t,g=2*t):f==="RBG"&&(l=0,g=t,u=2*t);for(let _=0;_<d;_++)for(let b=0;b<a;b++){const y=(n.data[l++]-s[0])*p[0],v=(n.data[u++]-s[1])*p[1],T=(n.data[g++]-s[2])*p[2],w=m===-1?255:(n.data[m++]-s[3])*p[3];o.fillStyle="rgba("+y+","+v+","+T+","+w+")",o.fillRect(b,_,1,1)}return i.toDataURL()}throw new Error("Can not access image data")},e.tensorToImageData=(n,r)=>{const i=document.createElement("canvas").getContext("2d");let o;if(i==null)throw new Error("Can not access image data");{let a,d,f;(r==null?void 0:r.tensorLayout)!==void 0&&r.tensorLayout==="NHWC"?(a=n.dims[2],d=n.dims[1],f=n.dims[3]):(a=n.dims[3],d=n.dims[2],f=n.dims[1]);const h=r!==void 0&&r.format!==void 0?r.format:"RGB",p=r==null?void 0:r.norm;let s,t;p===void 0||p.mean===void 0?s=[255,255,255,255]:typeof p.mean=="number"?s=[p.mean,p.mean,p.mean,p.mean]:(s=[p.mean[0],p.mean[1],p.mean[2],255],p.mean[3]!==void 0&&(s[3]=p.mean[3])),p===void 0||p.bias===void 0?t=[0,0,0,0]:typeof p.bias=="number"?t=[p.bias,p.bias,p.bias,p.bias]:(t=[p.bias[0],p.bias[1],p.bias[2],0],p.bias[3]!==void 0&&(t[3]=p.bias[3]));const l=d*a;if(r!==void 0&&(r.format!==void 0&&f===4&&r.format!=="RGBA"||f===3&&r.format!=="RGB"&&r.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");const u=4;let g=0,m=1,_=2,b=3,y=0,v=l,T=2*l,w=-1;h==="RGBA"?(y=0,v=l,T=2*l,w=3*l):h==="RGB"?(y=0,v=l,T=2*l):h==="RBG"&&(y=0,T=l,v=2*l),o=i.createImageData(a,d);for(let S=0;S<d*a;g+=u,m+=u,_+=u,b+=u,S++)o.data[g]=(n.data[y++]-t[0])*s[0],o.data[m]=(n.data[v++]-t[1])*s[1],o.data[_]=(n.data[T++]-t[2])*s[2],o.data[b]=w===-1?255:(n.data[w++]-t[3])*s[3]}return o}},4866:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tensorFromImage=e.bufferToTensor=void 0;const r=n(963);e.bufferToTensor=(i,o)=>{if(i===void 0)throw new Error("Image buffer must be defined");if(o.height===void 0||o.width===void 0)throw new Error("Image height and width must be defined");if(o.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");const{height:a,width:d}=o,f=o.norm??{mean:255,bias:0};let h,p;h=typeof f.mean=="number"?[f.mean,f.mean,f.mean,f.mean]:[f.mean[0],f.mean[1],f.mean[2],f.mean[3]??255],p=typeof f.bias=="number"?[f.bias,f.bias,f.bias,f.bias]:[f.bias[0],f.bias[1],f.bias[2],f.bias[3]??0];const s=o.format!==void 0?o.format:"RGBA",t=o.tensorFormat!==void 0&&o.tensorFormat!==void 0?o.tensorFormat:"RGB",l=a*d,u=t==="RGBA"?new Float32Array(4*l):new Float32Array(3*l);let g=4,m=0,_=1,b=2,y=3,v=0,T=l,w=2*l,S=-1;s==="RGB"&&(g=3,m=0,_=1,b=2,y=-1),t==="RGBA"?S=3*l:t==="RBG"?(v=0,w=l,T=2*l):t==="BGR"&&(w=0,T=l,v=2*l);for(let x=0;x<l;x++,m+=g,b+=g,_+=g,y+=g)u[v++]=(i[m]+p[0])/h[0],u[T++]=(i[_]+p[1])/h[1],u[w++]=(i[b]+p[2])/h[2],S!==-1&&y!==-1&&(u[S++]=(i[y]+p[3])/h[3]);return t==="RGBA"?new r.Tensor("float32",u,[1,4,a,d]):new r.Tensor("float32",u,[1,3,a,d])},e.tensorFromImage=async(i,o)=>{const a=typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement,d=typeof ImageData<"u"&&i instanceof ImageData,f=typeof ImageBitmap<"u"&&i instanceof ImageBitmap,h=typeof i=="string";let p,s=o??{};if(a){const t=document.createElement("canvas");t.width=i.width,t.height=i.height;const l=t.getContext("2d");if(l==null)throw new Error("Can not access image data");{let u=i.height,g=i.width;if(o!==void 0&&o.resizedHeight!==void 0&&o.resizedWidth!==void 0&&(u=o.resizedHeight,g=o.resizedWidth),o!==void 0){if(s=o,o.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");s.tensorFormat="RGBA",s.height=u,s.width=g}else s.tensorFormat="RGBA",s.height=u,s.width=g;l.drawImage(i,0,0),p=l.getImageData(0,0,g,u).data}}else{if(!d){if(f){if(o===void 0)throw new Error("Please provide image config with format for Imagebitmap");const t=document.createElement("canvas");t.width=i.width,t.height=i.height;const l=t.getContext("2d");if(l!=null){const u=i.height,g=i.width;return l.drawImage(i,0,0,g,u),p=l.getImageData(0,0,g,u).data,s.height=u,s.width=g,(0,e.bufferToTensor)(p,s)}throw new Error("Can not access image data")}if(h)return new Promise((t,l)=>{const u=document.createElement("canvas"),g=u.getContext("2d");if(!i||!g)return l();const m=new Image;m.crossOrigin="Anonymous",m.src=i,m.onload=()=>{u.width=m.width,u.height=m.height,g.drawImage(m,0,0,u.width,u.height);const _=g.getImageData(0,0,u.width,u.height);s.height=u.height,s.width=u.width,t((0,e.bufferToTensor)(_.data,s))}});throw new Error("Input data provided is not supported - aborted tensor creation")}{let t,l;if(o!==void 0&&o.resizedWidth!==void 0&&o.resizedHeight!==void 0?(t=o.resizedHeight,l=o.resizedWidth):(t=i.height,l=i.width),o!==void 0&&(s=o),s.format="RGBA",s.height=t,s.width=l,o!==void 0){const u=document.createElement("canvas");u.width=l,u.height=t;const g=u.getContext("2d");if(g==null)throw new Error("Can not access image data");g.putImageData(i,0,0),p=g.getImageData(0,0,l,t).data}else p=i.data}}if(p!==void 0)return(0,e.bufferToTensor)(p,s);throw new Error("Input data provided is not supported - aborted tensor creation")}},5957:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Tensor=void 0;const r=n(2350),i=n(4866),o=n(106),a=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["float16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),d=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]);let f=!1;e.Tensor=class{constructor(h,p,s){let t,l,u;if((()=>{if(!f){f=!0;const m=typeof BigInt64Array<"u"&&typeof BigInt64Array.from=="function",_=typeof BigUint64Array<"u"&&typeof BigUint64Array.from=="function";m&&(a.set("int64",BigInt64Array),d.set(BigInt64Array,"int64")),_&&(a.set("uint64",BigUint64Array),d.set(BigUint64Array,"uint64"))}})(),typeof h=="string")if(t=h,u=s,h==="string"){if(!Array.isArray(p))throw new TypeError("A string tensor's data must be a string array.");l=p}else{const m=a.get(h);if(m===void 0)throw new TypeError(`Unsupported tensor type: ${h}.`);if(Array.isArray(p)){if(h==="float16")throw new TypeError("Creating a float16 tensor from number array is not supported. Please use Uint16Array as data.");l=h==="uint64"||h==="int64"?m.from(p,BigInt):m.from(p)}else{if(!(p instanceof m))throw new TypeError(`A ${t} tensor's data must be type of ${m}`);l=p}}else if(u=p,Array.isArray(h)){if(h.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");const m=typeof h[0];if(m==="string")t="string",l=h;else{if(m!=="boolean")throw new TypeError(`Invalid element type of data array: ${m}.`);t="bool",l=Uint8Array.from(h)}}else{const m=d.get(h.constructor);if(m===void 0)throw new TypeError(`Unsupported type for tensor data: ${h.constructor}.`);t=m,l=h}if(u===void 0)u=[l.length];else if(!Array.isArray(u))throw new TypeError("A tensor's dims must be a number array");const g=(0,o.calculateSize)(u);if(g!==l.length)throw new Error(`Tensor's size(${g}) does not match data length(${l.length}).`);this.dims=u,this.type=t,this.data=l,this.size=g}static async fromImage(h,p){return(0,i.tensorFromImage)(h,p)}toDataURL(h){return(0,r.tensorToDataURL)(this,h)}toImageData(h){return(0,r.tensorToImageData)(this,h)}reshape(h){return(0,o.tensorReshape)(this,h)}}},106:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tensorReshape=e.calculateSize=void 0;const r=n(963);e.calculateSize=i=>{let o=1;for(let a=0;a<i.length;a++){const d=i[a];if(typeof d!="number"||!Number.isSafeInteger(d))throw new TypeError(`dims[${a}] must be an integer, got: ${d}`);if(d<0)throw new RangeError(`dims[${a}] must be a non-negative integer, got: ${d}`);o*=d}return o},e.tensorReshape=(i,o)=>new r.Tensor(i.type,i.data,o)},963:(c,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Tensor=void 0;const r=n(5957);e.Tensor=r.Tensor},9104:(c,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.version=void 0,e.version="1.16.3"},1583:(c,e)=>{var n,r=function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var o=null;try{o=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function a(k,A,R){this.low=0|k,this.high=0|A,this.unsigned=!!R}function d(k){return(k&&k.__isLong__)===!0}function f(k){var A=Math.clz32(k&-k);return k?31-A:A}a.prototype.__isLong__,Object.defineProperty(a.prototype,"__isLong__",{value:!0}),a.isLong=d;var h={},p={};function s(k,A){var R,K,Z;return A?(Z=0<=(k>>>=0)&&k<256)&&(K=p[k])?K:(R=l(k,0,!0),Z&&(p[k]=R),R):(Z=-128<=(k|=0)&&k<128)&&(K=h[k])?K:(R=l(k,k<0?-1:0,!1),Z&&(h[k]=R),R)}function t(k,A){if(isNaN(k))return A?w:T;if(A){if(k<0)return w;if(k>=b)return N}else{if(k<=-y)return L;if(k+1>=y)return I}return k<0?t(-k,A).neg():l(k%_|0,k/_|0,A)}function l(k,A,R){return new a(k,A,R)}a.fromInt=s,a.fromNumber=t,a.fromBits=l;var u=Math.pow;function g(k,A,R){if(k.length===0)throw Error("empty string");if(typeof A=="number"?(R=A,A=!1):A=!!A,k==="NaN"||k==="Infinity"||k==="+Infinity"||k==="-Infinity")return A?w:T;if((R=R||10)<2||36<R)throw RangeError("radix");var K;if((K=k.indexOf("-"))>0)throw Error("interior hyphen");if(K===0)return g(k.substring(1),A,R).neg();for(var Z=t(u(R,8)),J=T,X=0;X<k.length;X+=8){var te=Math.min(8,k.length-X),oe=parseInt(k.substring(X,X+te),R);if(te<8){var ae=t(u(R,te));J=J.mul(ae).add(t(oe))}else J=(J=J.mul(Z)).add(t(oe))}return J.unsigned=A,J}function m(k,A){return typeof k=="number"?t(k,A):typeof k=="string"?g(k,A):l(k.low,k.high,typeof A=="boolean"?A:k.unsigned)}a.fromString=g,a.fromValue=m;var _=4294967296,b=_*_,y=b/2,v=s(1<<24),T=s(0);a.ZERO=T;var w=s(0,!0);a.UZERO=w;var S=s(1);a.ONE=S;var x=s(1,!0);a.UONE=x;var P=s(-1);a.NEG_ONE=P;var I=l(-1,2147483647,!1);a.MAX_VALUE=I;var N=l(-1,-1,!0);a.MAX_UNSIGNED_VALUE=N;var L=l(0,-2147483648,!1);a.MIN_VALUE=L;var E=a.prototype;E.toInt=function(){return this.unsigned?this.low>>>0:this.low},E.toNumber=function(){return this.unsigned?(this.high>>>0)*_+(this.low>>>0):this.high*_+(this.low>>>0)},E.toString=function(k){if((k=k||10)<2||36<k)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(L)){var A=t(k),R=this.div(A),K=R.mul(A).sub(this);return R.toString(k)+K.toInt().toString(k)}return"-"+this.neg().toString(k)}for(var Z=t(u(k,6),this.unsigned),J=this,X="";;){var te=J.div(Z),oe=(J.sub(te.mul(Z)).toInt()>>>0).toString(k);if((J=te).isZero())return oe+X;for(;oe.length<6;)oe="0"+oe;X=""+oe+X}},E.getHighBits=function(){return this.high},E.getHighBitsUnsigned=function(){return this.high>>>0},E.getLowBits=function(){return this.low},E.getLowBitsUnsigned=function(){return this.low>>>0},E.getNumBitsAbs=function(){if(this.isNegative())return this.eq(L)?64:this.neg().getNumBitsAbs();for(var k=this.high!=0?this.high:this.low,A=31;A>0&&!(k&1<<A);A--);return this.high!=0?A+33:A+1},E.isZero=function(){return this.high===0&&this.low===0},E.eqz=E.isZero,E.isNegative=function(){return!this.unsigned&&this.high<0},E.isPositive=function(){return this.unsigned||this.high>=0},E.isOdd=function(){return(1&this.low)==1},E.isEven=function(){return(1&this.low)==0},E.equals=function(k){return d(k)||(k=m(k)),(this.unsigned===k.unsigned||this.high>>>31!=1||k.high>>>31!=1)&&this.high===k.high&&this.low===k.low},E.eq=E.equals,E.notEquals=function(k){return!this.eq(k)},E.neq=E.notEquals,E.ne=E.notEquals,E.lessThan=function(k){return this.comp(k)<0},E.lt=E.lessThan,E.lessThanOrEqual=function(k){return this.comp(k)<=0},E.lte=E.lessThanOrEqual,E.le=E.lessThanOrEqual,E.greaterThan=function(k){return this.comp(k)>0},E.gt=E.greaterThan,E.greaterThanOrEqual=function(k){return this.comp(k)>=0},E.gte=E.greaterThanOrEqual,E.ge=E.greaterThanOrEqual,E.compare=function(k){if(d(k)||(k=m(k)),this.eq(k))return 0;var A=this.isNegative(),R=k.isNegative();return A&&!R?-1:!A&&R?1:this.unsigned?k.high>>>0>this.high>>>0||k.high===this.high&&k.low>>>0>this.low>>>0?-1:1:this.sub(k).isNegative()?-1:1},E.comp=E.compare,E.negate=function(){return!this.unsigned&&this.eq(L)?L:this.not().add(S)},E.neg=E.negate,E.add=function(k){d(k)||(k=m(k));var A=this.high>>>16,R=65535&this.high,K=this.low>>>16,Z=65535&this.low,J=k.high>>>16,X=65535&k.high,te=k.low>>>16,oe=0,ae=0,ce=0,fe=0;return ce+=(fe+=Z+(65535&k.low))>>>16,ae+=(ce+=K+te)>>>16,oe+=(ae+=R+X)>>>16,oe+=A+J,l((ce&=65535)<<16|(fe&=65535),(oe&=65535)<<16|(ae&=65535),this.unsigned)},E.subtract=function(k){return d(k)||(k=m(k)),this.add(k.neg())},E.sub=E.subtract,E.multiply=function(k){if(this.isZero())return this;if(d(k)||(k=m(k)),o)return l(o.mul(this.low,this.high,k.low,k.high),o.get_high(),this.unsigned);if(k.isZero())return this.unsigned?w:T;if(this.eq(L))return k.isOdd()?L:T;if(k.eq(L))return this.isOdd()?L:T;if(this.isNegative())return k.isNegative()?this.neg().mul(k.neg()):this.neg().mul(k).neg();if(k.isNegative())return this.mul(k.neg()).neg();if(this.lt(v)&&k.lt(v))return t(this.toNumber()*k.toNumber(),this.unsigned);var A=this.high>>>16,R=65535&this.high,K=this.low>>>16,Z=65535&this.low,J=k.high>>>16,X=65535&k.high,te=k.low>>>16,oe=65535&k.low,ae=0,ce=0,fe=0,he=0;return fe+=(he+=Z*oe)>>>16,ce+=(fe+=K*oe)>>>16,fe&=65535,ce+=(fe+=Z*te)>>>16,ae+=(ce+=R*oe)>>>16,ce&=65535,ae+=(ce+=K*te)>>>16,ce&=65535,ae+=(ce+=Z*X)>>>16,ae+=A*oe+R*te+K*X+Z*J,l((fe&=65535)<<16|(he&=65535),(ae&=65535)<<16|(ce&=65535),this.unsigned)},E.mul=E.multiply,E.divide=function(k){if(d(k)||(k=m(k)),k.isZero())throw Error("division by zero");var A,R,K;if(o)return this.unsigned||this.high!==-2147483648||k.low!==-1||k.high!==-1?l((this.unsigned?o.div_u:o.div_s)(this.low,this.high,k.low,k.high),o.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?w:T;if(this.unsigned){if(k.unsigned||(k=k.toUnsigned()),k.gt(this))return w;if(k.gt(this.shru(1)))return x;K=w}else{if(this.eq(L))return k.eq(S)||k.eq(P)?L:k.eq(L)?S:(A=this.shr(1).div(k).shl(1)).eq(T)?k.isNegative()?S:P:(R=this.sub(k.mul(A)),K=A.add(R.div(k)));if(k.eq(L))return this.unsigned?w:T;if(this.isNegative())return k.isNegative()?this.neg().div(k.neg()):this.neg().div(k).neg();if(k.isNegative())return this.div(k.neg()).neg();K=T}for(R=this;R.gte(k);){A=Math.max(1,Math.floor(R.toNumber()/k.toNumber()));for(var Z=Math.ceil(Math.log(A)/Math.LN2),J=Z<=48?1:u(2,Z-48),X=t(A),te=X.mul(k);te.isNegative()||te.gt(R);)te=(X=t(A-=J,this.unsigned)).mul(k);X.isZero()&&(X=S),K=K.add(X),R=R.sub(te)}return K},E.div=E.divide,E.modulo=function(k){return d(k)||(k=m(k)),o?l((this.unsigned?o.rem_u:o.rem_s)(this.low,this.high,k.low,k.high),o.get_high(),this.unsigned):this.sub(this.div(k).mul(k))},E.mod=E.modulo,E.rem=E.modulo,E.not=function(){return l(~this.low,~this.high,this.unsigned)},E.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},E.clz=E.countLeadingZeros,E.countTrailingZeros=function(){return this.low?f(this.low):f(this.high)+32},E.ctz=E.countTrailingZeros,E.and=function(k){return d(k)||(k=m(k)),l(this.low&k.low,this.high&k.high,this.unsigned)},E.or=function(k){return d(k)||(k=m(k)),l(this.low|k.low,this.high|k.high,this.unsigned)},E.xor=function(k){return d(k)||(k=m(k)),l(this.low^k.low,this.high^k.high,this.unsigned)},E.shiftLeft=function(k){return d(k)&&(k=k.toInt()),(k&=63)==0?this:k<32?l(this.low<<k,this.high<<k|this.low>>>32-k,this.unsigned):l(0,this.low<<k-32,this.unsigned)},E.shl=E.shiftLeft,E.shiftRight=function(k){return d(k)&&(k=k.toInt()),(k&=63)==0?this:k<32?l(this.low>>>k|this.high<<32-k,this.high>>k,this.unsigned):l(this.high>>k-32,this.high>=0?0:-1,this.unsigned)},E.shr=E.shiftRight,E.shiftRightUnsigned=function(k){return d(k)&&(k=k.toInt()),(k&=63)==0?this:k<32?l(this.low>>>k|this.high<<32-k,this.high>>>k,this.unsigned):l(k===32?this.high:this.high>>>k-32,0,this.unsigned)},E.shru=E.shiftRightUnsigned,E.shr_u=E.shiftRightUnsigned,E.rotateLeft=function(k){var A;return d(k)&&(k=k.toInt()),(k&=63)==0?this:k===32?l(this.high,this.low,this.unsigned):k<32?(A=32-k,l(this.low<<k|this.high>>>A,this.high<<k|this.low>>>A,this.unsigned)):(A=32-(k-=32),l(this.high<<k|this.low>>>A,this.low<<k|this.high>>>A,this.unsigned))},E.rotl=E.rotateLeft,E.rotateRight=function(k){var A;return d(k)&&(k=k.toInt()),(k&=63)==0?this:k===32?l(this.high,this.low,this.unsigned):k<32?(A=32-k,l(this.high<<A|this.low>>>k,this.low<<A|this.high>>>k,this.unsigned)):(A=32-(k-=32),l(this.low<<A|this.high>>>k,this.high<<A|this.low>>>k,this.unsigned))},E.rotr=E.rotateRight,E.toSigned=function(){return this.unsigned?l(this.low,this.high,!1):this},E.toUnsigned=function(){return this.unsigned?this:l(this.low,this.high,!0)},E.toBytes=function(k){return k?this.toBytesLE():this.toBytesBE()},E.toBytesLE=function(){var k=this.high,A=this.low;return[255&A,A>>>8&255,A>>>16&255,A>>>24,255&k,k>>>8&255,k>>>16&255,k>>>24]},E.toBytesBE=function(){var k=this.high,A=this.low;return[k>>>24,k>>>16&255,k>>>8&255,255&k,A>>>24,A>>>16&255,A>>>8&255,255&A]},a.fromBytes=function(k,A,R){return R?a.fromBytesLE(k,A):a.fromBytesBE(k,A)},a.fromBytesLE=function(k,A){return new a(k[0]|k[1]<<8|k[2]<<16|k[3]<<24,k[4]|k[5]<<8|k[6]<<16|k[7]<<24,A)},a.fromBytesBE=function(k,A){return new a(k[4]<<24|k[5]<<16|k[6]<<8|k[7],k[0]<<24|k[1]<<16|k[2]<<8|k[3],A)};var M=a;return i.default=M,"default"in i?i.default:i}({});(n=(function(){return r}).apply(e,[]))===void 0||(c.exports=n)},5686:(c,e,n)=>{n.r(e),n.d(e,{flatbuffers:()=>r});var r={};r.Offset,r.Table,r.SIZEOF_SHORT=2,r.SIZEOF_INT=4,r.FILE_IDENTIFIER_LENGTH=4,r.SIZE_PREFIX_LENGTH=4,r.Encoding={UTF8_BYTES:1,UTF16_STRING:2},r.int32=new Int32Array(2),r.float32=new Float32Array(r.int32.buffer),r.float64=new Float64Array(r.int32.buffer),r.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,r.Long=function(i,o){this.low=0|i,this.high=0|o},r.Long.create=function(i,o){return i==0&&o==0?r.Long.ZERO:new r.Long(i,o)},r.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},r.Long.prototype.equals=function(i){return this.low==i.low&&this.high==i.high},r.Long.ZERO=new r.Long(0,0),r.Builder=function(i){if(i)o=i;else var o=1024;this.bb=r.ByteBuffer.allocate(o),this.space=o,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},r.Builder.prototype.clear=function(){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},r.Builder.prototype.forceDefaults=function(i){this.force_defaults=i},r.Builder.prototype.dataBuffer=function(){return this.bb},r.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},r.Builder.prototype.prep=function(i,o){i>this.minalign&&(this.minalign=i);for(var a=1+~(this.bb.capacity()-this.space+o)&i-1;this.space<a+i+o;){var d=this.bb.capacity();this.bb=r.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-d}this.pad(a)},r.Builder.prototype.pad=function(i){for(var o=0;o<i;o++)this.bb.writeInt8(--this.space,0)},r.Builder.prototype.writeInt8=function(i){this.bb.writeInt8(this.space-=1,i)},r.Builder.prototype.writeInt16=function(i){this.bb.writeInt16(this.space-=2,i)},r.Builder.prototype.writeInt32=function(i){this.bb.writeInt32(this.space-=4,i)},r.Builder.prototype.writeInt64=function(i){this.bb.writeInt64(this.space-=8,i)},r.Builder.prototype.writeFloat32=function(i){this.bb.writeFloat32(this.space-=4,i)},r.Builder.prototype.writeFloat64=function(i){this.bb.writeFloat64(this.space-=8,i)},r.Builder.prototype.addInt8=function(i){this.prep(1,0),this.writeInt8(i)},r.Builder.prototype.addInt16=function(i){this.prep(2,0),this.writeInt16(i)},r.Builder.prototype.addInt32=function(i){this.prep(4,0),this.writeInt32(i)},r.Builder.prototype.addInt64=function(i){this.prep(8,0),this.writeInt64(i)},r.Builder.prototype.addFloat32=function(i){this.prep(4,0),this.writeFloat32(i)},r.Builder.prototype.addFloat64=function(i){this.prep(8,0),this.writeFloat64(i)},r.Builder.prototype.addFieldInt8=function(i,o,a){(this.force_defaults||o!=a)&&(this.addInt8(o),this.slot(i))},r.Builder.prototype.addFieldInt16=function(i,o,a){(this.force_defaults||o!=a)&&(this.addInt16(o),this.slot(i))},r.Builder.prototype.addFieldInt32=function(i,o,a){(this.force_defaults||o!=a)&&(this.addInt32(o),this.slot(i))},r.Builder.prototype.addFieldInt64=function(i,o,a){!this.force_defaults&&o.equals(a)||(this.addInt64(o),this.slot(i))},r.Builder.prototype.addFieldFloat32=function(i,o,a){(this.force_defaults||o!=a)&&(this.addFloat32(o),this.slot(i))},r.Builder.prototype.addFieldFloat64=function(i,o,a){(this.force_defaults||o!=a)&&(this.addFloat64(o),this.slot(i))},r.Builder.prototype.addFieldOffset=function(i,o,a){(this.force_defaults||o!=a)&&(this.addOffset(o),this.slot(i))},r.Builder.prototype.addFieldStruct=function(i,o,a){o!=a&&(this.nested(o),this.slot(i))},r.Builder.prototype.nested=function(i){if(i!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},r.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},r.Builder.prototype.slot=function(i){this.vtable[i]=this.offset()},r.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},r.Builder.growByteBuffer=function(i){var o=i.capacity();if(3221225472&o)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var a=o<<1,d=r.ByteBuffer.allocate(a);return d.setPosition(a-o),d.bytes().set(i.bytes(),a-o),d},r.Builder.prototype.addOffset=function(i){this.prep(r.SIZEOF_INT,0),this.writeInt32(this.offset()-i+r.SIZEOF_INT)},r.Builder.prototype.startObject=function(i){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=i;for(var o=0;o<i;o++)this.vtable[o]=0;this.isNested=!0,this.object_start=this.offset()},r.Builder.prototype.endObject=function(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var i=this.offset(),o=this.vtable_in_use-1;o>=0&&this.vtable[o]==0;o--);for(var a=o+1;o>=0;o--)this.addInt16(this.vtable[o]!=0?i-this.vtable[o]:0);this.addInt16(i-this.object_start);var d=(a+2)*r.SIZEOF_SHORT;this.addInt16(d);var f=0,h=this.space;e:for(o=0;o<this.vtables.length;o++){var p=this.bb.capacity()-this.vtables[o];if(d==this.bb.readInt16(p)){for(var s=r.SIZEOF_SHORT;s<d;s+=r.SIZEOF_SHORT)if(this.bb.readInt16(h+s)!=this.bb.readInt16(p+s))continue e;f=this.vtables[o];break}}return f?(this.space=this.bb.capacity()-i,this.bb.writeInt32(this.space,f-i)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-i,this.offset()-i)),this.isNested=!1,i},r.Builder.prototype.finish=function(i,o,a){var d=a?r.SIZE_PREFIX_LENGTH:0;if(o){var f=o;if(this.prep(this.minalign,r.SIZEOF_INT+r.FILE_IDENTIFIER_LENGTH+d),f.length!=r.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+r.FILE_IDENTIFIER_LENGTH);for(var h=r.FILE_IDENTIFIER_LENGTH-1;h>=0;h--)this.writeInt8(f.charCodeAt(h))}this.prep(this.minalign,r.SIZEOF_INT+d),this.addOffset(i),d&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},r.Builder.prototype.finishSizePrefixed=function(i,o){this.finish(i,o,!0)},r.Builder.prototype.requiredField=function(i,o){var a=this.bb.capacity()-i,d=a-this.bb.readInt32(a);if(this.bb.readInt16(d+o)==0)throw new Error("FlatBuffers: field "+o+" must be set")},r.Builder.prototype.startVector=function(i,o,a){this.notNested(),this.vector_num_elems=o,this.prep(r.SIZEOF_INT,i*o),this.prep(a,i*o)},r.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},r.Builder.prototype.createString=function(i){if(i instanceof Uint8Array)var o=i;else{o=[];for(var a=0;a<i.length;){var d,f=i.charCodeAt(a++);(d=f<55296||f>=56320?f:(f<<10)+i.charCodeAt(a++)+-56613888)<128?o.push(d):(d<2048?o.push(d>>6&31|192):(d<65536?o.push(d>>12&15|224):o.push(d>>18&7|240,d>>12&63|128),o.push(d>>6&63|128)),o.push(63&d|128))}}this.addInt8(0),this.startVector(1,o.length,1),this.bb.setPosition(this.space-=o.length),a=0;for(var h=this.space,p=this.bb.bytes();a<o.length;a++)p[h++]=o[a];return this.endVector()},r.Builder.prototype.createLong=function(i,o){return r.Long.create(i,o)},r.ByteBuffer=function(i){this.bytes_=i,this.position_=0},r.ByteBuffer.allocate=function(i){return new r.ByteBuffer(new Uint8Array(i))},r.ByteBuffer.prototype.clear=function(){this.position_=0},r.ByteBuffer.prototype.bytes=function(){return this.bytes_},r.ByteBuffer.prototype.position=function(){return this.position_},r.ByteBuffer.prototype.setPosition=function(i){this.position_=i},r.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},r.ByteBuffer.prototype.readInt8=function(i){return this.readUint8(i)<<24>>24},r.ByteBuffer.prototype.readUint8=function(i){return this.bytes_[i]},r.ByteBuffer.prototype.readInt16=function(i){return this.readUint16(i)<<16>>16},r.ByteBuffer.prototype.readUint16=function(i){return this.bytes_[i]|this.bytes_[i+1]<<8},r.ByteBuffer.prototype.readInt32=function(i){return this.bytes_[i]|this.bytes_[i+1]<<8|this.bytes_[i+2]<<16|this.bytes_[i+3]<<24},r.ByteBuffer.prototype.readUint32=function(i){return this.readInt32(i)>>>0},r.ByteBuffer.prototype.readInt64=function(i){return new r.Long(this.readInt32(i),this.readInt32(i+4))},r.ByteBuffer.prototype.readUint64=function(i){return new r.Long(this.readUint32(i),this.readUint32(i+4))},r.ByteBuffer.prototype.readFloat32=function(i){return r.int32[0]=this.readInt32(i),r.float32[0]},r.ByteBuffer.prototype.readFloat64=function(i){return r.int32[r.isLittleEndian?0:1]=this.readInt32(i),r.int32[r.isLittleEndian?1:0]=this.readInt32(i+4),r.float64[0]},r.ByteBuffer.prototype.writeInt8=function(i,o){this.bytes_[i]=o},r.ByteBuffer.prototype.writeUint8=function(i,o){this.bytes_[i]=o},r.ByteBuffer.prototype.writeInt16=function(i,o){this.bytes_[i]=o,this.bytes_[i+1]=o>>8},r.ByteBuffer.prototype.writeUint16=function(i,o){this.bytes_[i]=o,this.bytes_[i+1]=o>>8},r.ByteBuffer.prototype.writeInt32=function(i,o){this.bytes_[i]=o,this.bytes_[i+1]=o>>8,this.bytes_[i+2]=o>>16,this.bytes_[i+3]=o>>24},r.ByteBuffer.prototype.writeUint32=function(i,o){this.bytes_[i]=o,this.bytes_[i+1]=o>>8,this.bytes_[i+2]=o>>16,this.bytes_[i+3]=o>>24},r.ByteBuffer.prototype.writeInt64=function(i,o){this.writeInt32(i,o.low),this.writeInt32(i+4,o.high)},r.ByteBuffer.prototype.writeUint64=function(i,o){this.writeUint32(i,o.low),this.writeUint32(i+4,o.high)},r.ByteBuffer.prototype.writeFloat32=function(i,o){r.float32[0]=o,this.writeInt32(i,r.int32[0])},r.ByteBuffer.prototype.writeFloat64=function(i,o){r.float64[0]=o,this.writeInt32(i,r.int32[r.isLittleEndian?0:1]),this.writeInt32(i+4,r.int32[r.isLittleEndian?1:0])},r.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+r.SIZEOF_INT+r.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var i="",o=0;o<r.FILE_IDENTIFIER_LENGTH;o++)i+=String.fromCharCode(this.readInt8(this.position_+r.SIZEOF_INT+o));return i},r.ByteBuffer.prototype.__offset=function(i,o){var a=i-this.readInt32(i);return o<this.readInt16(a)?this.readInt16(a+o):0},r.ByteBuffer.prototype.__union=function(i,o){return i.bb_pos=o+this.readInt32(o),i.bb=this,i},r.ByteBuffer.prototype.__string=function(i,o){i+=this.readInt32(i);var a=this.readInt32(i),d="",f=0;if(i+=r.SIZEOF_INT,o===r.Encoding.UTF8_BYTES)return this.bytes_.subarray(i,i+a);for(;f<a;){var h,p=this.readUint8(i+f++);if(p<192)h=p;else{var s=this.readUint8(i+f++);if(p<224)h=(31&p)<<6|63&s;else{var t=this.readUint8(i+f++);h=p<240?(15&p)<<12|(63&s)<<6|63&t:(7&p)<<18|(63&s)<<12|(63&t)<<6|63&this.readUint8(i+f++)}}h<65536?d+=String.fromCharCode(h):(h-=65536,d+=String.fromCharCode(55296+(h>>10),56320+(1023&h)))}return d},r.ByteBuffer.prototype.__indirect=function(i){return i+this.readInt32(i)},r.ByteBuffer.prototype.__vector=function(i){return i+this.readInt32(i)+r.SIZEOF_INT},r.ByteBuffer.prototype.__vector_len=function(i){return this.readInt32(i+this.readInt32(i))},r.ByteBuffer.prototype.__has_identifier=function(i){if(i.length!=r.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+r.FILE_IDENTIFIER_LENGTH);for(var o=0;o<r.FILE_IDENTIFIER_LENGTH;o++)if(i.charCodeAt(o)!=this.readInt8(this.position_+r.SIZEOF_INT+o))return!1;return!0},r.ByteBuffer.prototype.createLong=function(i,o){return r.Long.create(i,o)}}},__webpack_module_cache__={};function __webpack_require__(c){var e=__webpack_module_cache__[c];if(e!==void 0)return e.exports;var n=__webpack_module_cache__[c]={exports:{}};return __webpack_modules__[c].call(n.exports,n,n.exports,__webpack_require__),n.exports}__webpack_require__.n=c=>{var e=c&&c.__esModule?()=>c.default:()=>c;return __webpack_require__.d(e,{a:e}),e},__webpack_require__.d=(c,e)=>{for(var n in e)__webpack_require__.o(e,n)&&!__webpack_require__.o(c,n)&&Object.defineProperty(c,n,{enumerable:!0,get:e[n]})},__webpack_require__.o=(c,e)=>Object.prototype.hasOwnProperty.call(c,e),__webpack_require__.r=c=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(c,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(1057);return __webpack_exports__})())})(ort_min);var ort_minExports=ort_min.exports;/**
 * @copyright CEA
 * @author CEA
 * @license CECILL
 *
 * This software is a collaborative computer program whose purpose is to
 * generate and explore labeled data for computer vision applications.
 * This software is governed by the CeCILL-C license under French law and
 * abiding by the rules of distribution of free software. You can use,
 * modify and/ or redistribute the software under the terms of the CeCILL-C
 * license as circulated by CEA, CNRS and INRIA at the following URL
 *
 * http://www.cecill.info
 */ort_minExports.env.wasm.wasmPaths="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.16.1/dist/";class SAM{constructor(){rt(this,"onnxModel");rt(this,"previousMask",null);rt(this,"imageLongSideLength",1024);rt(this,"predictionThreshold",0)}async init(e){this.onnxModel=await ort_minExports.InferenceSession.create(e)}getScalingFactor(e,n){return this.imageLongSideLength/Math.max(e,n)}getPreviousMask(){let e,n;return this.previousMask?(e=this.previousMask,n=new ort_minExports.Tensor("float32",[1])):(e=new ort_minExports.Tensor("float32",new Float32Array(256*256),[1,1,256,256]),n=new ort_minExports.Tensor("float32",[0])),[e,n]}preProcessInputs(e,n,r,i){const o=this.getScalingFactor(r,i),a=e==null?void 0:e.length,d=n?2:1,f=new Float32Array(2*(a+d)),h=new Float32Array(a+d);for(let t=0;t<a;t++)f[2*t]=e[t].x*o,f[2*t+1]=e[t].y*o,h[t]=e[t].label;n?(f[2*a]=Math.min(n.x,n.x+n.width)*o,f[2*a+1]=Math.min(n.y,n.y+n.height)*o,h[a]=2,f[2*a+2]=Math.max(n.x,n.x+n.width)*o,f[2*a+3]=Math.max(n.y,n.y+n.height)*o,h[a+1]=3):(f[2*a]=0,f[2*a+1]=0,h[a]=-1);const p=new ort_minExports.Tensor("float32",f,[1,a+d,2]),s=new ort_minExports.Tensor("float32",h,[1,a+d]);return{points:p,labels:s}}async segmentImage(e){const n=e.image.naturalWidth,r=e.image.naturalHeight,i=new ort_minExports.Tensor("float32",[r,n]),o=this.preProcessInputs(e.points,e.box,n,r),a=this.getPreviousMask(),d={image_embeddings:e.embedding,point_coords:o.points,point_labels:o.labels,orig_im_size:i,mask_input:a[0],has_mask_input:a[1]},f=Date.now(),h=await this.onnxModel.run(d);console.log("SAM.segmentImage in",Date.now()-f,"ms"),this.previousMask=h.low_res_masks;const p=maskDataToFortranArrayToRle(h.masks.data,r,n),s=generatePolygonSegments(p,r);return{masksImageSVG:convertSegmentsToSVG(s),rle:{counts:p,size:[r,n]},masks:h.mask}}inputNames(){return this.onnxModel.inputNames}outputNames(){return this.onnxModel.outputNames}reset(){this.previousMask=null}}const GROUND_TRUTH="Ground Truth",MODEL_RUN="Model Run",DEFAULT_FEATURE="category",defaultObjectFeatures={[DEFAULT_FEATURE]:{name:"category",dtype:"str",label:"category"}},defaultSceneFeatures={label:{name:"label",dtype:"str",value:"None"}},defineTooltip=c=>{var r,i;if(!c.bbox)return null;const e=c.bbox.confidence!=0&&c.source_id!==GROUND_TRUTH?" "+c.bbox.confidence.toFixed(2):"";return typeof((r=c.features[DEFAULT_FEATURE])==null?void 0:r.value)=="string"?((i=c.features[DEFAULT_FEATURE])==null?void 0:i.value)+e:null},mapObjectToBBox=(c,e)=>{var h,p,s,t,l,u;if(!c.bbox)return;const n=((h=e==null?void 0:e[c.view_id])==null?void 0:h.features.height.value)||1,r=((p=e==null?void 0:e[c.view_id])==null?void 0:p.features.width.value)||1,i=c.bbox.coords[0]*r,o=c.bbox.coords[1]*n,a=c.bbox.coords[2]*r,d=c.bbox.coords[3]*n,f=defineTooltip(c);return{id:c.id,viewId:c.view_id,catId:((s=c.features.category_id)==null?void 0:s.value)||1,bbox:[i,o,a,d],tooltip:f,opacity:1,visible:!((t=c.bbox.displayControl)!=null&&t.hidden),editing:(l=c.displayControl)==null?void 0:l.editing,locked:(u=c.displayControl)==null?void 0:u.locked}},mapObjectToMasks=c=>{var o,a,d;if(!c.mask)return;const e=c.mask.counts,n=c.mask.size,r=generatePolygonSegments(e,n[0]),i=convertSegmentsToSVG(r);return{id:c.id,viewId:c.view_id,svg:i,rle:c.mask,catId:((o=c.features.category_id)==null?void 0:o.value)||1,visible:!((a=c.mask.displayControl)!=null&&a.hidden),editing:(d=c.displayControl)==null?void 0:d.editing,opacity:1,isManual:!!c.isManual}},toggleObjectDisplayControl=(c,e,n,r)=>(n.includes("bbox")&&c.bbox&&(c.bbox.displayControl={...c.bbox.displayControl,[e]:r}),n.includes("mask")&&c.mask&&(c.mask.displayControl={...c.mask.displayControl,[e]:r}),n.includes("bbox")&&n.includes("mask")&&(c.displayControl={...c.displayControl,[e]:r}),c),sortObjectsByModel=c=>c.reduce((e,n)=>{if(n.source_id===GROUND_TRUTH)e[GROUND_TRUTH]=[n,...e[GROUND_TRUTH]];else{const r=e[MODEL_RUN].some(i=>i.modelName===n.source_id);r||(e[MODEL_RUN]=[...e[MODEL_RUN],{modelName:n.source_id,objects:[n]}]),r&&(e[MODEL_RUN]=e[MODEL_RUN].map(i=>i.modelName===n.source_id?{...i,objects:[...i.objects,n]}:i))}return e},{[GROUND_TRUTH]:[],[MODEL_RUN]:[]}),updateExistingObject=(c,e)=>c.map(n=>(e==null?void 0:e.status)!=="editing"?n:e.type==="mask"&&n.id===e.maskId&&n.mask?{...n,mask:{...n.mask,counts:e.counts}}:e.type==="rectangle"&&n.id===e.rectangleId&&n.bbox?{...n,bbox:{...n.bbox,coords:e.coords}}:n);/**
 * @copyright CEA
 * @author CEA
 * @license CECILL
 *
 * This software is a collaborative computer program whose purpose is to
 * generate and explore labeled data for computer vision applications.
 * This software is governed by the CeCILL-C license under French law and
 * abiding by the rules of distribution of free software. You can use,
 * modify and/ or redistribute the software under the terms of the CeCILL-C
 * license as circulated by CEA, CNRS and INRIA at the following URL
 *
 * http://www.cecill.info
 */const newShape=writable(),itemObjects=writable([]),interactiveSegmenterModel=writable(),itemMetas=writable(),canSave=writable(!1),modelsStore=writable({currentModalOpen:"none",selectedModelName:""}),itemBboxes=derived([itemObjects,itemMetas],([c,e])=>c.reduce((n,r)=>{const i=mapObjectToBBox(r,e==null?void 0:e.views);return n=[...n,...i?[i]:[]],n},[])),itemMasks=derived(itemObjects,c=>c.reduce((e,n)=>{const r=mapObjectToMasks(n);return e=[...e,...r?[r]:[]],e},[]));function create_default_slot_5$1(c){let e,n;return e=new Mouse_pointer({}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_default_slot_4$2(c){let e,n;return e=new Square({}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_default_slot_3$2(c){let e,n;return e=new Share_2({}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_if_block$g(c){var d,f,h;let e,n,r,i,o,a;return e=new TooltipIconButton({props:{tooltipContent:c[2].name,selected:((d=c[0])==null?void 0:d.type)==="POINT_SELECTION"&&!!c[0].label,$$slots:{default:[create_default_slot_2$3]},$$scope:{ctx:c}}}),e.$on("click",c[12]),r=new TooltipIconButton({props:{tooltipContent:c[3].name,selected:((f=c[0])==null?void 0:f.type)==="POINT_SELECTION"&&!c[0].label,$$slots:{default:[create_default_slot_1$6]},$$scope:{ctx:c}}}),r.$on("click",c[13]),o=new TooltipIconButton({props:{tooltipContent:"Smart rectangle",selected:((h=c[0])==null?void 0:h.type)==="RECTANGLE"&&c[0].isSmart,$$slots:{default:[create_default_slot$9]},$$scope:{ctx:c}}}),o.$on("click",c[14]),{c(){create_component(e.$$.fragment),n=space(),create_component(r.$$.fragment),i=space(),create_component(o.$$.fragment)},l(p){claim_component(e.$$.fragment,p),n=claim_space(p),claim_component(r.$$.fragment,p),i=claim_space(p),claim_component(o.$$.fragment,p)},m(p,s){mount_component(e,p,s),insert_hydration(p,n,s),mount_component(r,p,s),insert_hydration(p,i,s),mount_component(o,p,s),a=!0},p(p,s){var g,m,_;const t={};s&4&&(t.tooltipContent=p[2].name),s&1&&(t.selected=((g=p[0])==null?void 0:g.type)==="POINT_SELECTION"&&!!p[0].label),s&32768&&(t.$$scope={dirty:s,ctx:p}),e.$set(t);const l={};s&8&&(l.tooltipContent=p[3].name),s&1&&(l.selected=((m=p[0])==null?void 0:m.type)==="POINT_SELECTION"&&!p[0].label),s&32768&&(l.$$scope={dirty:s,ctx:p}),r.$set(l);const u={};s&1&&(u.selected=((_=p[0])==null?void 0:_.type)==="RECTANGLE"&&p[0].isSmart),s&32768&&(u.$$scope={dirty:s,ctx:p}),o.$set(u)},i(p){a||(transition_in(e.$$.fragment,p),transition_in(r.$$.fragment,p),transition_in(o.$$.fragment,p),a=!0)},o(p){transition_out(e.$$.fragment,p),transition_out(r.$$.fragment,p),transition_out(o.$$.fragment,p),a=!1},d(p){p&&(detach(n),detach(i)),destroy_component(e,p),destroy_component(r,p),destroy_component(o,p)}}}function create_default_slot_2$3(c){let e,n,r,i;return e=new Plus_circle({}),r=new MagicIcon({}),{c(){create_component(e.$$.fragment),n=space(),create_component(r.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(r.$$.fragment,o)},m(o,a){mount_component(e,o,a),insert_hydration(o,n,a),mount_component(r,o,a),i=!0},i(o){i||(transition_in(e.$$.fragment,o),transition_in(r.$$.fragment,o),i=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(r.$$.fragment,o),i=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(r,o)}}}function create_default_slot_1$6(c){let e,n,r,i;return e=new Minus_circle({}),r=new MagicIcon({}),{c(){create_component(e.$$.fragment),n=space(),create_component(r.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(r.$$.fragment,o)},m(o,a){mount_component(e,o,a),insert_hydration(o,n,a),mount_component(r,o,a),i=!0},i(o){i||(transition_in(e.$$.fragment,o),transition_in(r.$$.fragment,o),i=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(r.$$.fragment,o),i=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(r,o)}}}function create_default_slot$9(c){let e,n,r,i;return e=new Square({}),r=new MagicIcon({}),{c(){create_component(e.$$.fragment),n=space(),create_component(r.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(r.$$.fragment,o)},m(o,a){mount_component(e,o,a),insert_hydration(o,n,a),mount_component(r,o,a),i=!0},i(o){i||(transition_in(e.$$.fragment,o),transition_in(r.$$.fragment,o),i=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(r.$$.fragment,o),i=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(r,o)}}}function create_fragment$i(c){var v,T,w;let e,n,r,i,o,a,d,f,h,p,s,t,l,u,g,m,_,b;r=new TooltipIconButton({props:{tooltipContent:"Move image around",selected:((v=c[0])==null?void 0:v.type)==="PAN",$$slots:{default:[create_default_slot_5$1]},$$scope:{ctx:c}}}),r.$on("click",c[8]),o=new TooltipIconButton({props:{selected:((T=c[0])==null?void 0:T.type)==="RECTANGLE"&&!c[0].isSmart,$$slots:{default:[create_default_slot_4$2]},$$scope:{ctx:c}}}),o.$on("click",c[9]),d=new TooltipIconButton({props:{tooltipContent:"Create a polygon",selected:((w=c[0])==null?void 0:w.type)==="POLYGON",$$slots:{default:[create_default_slot_3$2]},$$scope:{ctx:c}}}),d.$on("click",c[10]),s=new Brush({}),l=new MagicIcon({});let y=c[4]&&create_if_block$g(c);return{c(){e=element("div"),n=element("div"),create_component(r.$$.fragment),i=space(),create_component(o.$$.fragment),a=space(),create_component(d.$$.fragment),f=space(),h=element("div"),p=element("button"),create_component(s.$$.fragment),t=space(),create_component(l.$$.fragment),u=space(),y&&y.c(),this.h()},l(S){e=claim_element(S,"DIV",{class:!0});var x=children(e);n=claim_element(x,"DIV",{class:!0});var P=children(n);claim_component(r.$$.fragment,P),i=claim_space(P),claim_component(o.$$.fragment,P),a=claim_space(P),claim_component(d.$$.fragment,P),P.forEach(detach),f=claim_space(x),h=claim_element(x,"DIV",{class:!0});var I=children(h);p=claim_element(I,"BUTTON",{class:!0});var N=children(p);claim_component(s.$$.fragment,N),t=claim_space(N),claim_component(l.$$.fragment,N),N.forEach(detach),u=claim_space(I),y&&y.l(I),I.forEach(detach),x.forEach(detach),this.h()},h(){attr(n,"class","flex items-center flex-col gap-4"),attr(p,"class","relative hover:bg-primary-light inline-flex items-center justify-center rounded-md text-sm font-medium whitespace-nowrap ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 h-10 w-10 bg-transparent text-gray-800"),attr(h,"class",g=cn("flex items-center flex-col gap-4 mt-4",{"bg-slate-100 rounded-sm":c[4]})),attr(e,"class","h-full shadow-md bg-popover py-4 px-2 w-16 border-l border-slate-200 z-10")},m(S,x){insert_hydration(S,e,x),append_hydration(e,n),mount_component(r,n,null),append_hydration(n,i),mount_component(o,n,null),append_hydration(n,a),mount_component(d,n,null),append_hydration(e,f),append_hydration(e,h),append_hydration(h,p),mount_component(s,p,null),append_hydration(p,t),mount_component(l,p,null),append_hydration(h,u),y&&y.m(h,null),m=!0,_||(b=[listen(p,"click",c[6]),listen(p,"dblclick",c[11])],_=!0)},p(S,[x]){var L,E,M;const P={};x&1&&(P.selected=((L=S[0])==null?void 0:L.type)==="PAN"),x&32768&&(P.$$scope={dirty:x,ctx:S}),r.$set(P);const I={};x&1&&(I.selected=((E=S[0])==null?void 0:E.type)==="RECTANGLE"&&!S[0].isSmart),x&32768&&(I.$$scope={dirty:x,ctx:S}),o.$set(I);const N={};x&1&&(N.selected=((M=S[0])==null?void 0:M.type)==="POLYGON"),x&32768&&(N.$$scope={dirty:x,ctx:S}),d.$set(N),S[4]?y?(y.p(S,x),x&16&&transition_in(y,1)):(y=create_if_block$g(S),y.c(),transition_in(y,1),y.m(h,null)):y&&(group_outros(),transition_out(y,1,1,()=>{y=null}),check_outros()),(!m||x&16&&g!==(g=cn("flex items-center flex-col gap-4 mt-4",{"bg-slate-100 rounded-sm":S[4]})))&&attr(h,"class",g)},i(S){m||(transition_in(r.$$.fragment,S),transition_in(o.$$.fragment,S),transition_in(d.$$.fragment,S),transition_in(s.$$.fragment,S),transition_in(l.$$.fragment,S),transition_in(y),m=!0)},o(S){transition_out(r.$$.fragment,S),transition_out(o.$$.fragment,S),transition_out(d.$$.fragment,S),transition_out(s.$$.fragment,S),transition_out(l.$$.fragment,S),transition_out(y),m=!1},d(S){S&&detach(e),destroy_component(r),destroy_component(o),destroy_component(d),destroy_component(s),destroy_component(l),y&&y.d(),_=!1,run_all(b)}}}function instance$m(c,e,n){let{selectedTool:r}=e,i=null,o=!1;const a=g=>{g!==r&&n(0,r=g)},d=()=>{a(o?null:addSmartPointTool),n(4,o=!o)};interactiveSegmenterModel.subscribe(g=>{g&&(n(2,addSmartPointTool.postProcessor=g,addSmartPointTool),n(3,removeSmartPointTool.postProcessor=g,removeSmartPointTool),n(1,smartRectangleTool.postProcessor=g,smartRectangleTool))}),onMount(()=>{a(panTool)});const f=()=>a(panTool),h=()=>a(rectangleTool),p=()=>a(polygoneTool),s=()=>modelsStore.update(g=>({...g,currentModalOpen:"selectModel"})),t=()=>a(addSmartPointTool),l=()=>a(removeSmartPointTool),u=()=>a(smartRectangleTool);return c.$$set=g=>{"selectedTool"in g&&n(0,r=g.selectedTool)},c.$$.update=()=>{c.$$.dirty&129&&((!(i!=null&&i.isSmart)||!(r!=null&&r.isSmart))&&newShape.set({status:"none"}),n(7,i=r))},[r,smartRectangleTool,addSmartPointTool,removeSmartPointTool,o,a,d,i,f,h,p,s,t,l,u]}class Toolbar extends SvelteComponent{constructor(e){super(),init(this,e,instance$m,create_fragment$i,safe_not_equal,{selectedTool:0})}}var PI_OVER_180=Math.PI/180;function detectBrowser(){return typeof window<"u"&&({}.toString.call(window)==="[object Window]"||{}.toString.call(window)==="[object global]")}const glob=typeof global<"u"?global:typeof window<"u"?window:typeof WorkerGlobalScope<"u"?self:{},Konva$2={_global:glob,version:"8.4.3",isBrowser:detectBrowser(),isUnminified:/param/.test((function(c){}).toString()),dblClickWindow:400,getAngle(c){return Konva$2.angleDeg?c*PI_OVER_180:c},enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,pixelRatio:typeof window<"u"&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return Konva$2.DD.isDragging},isDragReady(){return!!Konva$2.DD.node},releaseCanvasOnDestroy:!0,document:glob.document,_injectGlobal(c){glob.Konva=c}},_registerNode=c=>{Konva$2[c.prototype.getClassName()]=c};Konva$2._injectGlobal(Konva$2);class Transform{constructor(e=[1,0,0,1,0,0]){this.dirty=!1,this.m=e&&e.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new Transform(this.m)}copyInto(e){e.m[0]=this.m[0],e.m[1]=this.m[1],e.m[2]=this.m[2],e.m[3]=this.m[3],e.m[4]=this.m[4],e.m[5]=this.m[5]}point(e){var n=this.m;return{x:n[0]*e.x+n[2]*e.y+n[4],y:n[1]*e.x+n[3]*e.y+n[5]}}translate(e,n){return this.m[4]+=this.m[0]*e+this.m[2]*n,this.m[5]+=this.m[1]*e+this.m[3]*n,this}scale(e,n){return this.m[0]*=e,this.m[1]*=e,this.m[2]*=n,this.m[3]*=n,this}rotate(e){var n=Math.cos(e),r=Math.sin(e),i=this.m[0]*n+this.m[2]*r,o=this.m[1]*n+this.m[3]*r,a=this.m[0]*-r+this.m[2]*n,d=this.m[1]*-r+this.m[3]*n;return this.m[0]=i,this.m[1]=o,this.m[2]=a,this.m[3]=d,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(e,n){var r=this.m[0]+this.m[2]*n,i=this.m[1]+this.m[3]*n,o=this.m[2]+this.m[0]*e,a=this.m[3]+this.m[1]*e;return this.m[0]=r,this.m[1]=i,this.m[2]=o,this.m[3]=a,this}multiply(e){var n=this.m[0]*e.m[0]+this.m[2]*e.m[1],r=this.m[1]*e.m[0]+this.m[3]*e.m[1],i=this.m[0]*e.m[2]+this.m[2]*e.m[3],o=this.m[1]*e.m[2]+this.m[3]*e.m[3],a=this.m[0]*e.m[4]+this.m[2]*e.m[5]+this.m[4],d=this.m[1]*e.m[4]+this.m[3]*e.m[5]+this.m[5];return this.m[0]=n,this.m[1]=r,this.m[2]=i,this.m[3]=o,this.m[4]=a,this.m[5]=d,this}invert(){var e=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),n=this.m[3]*e,r=-this.m[1]*e,i=-this.m[2]*e,o=this.m[0]*e,a=e*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),d=e*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=n,this.m[1]=r,this.m[2]=i,this.m[3]=o,this.m[4]=a,this.m[5]=d,this}getMatrix(){return this.m}decompose(){var e=this.m[0],n=this.m[1],r=this.m[2],i=this.m[3],o=this.m[4],a=this.m[5],d=e*i-n*r;let f={x:o,y:a,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(e!=0||n!=0){var h=Math.sqrt(e*e+n*n);f.rotation=n>0?Math.acos(e/h):-Math.acos(e/h),f.scaleX=h,f.scaleY=d/h,f.skewX=(e*r+n*i)/d,f.skewY=0}else if(r!=0||i!=0){var p=Math.sqrt(r*r+i*i);f.rotation=Math.PI/2-(i>0?Math.acos(-r/p):-Math.acos(r/p)),f.scaleX=d/p,f.scaleY=p,f.skewX=0,f.skewY=(e*r+n*i)/d}return f.rotation=Util._getRotation(f.rotation),f}}var OBJECT_ARRAY="[object Array]",OBJECT_NUMBER="[object Number]",OBJECT_STRING="[object String]",OBJECT_BOOLEAN="[object Boolean]",PI_OVER_DEG180=Math.PI/180,DEG180_OVER_PI=180/Math.PI,HASH$1="#",EMPTY_STRING$1="",ZERO="0",KONVA_WARNING="Konva warning: ",KONVA_ERROR="Konva error: ",RGB_PAREN="rgb(",COLORS={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},RGB_REGEX=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,animQueue=[];const req=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(c){setTimeout(c,60)},Util={_isElement(c){return!!(c&&c.nodeType==1)},_isFunction(c){return!!(c&&c.constructor&&c.call&&c.apply)},_isPlainObject(c){return!!c&&c.constructor===Object},_isArray(c){return Object.prototype.toString.call(c)===OBJECT_ARRAY},_isNumber(c){return Object.prototype.toString.call(c)===OBJECT_NUMBER&&!isNaN(c)&&isFinite(c)},_isString(c){return Object.prototype.toString.call(c)===OBJECT_STRING},_isBoolean(c){return Object.prototype.toString.call(c)===OBJECT_BOOLEAN},isObject(c){return c instanceof Object},isValidSelector(c){if(typeof c!="string")return!1;var e=c[0];return e==="#"||e==="."||e===e.toUpperCase()},_sign(c){return c===0||c>0?1:-1},requestAnimFrame(c){animQueue.push(c),animQueue.length===1&&req(function(){const e=animQueue;animQueue=[],e.forEach(function(n){n()})})},createCanvasElement(){var c=document.createElement("canvas");try{c.style=c.style||{}}catch{}return c},createImageElement(){return document.createElement("img")},_isInDocument(c){for(;c=c.parentNode;)if(c==document)return!0;return!1},_urlToImage(c,e){var n=Util.createImageElement();n.onload=function(){e(n)},n.src=c},_rgbToHex(c,e,n){return((1<<24)+(c<<16)+(e<<8)+n).toString(16).slice(1)},_hexToRgb(c){c=c.replace(HASH$1,EMPTY_STRING$1);var e=parseInt(c,16);return{r:e>>16&255,g:e>>8&255,b:e&255}},getRandomColor(){for(var c=(Math.random()*16777215<<0).toString(16);c.length<6;)c=ZERO+c;return HASH$1+c},getRGB(c){var e;return c in COLORS?(e=COLORS[c],{r:e[0],g:e[1],b:e[2]}):c[0]===HASH$1?this._hexToRgb(c.substring(1)):c.substr(0,4)===RGB_PAREN?(e=RGB_REGEX.exec(c.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA(c){return c=c||"black",Util._namedColorToRBA(c)||Util._hex3ColorToRGBA(c)||Util._hex4ColorToRGBA(c)||Util._hex6ColorToRGBA(c)||Util._hex8ColorToRGBA(c)||Util._rgbColorToRGBA(c)||Util._rgbaColorToRGBA(c)||Util._hslColorToRGBA(c)},_namedColorToRBA(c){var e=COLORS[c.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(c){if(c.indexOf("rgb(")===0){c=c.match(/rgb\(([^)]+)\)/)[1];var e=c.split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(c){if(c.indexOf("rgba(")===0){c=c.match(/rgba\(([^)]+)\)/)[1];var e=c.split(/ *, */).map((n,r)=>n.slice(-1)==="%"?r===3?parseInt(n)/100:parseInt(n)/100*255:Number(n));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(c){if(c[0]==="#"&&c.length===9)return{r:parseInt(c.slice(1,3),16),g:parseInt(c.slice(3,5),16),b:parseInt(c.slice(5,7),16),a:parseInt(c.slice(7,9),16)/255}},_hex6ColorToRGBA(c){if(c[0]==="#"&&c.length===7)return{r:parseInt(c.slice(1,3),16),g:parseInt(c.slice(3,5),16),b:parseInt(c.slice(5,7),16),a:1}},_hex4ColorToRGBA(c){if(c[0]==="#"&&c.length===5)return{r:parseInt(c[1]+c[1],16),g:parseInt(c[2]+c[2],16),b:parseInt(c[3]+c[3],16),a:parseInt(c[4]+c[4],16)/255}},_hex3ColorToRGBA(c){if(c[0]==="#"&&c.length===4)return{r:parseInt(c[1]+c[1],16),g:parseInt(c[2]+c[2],16),b:parseInt(c[3]+c[3],16),a:1}},_hslColorToRGBA(c){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(c)){const[e,...n]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(c),r=Number(n[0])/360,i=Number(n[1])/100,o=Number(n[2])/100;let a,d,f;if(i===0)return f=o*255,{r:Math.round(f),g:Math.round(f),b:Math.round(f),a:1};o<.5?a=o*(1+i):a=o+i-o*i;const h=2*o-a,p=[0,0,0];for(let s=0;s<3;s++)d=r+1/3*-(s-1),d<0&&d++,d>1&&d--,6*d<1?f=h+(a-h)*6*d:2*d<1?f=a:3*d<2?f=h+(a-h)*(2/3-d)*6:f=h,p[s]=f*255;return{r:Math.round(p[0]),g:Math.round(p[1]),b:Math.round(p[2]),a:1}}},haveIntersection(c,e){return!(e.x>c.x+c.width||e.x+e.width<c.x||e.y>c.y+c.height||e.y+e.height<c.y)},cloneObject(c){var e={};for(var n in c)this._isPlainObject(c[n])?e[n]=this.cloneObject(c[n]):this._isArray(c[n])?e[n]=this.cloneArray(c[n]):e[n]=c[n];return e},cloneArray(c){return c.slice(0)},degToRad(c){return c*PI_OVER_DEG180},radToDeg(c){return c*DEG180_OVER_PI},_degToRad(c){return Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),Util.degToRad(c)},_radToDeg(c){return Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),Util.radToDeg(c)},_getRotation(c){return Konva$2.angleDeg?Util.radToDeg(c):c},_capitalize(c){return c.charAt(0).toUpperCase()+c.slice(1)},throw(c){throw new Error(KONVA_ERROR+c)},error(c){console.error(KONVA_ERROR+c)},warn(c){Konva$2.showWarnings&&console.warn(KONVA_WARNING+c)},each(c,e){for(var n in c)e(n,c[n])},_inRange(c,e,n){return e<=c&&c<n},_getProjectionToSegment(c,e,n,r,i,o){var a,d,f,h=(c-n)*(c-n)+(e-r)*(e-r);if(h==0)a=c,d=e,f=(i-n)*(i-n)+(o-r)*(o-r);else{var p=((i-c)*(n-c)+(o-e)*(r-e))/h;p<0?(a=c,d=e,f=(c-i)*(c-i)+(e-o)*(e-o)):p>1?(a=n,d=r,f=(n-i)*(n-i)+(r-o)*(r-o)):(a=c+p*(n-c),d=e+p*(r-e),f=(a-i)*(a-i)+(d-o)*(d-o))}return[a,d,f]},_getProjectionToLine(c,e,n){var r=Util.cloneObject(c),i=Number.MAX_VALUE;return e.forEach(function(o,a){if(!(!n&&a===e.length-1)){var d=e[(a+1)%e.length],f=Util._getProjectionToSegment(o.x,o.y,d.x,d.y,c.x,c.y),h=f[0],p=f[1],s=f[2];s<i&&(r.x=h,r.y=p,i=s)}}),r},_prepareArrayForTween(c,e,n){var r,i=[],o=[];if(c.length>e.length){var a=e;e=c,c=a}for(r=0;r<c.length;r+=2)i.push({x:c[r],y:c[r+1]});for(r=0;r<e.length;r+=2)o.push({x:e[r],y:e[r+1]});var d=[];return o.forEach(function(f){var h=Util._getProjectionToLine(f,i,n);d.push(h.x),d.push(h.y)}),d},_prepareToStringify(c){var e;c.visitedByCircularReferenceRemoval=!0;for(var n in c)if(c.hasOwnProperty(n)&&c[n]&&typeof c[n]=="object"){if(e=Object.getOwnPropertyDescriptor(c,n),c[n].visitedByCircularReferenceRemoval||Util._isElement(c[n]))if(e.configurable)delete c[n];else return null;else if(Util._prepareToStringify(c[n])===null)if(e.configurable)delete c[n];else return null}return delete c.visitedByCircularReferenceRemoval,c},_assign(c,e){for(var n in e)c[n]=e[n];return c},_getFirstPointerId(c){return c.touches?c.changedTouches[0].identifier:c.pointerId||999},releaseCanvas(...c){Konva$2.releaseCanvasOnDestroy&&c.forEach(e=>{e.width=0,e.height=0})},drawRoundedRectPath(c,e,n,r){let i=0,o=0,a=0,d=0;typeof r=="number"?i=o=a=d=Math.min(r,e/2,n/2):(i=Math.min(r[0]||0,e/2,n/2),o=Math.min(r[1]||0,e/2,n/2),d=Math.min(r[2]||0,e/2,n/2),a=Math.min(r[3]||0,e/2,n/2)),c.moveTo(i,0),c.lineTo(e-o,0),c.arc(e-o,o,o,Math.PI*3/2,0,!1),c.lineTo(e,n-d),c.arc(e-d,n-d,d,0,Math.PI/2,!1),c.lineTo(a,n),c.arc(a,n-a,a,Math.PI/2,Math.PI,!1),c.lineTo(0,i),c.arc(i,i,i,Math.PI,Math.PI*3/2,!1)}};function _formatValue(c){return Util._isString(c)?'"'+c+'"':Object.prototype.toString.call(c)==="[object Number]"||Util._isBoolean(c)?c:Object.prototype.toString.call(c)}function RGBComponent(c){return c>255?255:c<0?0:Math.round(c)}function getNumberValidator(){if(Konva$2.isUnminified)return function(c,e){return Util._isNumber(c)||Util.warn(_formatValue(c)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),c}}function getNumberOrArrayOfNumbersValidator(c){if(Konva$2.isUnminified)return function(e,n){let r=Util._isNumber(e),i=Util._isArray(e)&&e.length==c;return!r&&!i&&Util.warn(_formatValue(e)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+c+")"),e}}function getNumberOrAutoValidator(){if(Konva$2.isUnminified)return function(c,e){var n=Util._isNumber(c),r=c==="auto";return n||r||Util.warn(_formatValue(c)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),c}}function getStringValidator(){if(Konva$2.isUnminified)return function(c,e){return Util._isString(c)||Util.warn(_formatValue(c)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),c}}function getStringOrGradientValidator(){if(Konva$2.isUnminified)return function(c,e){const n=Util._isString(c),r=Object.prototype.toString.call(c)==="[object CanvasGradient]"||c&&c.addColorStop;return n||r||Util.warn(_formatValue(c)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),c}}function getNumberArrayValidator(){if(Konva$2.isUnminified)return function(c,e){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&c instanceof n||(Util._isArray(c)?c.forEach(function(r){Util._isNumber(r)||Util.warn('"'+e+'" attribute has non numeric element '+r+". Make sure that all elements are numbers.")}):Util.warn(_formatValue(c)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),c}}function getBooleanValidator(){if(Konva$2.isUnminified)return function(c,e){var n=c===!0||c===!1;return n||Util.warn(_formatValue(c)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),c}}function getComponentValidator(c){if(Konva$2.isUnminified)return function(e,n){return e==null||Util.isObject(e)||Util.warn(_formatValue(e)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+c),e}}var GET="get",SET$1="set";const Factory={addGetterSetter(c,e,n,r,i){Factory.addGetter(c,e,n),Factory.addSetter(c,e,r,i),Factory.addOverloadedGetterSetter(c,e)},addGetter(c,e,n){var r=GET+Util._capitalize(e);c.prototype[r]=c.prototype[r]||function(){var i=this.attrs[e];return i===void 0?n:i}},addSetter(c,e,n,r){var i=SET$1+Util._capitalize(e);c.prototype[i]||Factory.overWriteSetter(c,e,n,r)},overWriteSetter(c,e,n,r){var i=SET$1+Util._capitalize(e);c.prototype[i]=function(o){return n&&o!==void 0&&o!==null&&(o=n.call(this,o,e)),this._setAttr(e,o),r&&r.call(this),this}},addComponentsGetterSetter(c,e,n,r,i){var o=n.length,a=Util._capitalize,d=GET+a(e),f=SET$1+a(e),h,p;c.prototype[d]=function(){var t={};for(h=0;h<o;h++)p=n[h],t[p]=this.getAttr(e+a(p));return t};var s=getComponentValidator(n);c.prototype[f]=function(t){var l=this.attrs[e],u;r&&(t=r.call(this,t)),s&&s.call(this,t,e);for(u in t)t.hasOwnProperty(u)&&this._setAttr(e+a(u),t[u]);return t||n.forEach(g=>{this._setAttr(e+a(g),void 0)}),this._fireChangeEvent(e,l,t),i&&i.call(this),this},Factory.addOverloadedGetterSetter(c,e)},addOverloadedGetterSetter(c,e){var n=Util._capitalize(e),r=SET$1+n,i=GET+n;c.prototype[e]=function(){return arguments.length?(this[r](arguments[0]),this):this[i]()}},addDeprecatedGetterSetter(c,e,n,r){Util.error("Adding deprecated "+e);var i=GET+Util._capitalize(e),o=e+" property is deprecated and will be removed soon. Look at Konva change log for more information.";c.prototype[i]=function(){Util.error(o);var a=this.attrs[e];return a===void 0?n:a},Factory.addSetter(c,e,r,function(){Util.error(o)}),Factory.addOverloadedGetterSetter(c,e)},backCompat(c,e){Util.each(e,function(n,r){var i=c.prototype[r],o=GET+Util._capitalize(n),a=SET$1+Util._capitalize(n);function d(){i.apply(this,arguments),Util.error('"'+n+'" method is deprecated and will be removed soon. Use ""'+r+'" instead.')}c.prototype[n]=d,c.prototype[o]=d,c.prototype[a]=d})},afterSetFilter(){this._filterUpToDate=!1}};function simplifyArray(c){var e=[],n=c.length,r=Util,i,o;for(i=0;i<n;i++)o=c[i],r._isNumber(o)?o=Math.round(o*1e3)/1e3:r._isString(o)||(o=o+""),e.push(o);return e}var COMMA=",",OPEN_PAREN="(",CLOSE_PAREN=")",OPEN_PAREN_BRACKET="([",CLOSE_BRACKET_PAREN="])",SEMICOLON=";",DOUBLE_PAREN="()",EQUALS="=",CONTEXT_METHODS=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"],CONTEXT_PROPERTIES=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"];const traceArrMax=100;class Context{constructor(e){this.canvas=e,Konva$2.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(e){e.fillEnabled()&&this._fill(e)}_fill(e){}strokeShape(e){e.hasStroke()&&this._stroke(e)}_stroke(e){}fillStrokeShape(e){e.attrs.fillAfterStrokeEnabled?(this.strokeShape(e),this.fillShape(e)):(this.fillShape(e),this.strokeShape(e))}getTrace(e,n){var r=this.traceArr,i=r.length,o="",a,d,f,h;for(a=0;a<i;a++)d=r[a],f=d.method,f?(h=d.args,o+=f,e?o+=DOUBLE_PAREN:Util._isArray(h[0])?o+=OPEN_PAREN_BRACKET+h.join(COMMA)+CLOSE_BRACKET_PAREN:(n&&(h=h.map(p=>typeof p=="number"?Math.floor(p):p)),o+=OPEN_PAREN+h.join(COMMA)+CLOSE_PAREN)):(o+=d.property,e||(o+=EQUALS+d.val)),o+=SEMICOLON;return o}clearTrace(){this.traceArr=[]}_trace(e){var n=this.traceArr,r;n.push(e),r=n.length,r>=traceArrMax&&n.shift()}reset(){var e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){var n=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,n.getWidth()/n.pixelRatio,n.getHeight()/n.pixelRatio)}_applyLineCap(e){const n=e.attrs.lineCap;n&&this.setAttr("lineCap",n)}_applyOpacity(e){var n=e.getAbsoluteOpacity();n!==1&&this.setAttr("globalAlpha",n)}_applyLineJoin(e){const n=e.attrs.lineJoin;n&&this.setAttr("lineJoin",n)}setAttr(e,n){this._context[e]=n}arc(e,n,r,i,o,a){this._context.arc(e,n,r,i,o,a)}arcTo(e,n,r,i,o){this._context.arcTo(e,n,r,i,o)}beginPath(){this._context.beginPath()}bezierCurveTo(e,n,r,i,o,a){this._context.bezierCurveTo(e,n,r,i,o,a)}clearRect(e,n,r,i){this._context.clearRect(e,n,r,i)}clip(){this._context.clip()}closePath(){this._context.closePath()}createImageData(e,n){var r=arguments;if(r.length===2)return this._context.createImageData(e,n);if(r.length===1)return this._context.createImageData(e)}createLinearGradient(e,n,r,i){return this._context.createLinearGradient(e,n,r,i)}createPattern(e,n){return this._context.createPattern(e,n)}createRadialGradient(e,n,r,i,o,a){return this._context.createRadialGradient(e,n,r,i,o,a)}drawImage(e,n,r,i,o,a,d,f,h){var p=arguments,s=this._context;p.length===3?s.drawImage(e,n,r):p.length===5?s.drawImage(e,n,r,i,o):p.length===9&&s.drawImage(e,n,r,i,o,a,d,f,h)}ellipse(e,n,r,i,o,a,d,f){this._context.ellipse(e,n,r,i,o,a,d,f)}isPointInPath(e,n,r,i){return r?this._context.isPointInPath(r,e,n,i):this._context.isPointInPath(e,n,i)}fill(e){e?this._context.fill(e):this._context.fill()}fillRect(e,n,r,i){this._context.fillRect(e,n,r,i)}strokeRect(e,n,r,i){this._context.strokeRect(e,n,r,i)}fillText(e,n,r,i){i?this._context.fillText(e,n,r,i):this._context.fillText(e,n,r)}measureText(e){return this._context.measureText(e)}getImageData(e,n,r,i){return this._context.getImageData(e,n,r,i)}lineTo(e,n){this._context.lineTo(e,n)}moveTo(e,n){this._context.moveTo(e,n)}rect(e,n,r,i){this._context.rect(e,n,r,i)}putImageData(e,n,r){this._context.putImageData(e,n,r)}quadraticCurveTo(e,n,r,i){this._context.quadraticCurveTo(e,n,r,i)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,n){this._context.scale(e,n)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):"mozDash"in this._context?this._context.mozDash=e:"webkitLineDash"in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,n,r,i,o,a){this._context.setTransform(e,n,r,i,o,a)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,n,r,i){this._context.strokeText(e,n,r,i)}transform(e,n,r,i,o,a){this._context.transform(e,n,r,i,o,a)}translate(e,n){this._context.translate(e,n)}_enableTrace(){var e=this,n=CONTEXT_METHODS.length,r=this.setAttr,i,o,a=function(d){var f=e[d],h;e[d]=function(){return o=simplifyArray(Array.prototype.slice.call(arguments,0)),h=f.apply(e,arguments),e._trace({method:d,args:o}),h}};for(i=0;i<n;i++)a(CONTEXT_METHODS[i]);e.setAttr=function(){r.apply(e,arguments);var d=arguments[0],f=arguments[1];(d==="shadowOffsetX"||d==="shadowOffsetY"||d==="shadowBlur")&&(f=f/this.canvas.getPixelRatio()),e._trace({property:d,val:f})}}_applyGlobalCompositeOperation(e){const n=e.attrs.globalCompositeOperation;var r=!n||n==="source-over";r||this.setAttr("globalCompositeOperation",n)}}CONTEXT_PROPERTIES.forEach(function(c){Object.defineProperty(Context.prototype,c,{get(){return this._context[c]},set(e){this._context[c]=e}})});class SceneContext extends Context{constructor(e){super(e),this._context=e._canvas.getContext("2d")}_fillColor(e){var n=e.fill();this.setAttr("fillStyle",n),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){var n=e._getLinearGradient();n&&(this.setAttr("fillStyle",n),e._fillFunc(this))}_fillRadialGradient(e){const n=e._getRadialGradient();n&&(this.setAttr("fillStyle",n),e._fillFunc(this))}_fill(e){const n=e.fill(),r=e.getFillPriority();if(n&&r==="color"){this._fillColor(e);return}const i=e.getFillPatternImage();if(i&&r==="pattern"){this._fillPattern(e);return}const o=e.getFillLinearGradientColorStops();if(o&&r==="linear-gradient"){this._fillLinearGradient(e);return}const a=e.getFillRadialGradientColorStops();if(a&&r==="radial-gradient"){this._fillRadialGradient(e);return}n?this._fillColor(e):i?this._fillPattern(e):o?this._fillLinearGradient(e):a&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const n=e.getStrokeLinearGradientStartPoint(),r=e.getStrokeLinearGradientEndPoint(),i=e.getStrokeLinearGradientColorStops(),o=this.createLinearGradient(n.x,n.y,r.x,r.y);if(i){for(var a=0;a<i.length;a+=2)o.addColorStop(i[a],i[a+1]);this.setAttr("strokeStyle",o)}}_stroke(e){var n=e.dash(),r=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!r){this.save();var i=this.getCanvas().getPixelRatio();this.setTransform(i,0,0,i,0,0)}this._applyLineCap(e),n&&e.dashEnabled()&&(this.setLineDash(n),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");var o=e.getStrokeLinearGradientColorStops();o?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),r||this.restore()}}_applyShadow(e){var n,r,i,o=(n=e.getShadowRGBA())!==null&&n!==void 0?n:"black",a=(r=e.getShadowBlur())!==null&&r!==void 0?r:5,d=(i=e.getShadowOffset())!==null&&i!==void 0?i:{x:0,y:0},f=e.getAbsoluteScale(),h=this.canvas.getPixelRatio(),p=f.x*h,s=f.y*h;this.setAttr("shadowColor",o),this.setAttr("shadowBlur",a*Math.min(Math.abs(p),Math.abs(s))),this.setAttr("shadowOffsetX",d.x*p),this.setAttr("shadowOffsetY",d.y*s)}}class HitContext extends Context{constructor(e){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr("fillStyle",e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){const o=e.getStrokeScaleEnabled();if(!o){this.save();var n=this.getCanvas().getPixelRatio();this.setTransform(n,0,0,n,0,0)}this._applyLineCap(e);var r=e.hitStrokeWidth(),i=r==="auto"?e.strokeWidth():r;this.setAttr("lineWidth",i),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),o||this.restore()}}}var _pixelRatio;function getDevicePixelRatio(){if(_pixelRatio)return _pixelRatio;var c=Util.createCanvasElement(),e=c.getContext("2d");return _pixelRatio=function(){var n=Konva$2._global.devicePixelRatio||1,r=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return n/r}(),Util.releaseCanvas(c),_pixelRatio}class Canvas{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var n=e||{},r=n.pixelRatio||Konva$2.pixelRatio||getDevicePixelRatio();this.pixelRatio=r,this._canvas=Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){var n=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/n,this.getHeight()/n)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";var n=this.pixelRatio,r=this.getContext()._context;r.scale(n,n)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";var n=this.pixelRatio,r=this.getContext()._context;r.scale(n,n)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,n){this.setWidth(e||0),this.setHeight(n||0)}toDataURL(e,n){try{return this._canvas.toDataURL(e,n)}catch{try{return this._canvas.toDataURL()}catch(i){return Util.error("Unable to get data URL. "+i.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}Factory.addGetterSetter(Canvas,"pixelRatio",void 0,getNumberValidator());class SceneCanvas extends Canvas{constructor(e={width:0,height:0}){super(e),this.context=new SceneContext(this),this.setSize(e.width,e.height)}}class HitCanvas extends Canvas{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new HitContext(this),this.setSize(e.width,e.height)}}const DD={get isDragging(){var c=!1;return DD._dragElements.forEach(e=>{e.dragStatus==="dragging"&&(c=!0)}),c},justDragged:!1,get node(){var c;return DD._dragElements.forEach(e=>{c=e.node}),c},_dragElements:new Map,_drag(c){const e=[];DD._dragElements.forEach((n,r)=>{const{node:i}=n,o=i.getStage();o.setPointersPositions(c),n.pointerId===void 0&&(n.pointerId=Util._getFirstPointerId(c));const a=o._changedPointerPositions.find(h=>h.id===n.pointerId);if(a){if(n.dragStatus!=="dragging"){var d=i.dragDistance(),f=Math.max(Math.abs(a.x-n.startPointerPos.x),Math.abs(a.y-n.startPointerPos.y));if(f<d||(i.startDrag({evt:c}),!i.isDragging()))return}i._setDragPosition(c,n),e.push(i)}}),e.forEach(n=>{n.fire("dragmove",{type:"dragmove",target:n,evt:c},!0)})},_endDragBefore(c){const e=[];DD._dragElements.forEach(n=>{const{node:r}=n,i=r.getStage();if(c&&i.setPointersPositions(c),!i._changedPointerPositions.find(d=>d.id===n.pointerId))return;(n.dragStatus==="dragging"||n.dragStatus==="stopped")&&(DD.justDragged=!0,Konva$2._mouseListenClick=!1,Konva$2._touchListenClick=!1,Konva$2._pointerListenClick=!1,n.dragStatus="stopped");const a=n.node.getLayer()||n.node instanceof Konva$2.Stage&&n.node;a&&e.indexOf(a)===-1&&e.push(a)}),e.forEach(n=>{n.draw()})},_endDragAfter(c){DD._dragElements.forEach((e,n)=>{e.dragStatus==="stopped"&&e.node.fire("dragend",{type:"dragend",target:e.node,evt:c},!0),e.dragStatus!=="dragging"&&DD._dragElements.delete(n)})}};Konva$2.isBrowser&&(window.addEventListener("mouseup",DD._endDragBefore,!0),window.addEventListener("touchend",DD._endDragBefore,!0),window.addEventListener("mousemove",DD._drag),window.addEventListener("touchmove",DD._drag),window.addEventListener("mouseup",DD._endDragAfter,!1),window.addEventListener("touchend",DD._endDragAfter,!1));var ABSOLUTE_OPACITY="absoluteOpacity",ALL_LISTENERS="allEventListeners",ABSOLUTE_TRANSFORM="absoluteTransform",ABSOLUTE_SCALE="absoluteScale",CANVAS="canvas",CHANGE="Change",CHILDREN="children",KONVA="konva",LISTENING="listening",MOUSEENTER$1="mouseenter",MOUSELEAVE$1="mouseleave",SET="set",SHAPE="Shape",SPACE$1=" ",STAGE$1="stage",TRANSFORM="transform",UPPER_STAGE="Stage",VISIBLE="visible",TRANSFORM_CHANGE_STR$1=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(SPACE$1);let idCounter$1=1;class Node{constructor(e){this._id=idCounter$1++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(e),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(e){(e===TRANSFORM||e===ABSOLUTE_TRANSFORM)&&this._cache.get(e)?this._cache.get(e).dirty=!0:e?this._cache.delete(e):this._cache.clear()}_getCache(e,n){var r=this._cache.get(e),i=e===TRANSFORM||e===ABSOLUTE_TRANSFORM,o=r===void 0||i&&r.dirty===!0;return o&&(r=n.call(this),this._cache.set(e,r)),r}_calculate(e,n,r){if(!this._attachedDepsListeners.get(e)){const i=n.map(o=>o+"Change.konva").join(SPACE$1);this.on(i,()=>{this._clearCache(e)}),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,r)}_getCanvasCache(){return this._cache.get(CANVAS)}_clearSelfAndDescendantCache(e){this._clearCache(e),e===ABSOLUTE_TRANSFORM&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(CANVAS)){const{scene:e,filter:n,hit:r}=this._cache.get(CANVAS);Util.releaseCanvas(e,n,r),this._cache.delete(CANVAS)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){var n=e||{},r={};(n.x===void 0||n.y===void 0||n.width===void 0||n.height===void 0)&&(r=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()}));var i=Math.ceil(n.width||r.width),o=Math.ceil(n.height||r.height),a=n.pixelRatio,d=n.x===void 0?Math.floor(r.x):n.x,f=n.y===void 0?Math.floor(r.y):n.y,h=n.offset||0,p=n.drawBorder||!1,s=n.hitCanvasPixelRatio||1;if(!i||!o){Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}i+=h*2+1,o+=h*2+1,d-=h,f-=h;var t=new SceneCanvas({pixelRatio:a,width:i,height:o}),l=new SceneCanvas({pixelRatio:a,width:0,height:0}),u=new HitCanvas({pixelRatio:s,width:i,height:o}),g=t.getContext(),m=u.getContext();return u.isCache=!0,t.isCache=!0,this._cache.delete(CANVAS),this._filterUpToDate=!1,n.imageSmoothingEnabled===!1&&(t.getContext()._context.imageSmoothingEnabled=!1,l.getContext()._context.imageSmoothingEnabled=!1),g.save(),m.save(),g.translate(-d,-f),m.translate(-d,-f),this._isUnderCache=!0,this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY),this._clearSelfAndDescendantCache(ABSOLUTE_SCALE),this.drawScene(t,this),this.drawHit(u,this),this._isUnderCache=!1,g.restore(),m.restore(),p&&(g.save(),g.beginPath(),g.rect(0,0,i,o),g.closePath(),g.setAttr("strokeStyle","red"),g.setAttr("lineWidth",5),g.stroke(),g.restore()),this._cache.set(CANVAS,{scene:t,filter:l,hit:u,x:d,y:f}),this._requestDraw(),this}isCached(){return this._cache.has(CANVAS)}getClientRect(e){throw new Error('abstract "getClientRect" method call')}_transformedRect(e,n){var r=[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],i,o,a,d,f=this.getAbsoluteTransform(n);return r.forEach(function(h){var p=f.point(h);i===void 0&&(i=a=p.x,o=d=p.y),i=Math.min(i,p.x),o=Math.min(o,p.y),a=Math.max(a,p.x),d=Math.max(d,p.y)}),{x:i,y:o,width:a-i,height:d-o}}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);const n=this._getCanvasCache();e.translate(n.x,n.y);var r=this._getCachedSceneCanvas(),i=r.pixelRatio;e.drawImage(r._canvas,0,0,r.width/i,r.height/i),e.restore()}_drawCachedHitCanvas(e){var n=this._getCanvasCache(),r=n.hit;e.save(),e.translate(n.x,n.y),e.drawImage(r._canvas,0,0,r.width/r.pixelRatio,r.height/r.pixelRatio),e.restore()}_getCachedSceneCanvas(){var e=this.filters(),n=this._getCanvasCache(),r=n.scene,i=n.filter,o=i.getContext(),a,d,f,h;if(e){if(!this._filterUpToDate){var p=r.pixelRatio;i.setSize(r.width/r.pixelRatio,r.height/r.pixelRatio);try{for(a=e.length,o.clear(),o.drawImage(r._canvas,0,0,r.getWidth()/p,r.getHeight()/p),d=o.getImageData(0,0,i.getWidth(),i.getHeight()),f=0;f<a;f++){if(h=e[f],typeof h!="function"){Util.error("Filter should be type of function, but got "+typeof h+" instead. Please check correct filters");continue}h.call(this,d),o.putImageData(d,0,0)}}catch(s){Util.error("Unable to apply filter. "+s.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return i}return r}on(e,n){if(this._cache&&this._cache.delete(ALL_LISTENERS),arguments.length===3)return this._delegate.apply(this,arguments);var r=e.split(SPACE$1),i=r.length,o,a,d,f,h;for(o=0;o<i;o++)a=r[o],d=a.split("."),f=d[0],h=d[1]||"",this.eventListeners[f]||(this.eventListeners[f]=[]),this.eventListeners[f].push({name:h,handler:n});return this}off(e,n){var r=(e||"").split(SPACE$1),i=r.length,o,a,d,f,h,p;if(this._cache&&this._cache.delete(ALL_LISTENERS),!e)for(a in this.eventListeners)this._off(a);for(o=0;o<i;o++)if(d=r[o],f=d.split("."),h=f[0],p=f[1],h)this.eventListeners[h]&&this._off(h,p,n);else for(a in this.eventListeners)this._off(a,p,n);return this}dispatchEvent(e){var n={target:this,type:e.type,evt:e};return this.fire(e.type,n),this}addEventListener(e,n){return this.on(e,function(r){n.call(this,r.evt)}),this}removeEventListener(e){return this.off(e),this}_delegate(e,n,r){var i=this;this.on(e,function(o){for(var a=o.target.findAncestors(n,!0,i),d=0;d<a.length;d++)o=Util.cloneObject(o),o.currentTarget=a[d],r.call(a[d],o)})}remove(){return this.isDragging()&&this.stopDrag(),DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY),this._clearSelfAndDescendantCache(ABSOLUTE_SCALE),this._clearSelfAndDescendantCache(STAGE$1),this._clearSelfAndDescendantCache(VISIBLE),this._clearSelfAndDescendantCache(LISTENING)}_remove(){this._clearCaches();var e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){var n="get"+Util._capitalize(e);return Util._isFunction(this[n])?this[n]():this.attrs[e]}getAncestors(){for(var e=this.getParent(),n=[];e;)n.push(e),e=e.getParent();return n}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges(()=>{var n,r;if(!e)return this;for(n in e)n!==CHILDREN&&(r=SET+Util._capitalize(n),Util._isFunction(this[r])?this[r](e[n]):this._setAttr(n,e[n]))}),this}isListening(){return this._getCache(LISTENING,this._isListening)}_isListening(e){if(!this.listening())return!1;const r=this.getParent();return r&&r!==e&&this!==e?r._isListening(e):!0}isVisible(){return this._getCache(VISIBLE,this._isVisible)}_isVisible(e){if(!this.visible())return!1;const r=this.getParent();return r&&r!==e&&this!==e?r._isVisible(e):!0}shouldDrawHit(e,n=!1){if(e)return this._isVisible(e)&&this._isListening(e);var r=this.getLayer(),i=!1;DD._dragElements.forEach(a=>{a.dragStatus==="dragging"&&(a.node.nodeType==="Stage"||a.node.getLayer()===r)&&(i=!0)});var o=!n&&!Konva$2.hitOnDragEnabled&&i;return this.isListening()&&this.isVisible()&&!o}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){var e=this.getDepth(),n=this,r=0,i,o,a,d;function f(h){for(i=[],o=h.length,a=0;a<o;a++)d=h[a],r++,d.nodeType!==SHAPE&&(i=i.concat(d.getChildren().slice())),d._id===n._id&&(a=o);i.length>0&&i[0].getDepth()<=e&&f(i)}return n.nodeType!==UPPER_STAGE&&f(n.getStage().getChildren()),r}getDepth(){for(var e=0,n=this.parent;n;)e++,n=n.parent;return e}_batchTransformChanges(e){this._batchingTransformChange=!0,e(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM)),this._needClearTransformCache=!1}setPosition(e){return this._batchTransformChanges(()=>{this.x(e.x),this.y(e.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){if(!this.getStage())return null;var e=this.getStage().getPointerPosition();if(!e)return null;var n=this.getAbsoluteTransform().copy();return n.invert(),n.point(e)}getAbsolutePosition(e){let n=!1,r=this.parent;for(;r;){if(r.isCached()){n=!0;break}r=r.parent}n&&!e&&(e=!0);var i=this.getAbsoluteTransform(e).getMatrix(),o=new Transform,a=this.offset();return o.m=i.slice(),o.translate(a.x,a.y),o.getTranslation()}setAbsolutePosition(e){var n=this._clearTransform();this.attrs.x=n.x,this.attrs.y=n.y,delete n.x,delete n.y,this._clearCache(TRANSFORM);var r=this._getAbsoluteTransform().copy();return r.invert(),r.translate(e.x,e.y),e={x:this.attrs.x+r.getTranslation().x,y:this.attrs.y+r.getTranslation().y},this._setTransform(n),this.setPosition({x:e.x,y:e.y}),this._clearCache(TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM),this}_setTransform(e){var n;for(n in e)this.attrs[n]=e[n]}_clearTransform(){var e={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,e}move(e){var n=e.x,r=e.y,i=this.x(),o=this.y();return n!==void 0&&(i+=n),r!==void 0&&(o+=r),this.setPosition({x:i,y:o}),this}_eachAncestorReverse(e,n){var r=[],i=this.getParent(),o,a;if(!(n&&n._id===this._id)){for(r.unshift(this);i&&(!n||i._id!==n._id);)r.unshift(i),i=i.parent;for(o=r.length,a=0;a<o;a++)e(r[a])}}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return Util.warn("Node has no parent. moveToTop function is ignored."),!1;var e=this.index,n=this.parent.getChildren().length;return e<n-1?(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0):!1}moveUp(){if(!this.parent)return Util.warn("Node has no parent. moveUp function is ignored."),!1;var e=this.index,n=this.parent.getChildren().length;return e<n-1?(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0):!1}moveDown(){if(!this.parent)return Util.warn("Node has no parent. moveDown function is ignored."),!1;var e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0):!1}moveToBottom(){if(!this.parent)return Util.warn("Node has no parent. moveToBottom function is ignored."),!1;var e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1}setZIndex(e){if(!this.parent)return Util.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&Util.warn("Unexpected value "+e+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");var n=this.index;return this.parent.children.splice(n,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(ABSOLUTE_OPACITY,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){var e=this.opacity(),n=this.getParent();return n&&!n._isUnderCache&&(e*=n.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){var e={},n=this.getAttrs(),r,i,o,a,d;e.attrs={};for(r in n)i=n[r],d=Util.isObject(i)&&!Util._isPlainObject(i)&&!Util._isArray(i),!d&&(o=typeof this[r]=="function"&&this[r],delete n[r],a=o?o.call(this):null,n[r]=i,a!==i&&(e.attrs[r]=i));return e.className=this.getClassName(),Util._prepareToStringify(e)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,n,r){var i=[];n&&this._isMatch(e)&&i.push(this);for(var o=this.parent;o;){if(o===r)return i;o._isMatch(e)&&i.push(o),o=o.parent}return i}isAncestorOf(e){return!1}findAncestor(e,n,r){return this.findAncestors(e,n,r)[0]}_isMatch(e){if(!e)return!1;if(typeof e=="function")return e(this);var n=e.replace(/ /g,"").split(","),r=n.length,i,o;for(i=0;i<r;i++)if(o=n[i],Util.isValidSelector(o)||(Util.warn('Selector "'+o+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),Util.warn("Konva is awesome, right?")),o.charAt(0)==="#"){if(this.id()===o.slice(1))return!0}else if(o.charAt(0)==="."){if(this.hasName(o.slice(1)))return!0}else if(this.className===o||this.nodeType===o)return!0;return!1}getLayer(){var e=this.getParent();return e?e.getLayer():null}getStage(){return this._getCache(STAGE$1,this._getStage)}_getStage(){var e=this.getParent();if(e)return e.getStage()}fire(e,n={},r){return n.target=n.target||this,r?this._fireAndBubble(e,n):this._fire(e,n),this}getAbsoluteTransform(e){return e?this._getAbsoluteTransform(e):this._getCache(ABSOLUTE_TRANSFORM,this._getAbsoluteTransform)}_getAbsoluteTransform(e){var n;if(e)return n=new Transform,this._eachAncestorReverse(function(i){var o=i.transformsEnabled();o==="all"?n.multiply(i.getTransform()):o==="position"&&n.translate(i.x()-i.offsetX(),i.y()-i.offsetY())},e),n;n=this._cache.get(ABSOLUTE_TRANSFORM)||new Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(n):n.reset();var r=this.transformsEnabled();if(r==="all")n.multiply(this.getTransform());else if(r==="position"){const i=this.attrs.x||0,o=this.attrs.y||0,a=this.attrs.offsetX||0,d=this.attrs.offsetY||0;n.translate(i-a,o-d)}return n.dirty=!1,n}getAbsoluteScale(e){for(var n=this;n;)n._isUnderCache&&(e=n),n=n.getParent();const i=this.getAbsoluteTransform(e).decompose();return{x:i.scaleX,y:i.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(TRANSFORM,this._getTransform)}_getTransform(){var e,n,r=this._cache.get(TRANSFORM)||new Transform;r.reset();var i=this.x(),o=this.y(),a=Konva$2.getAngle(this.rotation()),d=(e=this.attrs.scaleX)!==null&&e!==void 0?e:1,f=(n=this.attrs.scaleY)!==null&&n!==void 0?n:1,h=this.attrs.skewX||0,p=this.attrs.skewY||0,s=this.attrs.offsetX||0,t=this.attrs.offsetY||0;return(i!==0||o!==0)&&r.translate(i,o),a!==0&&r.rotate(a),(h!==0||p!==0)&&r.skew(h,p),(d!==1||f!==1)&&r.scale(d,f),(s!==0||t!==0)&&r.translate(-1*s,-1*t),r.dirty=!1,r}clone(e){var n=Util.cloneObject(this.attrs),r,i,o,a,d;for(r in e)n[r]=e[r];var f=new this.constructor(n);for(r in this.eventListeners)for(i=this.eventListeners[r],o=i.length,a=0;a<o;a++)d=i[a],d.name.indexOf(KONVA)<0&&(f.eventListeners[r]||(f.eventListeners[r]=[]),f.eventListeners[r].push(d));return f}_toKonvaCanvas(e){e=e||{};var n=this.getClientRect(),r=this.getStage(),i=e.x!==void 0?e.x:Math.floor(n.x),o=e.y!==void 0?e.y:Math.floor(n.y),a=e.pixelRatio||1,d=new SceneCanvas({width:e.width||Math.ceil(n.width)||(r?r.width():0),height:e.height||Math.ceil(n.height)||(r?r.height():0),pixelRatio:a}),f=d.getContext();return e.imageSmoothingEnabled===!1&&(f._context.imageSmoothingEnabled=!1),f.save(),(i||o)&&f.translate(-1*i,-1*o),this.drawScene(d),f.restore(),d}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){e=e||{};var n=e.mimeType||null,r=e.quality||null,i=this._toKonvaCanvas(e).toDataURL(n,r);return e.callback&&e.callback(i),i}toImage(e){return new Promise((n,r)=>{try{const i=e==null?void 0:e.callback;i&&delete e.callback,Util._urlToImage(this.toDataURL(e),function(o){n(o),i==null||i(o)})}catch(i){r(i)}})}toBlob(e){return new Promise((n,r)=>{try{const i=e==null?void 0:e.callback;i&&delete e.callback,this.toCanvas(e).toBlob(o=>{n(o),i==null||i(o)})}catch(i){r(i)}})}setSize(e){return this.width(e.width),this.height(e.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance!==void 0?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():Konva$2.dragDistance}_off(e,n,r){var i=this.eventListeners[e],o,a,d;for(o=0;o<i.length;o++)if(a=i[o].name,d=i[o].handler,(a!=="konva"||n==="konva")&&(!n||a===n)&&(!r||r===d)){if(i.splice(o,1),i.length===0){delete this.eventListeners[e];break}o--}}_fireChangeEvent(e,n,r){this._fire(e+CHANGE,{oldVal:n,newVal:r})}addName(e){if(!this.hasName(e)){var n=this.name(),r=n?n+" "+e:e;this.name(r)}return this}hasName(e){if(!e)return!1;const n=this.name();if(!n)return!1;var r=(n||"").split(/\s/g);return r.indexOf(e)!==-1}removeName(e){var n=(this.name()||"").split(/\s/g),r=n.indexOf(e);return r!==-1&&(n.splice(r,1),this.name(n.join(" "))),this}setAttr(e,n){var r=this[SET+Util._capitalize(e)];return Util._isFunction(r)?r.call(this,n):this._setAttr(e,n),this}_requestDraw(){if(Konva$2.autoDrawEnabled){const e=this.getLayer()||this.getStage();e==null||e.batchDraw()}}_setAttr(e,n){var r=this.attrs[e];r===n&&!Util.isObject(n)||(n==null?delete this.attrs[e]:this.attrs[e]=n,this._shouldFireChangeEvents&&this._fireChangeEvent(e,r,n),this._requestDraw())}_setComponentAttr(e,n,r){var i;r!==void 0&&(i=this.attrs[e],i||(this.attrs[e]=this.getAttr(e)),this.attrs[e][n]=r,this._fireChangeEvent(e,i,r))}_fireAndBubble(e,n,r){n&&this.nodeType===SHAPE&&(n.target=this);var i=(e===MOUSEENTER$1||e===MOUSELEAVE$1)&&(r&&(this===r||this.isAncestorOf&&this.isAncestorOf(r))||this.nodeType==="Stage"&&!r);if(!i){this._fire(e,n);var o=(e===MOUSEENTER$1||e===MOUSELEAVE$1)&&r&&r.isAncestorOf&&r.isAncestorOf(this)&&!r.isAncestorOf(this.parent);(n&&!n.cancelBubble||!n)&&this.parent&&this.parent.isListening()&&!o&&(r&&r.parent?this._fireAndBubble.call(this.parent,e,n,r):this._fireAndBubble.call(this.parent,e,n))}}_getProtoListeners(e){let n=this._cache.get(ALL_LISTENERS);if(!n){n={};let i=Object.getPrototypeOf(this);for(;i;){if(!i.eventListeners){i=Object.getPrototypeOf(i);continue}for(var r in i.eventListeners){const o=i.eventListeners[r],a=n[r]||[];n[r]=o.concat(a)}i=Object.getPrototypeOf(i)}this._cache.set(ALL_LISTENERS,n)}return n[e]}_fire(e,n){n=n||{},n.currentTarget=this,n.type=e;const r=this._getProtoListeners(e);if(r)for(var i=0;i<r.length;i++)r[i].handler.call(this,n);const o=this.eventListeners[e];if(o)for(var i=0;i<o.length;i++)o[i].handler.call(this,n)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(e){var n=e?e.pointerId:void 0,r=this.getStage(),i=this.getAbsolutePosition(),o=r._getPointerById(n)||r._changedPointerPositions[0]||i;DD._dragElements.set(this._id,{node:this,startPointerPos:o,offset:{x:o.x-i.x,y:o.y-i.y},dragStatus:"ready",pointerId:n})}startDrag(e,n=!0){DD._dragElements.has(this._id)||this._createDragElement(e);const r=DD._dragElements.get(this._id);r.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:e&&e.evt},n)}_setDragPosition(e,n){const r=this.getStage()._getPointerById(n.pointerId);if(r){var i={x:r.x-n.offset.x,y:r.y-n.offset.y},o=this.dragBoundFunc();if(o!==void 0){const a=o.call(this,i,e);a?i=a:Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}(!this._lastPos||this._lastPos.x!==i.x||this._lastPos.y!==i.y)&&(this.setAbsolutePosition(i),this._requestDraw()),this._lastPos=i}}stopDrag(e){const n=DD._dragElements.get(this._id);n&&(n.dragStatus="stopped"),DD._endDragBefore(e),DD._endDragAfter(e)}setDraggable(e){this._setAttr("draggable",e),this._dragChange()}isDragging(){const e=DD._dragElements.get(this._id);return e?e.dragStatus==="dragging":!1}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(e){var n=e.evt.button!==void 0,r=!n||Konva$2.dragButtons.indexOf(e.evt.button)>=0;if(r&&!this.isDragging()){var i=!1;DD._dragElements.forEach(o=>{this.isAncestorOf(o.node)&&(i=!0)}),i||this._createDragElement(e)}})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();var e=this.getStage();if(!e)return;const n=DD._dragElements.get(this._id),r=n&&n.dragStatus==="dragging",i=n&&n.dragStatus==="ready";r?this.stopDrag():i&&DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const n=this.getStage();if(!n)return!1;const r={x:-e.x,y:-e.y,width:n.width()+2*e.x,height:n.height()+2*e.y};return Util.haveIntersection(r,this.getClientRect())}static create(e,n){return Util._isString(e)&&(e=JSON.parse(e)),this._createNode(e,n)}static _createNode(e,n){var r=Node.prototype.getClassName.call(e),i=e.children,o,a,d;n&&(e.attrs.container=n),Konva$2[r]||(Util.warn('Can not find a node with class name "'+r+'". Fallback to "Shape".'),r="Shape");const f=Konva$2[r];if(o=new f(e.attrs),i)for(a=i.length,d=0;d<a;d++)o.add(Node._createNode(i[d]));return o}}Node.prototype.nodeType="Node";Node.prototype._attrsAffectingSize=[];Node.prototype.eventListeners={};Node.prototype.on.call(Node.prototype,TRANSFORM_CHANGE_STR$1,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM)});Node.prototype.on.call(Node.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(VISIBLE)});Node.prototype.on.call(Node.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(LISTENING)});Node.prototype.on.call(Node.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY)});const addGetterSetter=Factory.addGetterSetter;addGetterSetter(Node,"zIndex");addGetterSetter(Node,"absolutePosition");addGetterSetter(Node,"position");addGetterSetter(Node,"x",0,getNumberValidator());addGetterSetter(Node,"y",0,getNumberValidator());addGetterSetter(Node,"globalCompositeOperation","source-over",getStringValidator());addGetterSetter(Node,"opacity",1,getNumberValidator());addGetterSetter(Node,"name","",getStringValidator());addGetterSetter(Node,"id","",getStringValidator());addGetterSetter(Node,"rotation",0,getNumberValidator());Factory.addComponentsGetterSetter(Node,"scale",["x","y"]);addGetterSetter(Node,"scaleX",1,getNumberValidator());addGetterSetter(Node,"scaleY",1,getNumberValidator());Factory.addComponentsGetterSetter(Node,"skew",["x","y"]);addGetterSetter(Node,"skewX",0,getNumberValidator());addGetterSetter(Node,"skewY",0,getNumberValidator());Factory.addComponentsGetterSetter(Node,"offset",["x","y"]);addGetterSetter(Node,"offsetX",0,getNumberValidator());addGetterSetter(Node,"offsetY",0,getNumberValidator());addGetterSetter(Node,"dragDistance",null,getNumberValidator());addGetterSetter(Node,"width",0,getNumberValidator());addGetterSetter(Node,"height",0,getNumberValidator());addGetterSetter(Node,"listening",!0,getBooleanValidator());addGetterSetter(Node,"preventDefault",!0,getBooleanValidator());addGetterSetter(Node,"filters",null,function(c){return this._filterUpToDate=!1,c});addGetterSetter(Node,"visible",!0,getBooleanValidator());addGetterSetter(Node,"transformsEnabled","all",getStringValidator());addGetterSetter(Node,"size");addGetterSetter(Node,"dragBoundFunc");addGetterSetter(Node,"draggable",!1,getBooleanValidator());Factory.backCompat(Node,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});let Container$1=class extends Node{constructor(){super(...arguments),this.children=[]}getChildren(e){if(!e)return this.children||[];const n=this.children||[];var r=[];return n.forEach(function(i){e(i)&&r.push(i)}),r}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._requestDraw(),this}add(...e){if(e.length===0)return this;if(e.length>1){for(var n=0;n<e.length;n++)this.add(e[n]);return this}const r=e[0];return r.getParent()?(r.moveTo(this),this):(this._validateAdd(r),r.index=this.getChildren().length,r.parent=this,r._clearCaches(),this.getChildren().push(r),this._fire("add",{child:r}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){var n=this._generalFind(e,!0);return n.length>0?n[0]:void 0}_generalFind(e,n){var r=[];return this._descendants(i=>{const o=i._isMatch(e);return o&&r.push(i),!!(o&&n)}),r}_descendants(e){let n=!1;const r=this.getChildren();for(const i of r){if(n=e(i),n)return!0;if(i.hasChildren()&&(n=i._descendants(e),n))return!0}return!1}toObject(){var e=Node.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(n=>{e.children.push(n.toObject())}),e}isAncestorOf(e){for(var n=e.getParent();n;){if(n._id===this._id)return!0;n=n.getParent()}return!1}clone(e){var n=Node.prototype.clone.call(this,e);return this.getChildren().forEach(function(r){n.add(r.clone())}),n}getAllIntersections(e){var n=[];return this.find("Shape").forEach(function(r){r.isVisible()&&r.intersects(e)&&n.push(r)}),n}_clearSelfAndDescendantCache(e){var n;super._clearSelfAndDescendantCache(e),!this.isCached()&&((n=this.children)===null||n===void 0||n.forEach(function(r){r._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)===null||e===void 0||e.forEach(function(n,r){n.index=r}),this._requestDraw()}drawScene(e,n){var r=this.getLayer(),i=e||r&&r.getCanvas(),o=i&&i.getContext(),a=this._getCanvasCache(),d=a&&a.scene,f=i&&i.isCache;if(!this.isVisible()&&!f)return this;if(d){o.save();var h=this.getAbsoluteTransform(n).getMatrix();o.transform(h[0],h[1],h[2],h[3],h[4],h[5]),this._drawCachedSceneCanvas(o),o.restore()}else this._drawChildren("drawScene",i,n);return this}drawHit(e,n){if(!this.shouldDrawHit(n))return this;var r=this.getLayer(),i=e||r&&r.hitCanvas,o=i&&i.getContext(),a=this._getCanvasCache(),d=a&&a.hit;if(d){o.save();var f=this.getAbsoluteTransform(n).getMatrix();o.transform(f[0],f[1],f[2],f[3],f[4],f[5]),this._drawCachedHitCanvas(o),o.restore()}else this._drawChildren("drawHit",i,n);return this}_drawChildren(e,n,r){var i,o=n&&n.getContext(),a=this.clipWidth(),d=this.clipHeight(),f=this.clipFunc(),h=a&&d||f;const p=r===this;if(h){o.save();var s=this.getAbsoluteTransform(r),t=s.getMatrix();if(o.transform(t[0],t[1],t[2],t[3],t[4],t[5]),o.beginPath(),f)f.call(this,o,this);else{var l=this.clipX(),u=this.clipY();o.rect(l,u,a,d)}o.clip(),t=s.copy().invert().getMatrix(),o.transform(t[0],t[1],t[2],t[3],t[4],t[5])}var g=!p&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";g&&(o.save(),o._applyGlobalCompositeOperation(this)),(i=this.children)===null||i===void 0||i.forEach(function(m){m[e](n,r)}),g&&o.restore(),h&&o.restore()}getClientRect(e){var n;e=e||{};var r=e.skipTransform,i=e.relativeTo,o,a,d,f,h={x:1/0,y:1/0,width:0,height:0},p=this;(n=this.children)===null||n===void 0||n.forEach(function(g){if(g.visible()){var m=g.getClientRect({relativeTo:p,skipShadow:e.skipShadow,skipStroke:e.skipStroke});m.width===0&&m.height===0||(o===void 0?(o=m.x,a=m.y,d=m.x+m.width,f=m.y+m.height):(o=Math.min(o,m.x),a=Math.min(a,m.y),d=Math.max(d,m.x+m.width),f=Math.max(f,m.y+m.height)))}});for(var s=this.find("Shape"),t=!1,l=0;l<s.length;l++){var u=s[l];if(u._isVisible(this)){t=!0;break}}return t&&o!==void 0?h={x:o,y:a,width:d-o,height:f-a}:h={x:0,y:0,width:0,height:0},r?h:this._transformedRect(h,i)}};Factory.addComponentsGetterSetter(Container$1,"clip",["x","y","width","height"]);Factory.addGetterSetter(Container$1,"clipX",void 0,getNumberValidator());Factory.addGetterSetter(Container$1,"clipY",void 0,getNumberValidator());Factory.addGetterSetter(Container$1,"clipWidth",void 0,getNumberValidator());Factory.addGetterSetter(Container$1,"clipHeight",void 0,getNumberValidator());Factory.addGetterSetter(Container$1,"clipFunc");const Captures=new Map,SUPPORT_POINTER_EVENTS=Konva$2._global.PointerEvent!==void 0;function getCapturedShape(c){return Captures.get(c)}function createEvent(c){return{evt:c,pointerId:c.pointerId}}function hasPointerCapture(c,e){return Captures.get(c)===e}function setPointerCapture(c,e){releaseCapture(c),e.getStage()&&(Captures.set(c,e),SUPPORT_POINTER_EVENTS&&e._fire("gotpointercapture",createEvent(new PointerEvent("gotpointercapture"))))}function releaseCapture(c,e){const n=Captures.get(c);if(!n)return;const r=n.getStage();r&&r.content,Captures.delete(c),SUPPORT_POINTER_EVENTS&&n._fire("lostpointercapture",createEvent(new PointerEvent("lostpointercapture")))}var STAGE="Stage",STRING="string",PX="px",MOUSEOUT="mouseout",MOUSELEAVE="mouseleave",MOUSEOVER="mouseover",MOUSEENTER="mouseenter",MOUSEMOVE="mousemove",MOUSEDOWN="mousedown",MOUSEUP="mouseup",POINTERMOVE="pointermove",POINTERDOWN="pointerdown",POINTERUP="pointerup",POINTERCANCEL="pointercancel",LOSTPOINTERCAPTURE="lostpointercapture",POINTEROUT="pointerout",POINTERLEAVE="pointerleave",POINTEROVER="pointerover",POINTERENTER="pointerenter",CONTEXTMENU="contextmenu",TOUCHSTART="touchstart",TOUCHEND="touchend",TOUCHMOVE="touchmove",TOUCHCANCEL="touchcancel",WHEEL="wheel",MAX_LAYERS_NUMBER=5,EVENTS=[[MOUSEENTER,"_pointerenter"],[MOUSEDOWN,"_pointerdown"],[MOUSEMOVE,"_pointermove"],[MOUSEUP,"_pointerup"],[MOUSELEAVE,"_pointerleave"],[TOUCHSTART,"_pointerdown"],[TOUCHMOVE,"_pointermove"],[TOUCHEND,"_pointerup"],[TOUCHCANCEL,"_pointercancel"],[MOUSEOVER,"_pointerover"],[WHEEL,"_wheel"],[CONTEXTMENU,"_contextmenu"],[POINTERDOWN,"_pointerdown"],[POINTERMOVE,"_pointermove"],[POINTERUP,"_pointerup"],[POINTERCANCEL,"_pointercancel"],[LOSTPOINTERCAPTURE,"_lostpointercapture"]];const EVENTS_MAP={mouse:{[POINTEROUT]:MOUSEOUT,[POINTERLEAVE]:MOUSELEAVE,[POINTEROVER]:MOUSEOVER,[POINTERENTER]:MOUSEENTER,[POINTERMOVE]:MOUSEMOVE,[POINTERDOWN]:MOUSEDOWN,[POINTERUP]:MOUSEUP,[POINTERCANCEL]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[POINTEROUT]:"touchout",[POINTERLEAVE]:"touchleave",[POINTEROVER]:"touchover",[POINTERENTER]:"touchenter",[POINTERMOVE]:TOUCHMOVE,[POINTERDOWN]:TOUCHSTART,[POINTERUP]:TOUCHEND,[POINTERCANCEL]:TOUCHCANCEL,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[POINTEROUT]:POINTEROUT,[POINTERLEAVE]:POINTERLEAVE,[POINTEROVER]:POINTEROVER,[POINTERENTER]:POINTERENTER,[POINTERMOVE]:POINTERMOVE,[POINTERDOWN]:POINTERDOWN,[POINTERUP]:POINTERUP,[POINTERCANCEL]:POINTERCANCEL,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},getEventType=c=>c.indexOf("pointer")>=0?"pointer":c.indexOf("touch")>=0?"touch":"mouse",getEventsMap=c=>{const e=getEventType(c);if(e==="pointer")return Konva$2.pointerEventsEnabled&&EVENTS_MAP.pointer;if(e==="touch")return EVENTS_MAP.touch;if(e==="mouse")return EVENTS_MAP.mouse};function checkNoClip(c={}){return(c.clipFunc||c.clipWidth||c.clipHeight)&&Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),c}const NO_POINTERS_MESSAGE="Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);",stages=[];let Stage$1=class extends Container$1{constructor(e){super(checkNoClip(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{checkNoClip(this.attrs)}),this._checkVisibility()}_validateAdd(e){const n=e.getType()==="Layer",r=e.getType()==="FastLayer";n||r||Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const e=this.visible()?"":"none";this.content.style.display=e}setContainer(e){if(typeof e===STRING){if(e.charAt(0)==="."){var n=e.slice(1);e=document.getElementsByClassName(n)[0]}else{var r;e.charAt(0)!=="#"?r=e:r=e.slice(1),e=document.getElementById(r)}if(!e)throw"Can not find container in document with id "+r}return this._setAttr("container",e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){var e=this.children,n=e.length,r;for(r=0;r<n;r++)e[r].clear();return this}clone(e){return e||(e={}),e.container=typeof document<"u"&&document.createElement("div"),Container$1.prototype.clone.call(this,e)}destroy(){super.destroy();var e=this.content;e&&Util._isInDocument(e)&&this.container().removeChild(e);var n=stages.indexOf(this);return n>-1&&stages.splice(n,1),Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(Util.warn(NO_POINTERS_MESSAGE),null)}_getPointerById(e){return this._pointerPositions.find(n=>n.id===e)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){e=e||{},e.x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();var n=new SceneCanvas({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),r=n.getContext()._context,i=this.children;return(e.x||e.y)&&r.translate(-1*e.x,-1*e.y),i.forEach(function(o){if(o.isVisible()){var a=o._toKonvaCanvas(e);r.drawImage(a._canvas,e.x,e.y,a.getWidth()/a.getPixelRatio(),a.getHeight()/a.getPixelRatio())}}),n}getIntersection(e){if(!e)return null;var n=this.children,r=n.length,i=r-1,o;for(o=i;o>=0;o--){const a=n[o].getIntersection(e);if(a)return a}return null}_resizeDOM(){var e=this.width(),n=this.height();this.content&&(this.content.style.width=e+PX,this.content.style.height=n+PX),this.bufferCanvas.setSize(e,n),this.bufferHitCanvas.setSize(e,n),this.children.forEach(r=>{r.setSize({width:e,height:n}),r.draw()})}add(e,...n){if(arguments.length>1){for(var r=0;r<arguments.length;r++)this.add(arguments[r]);return this}super.add(e);var i=this.children.length;return i>MAX_LAYERS_NUMBER&&Util.warn("The stage has "+i+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),e.setSize({width:this.width(),height:this.height()}),e.draw(),Konva$2.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return hasPointerCapture(e,this)}setPointerCapture(e){setPointerCapture(e,this)}releaseCapture(e){releaseCapture(e)}getLayers(){return this.children}_bindContentEvents(){Konva$2.isBrowser&&EVENTS.forEach(([e,n])=>{this.content.addEventListener(e,r=>{this[n](r)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);const n=getEventsMap(e.type);this._fire(n.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const n=getEventsMap(e.type);this._fire(n.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let n=this[e+"targetShape"];return n&&!n.getStage()&&(n=null),n}_pointerleave(e){const n=getEventsMap(e.type),r=getEventType(e.type);if(n){this.setPointersPositions(e);var i=this._getTargetShape(r),o=!DD.isDragging||Konva$2.hitOnDragEnabled;i&&o?(i._fireAndBubble(n.pointerout,{evt:e}),i._fireAndBubble(n.pointerleave,{evt:e}),this._fire(n.pointerleave,{evt:e,target:this,currentTarget:this}),this[r+"targetShape"]=null):o&&(this._fire(n.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(n.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=void 0,this._pointerPositions=[]}}_pointerdown(e){const n=getEventsMap(e.type),r=getEventType(e.type);if(n){this.setPointersPositions(e);var i=!1;this._changedPointerPositions.forEach(o=>{var a=this.getIntersection(o);if(DD.justDragged=!1,Konva$2["_"+r+"ListenClick"]=!0,!(a&&a.isListening()))return;Konva$2.capturePointerEventsEnabled&&a.setPointerCapture(o.id),this[r+"ClickStartShape"]=a,a._fireAndBubble(n.pointerdown,{evt:e,pointerId:o.id}),i=!0;const f=e.type.indexOf("touch")>=0;a.preventDefault()&&e.cancelable&&f&&e.preventDefault()}),i||this._fire(n.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(e){const n=getEventsMap(e.type),r=getEventType(e.type);if(!n)return;DD.isDragging&&DD.node.preventDefault()&&e.cancelable&&e.preventDefault(),this.setPointersPositions(e);var i=!DD.isDragging||Konva$2.hitOnDragEnabled;if(!i)return;var o={};let a=!1;var d=this._getTargetShape(r);this._changedPointerPositions.forEach(f=>{const h=getCapturedShape(f.id)||this.getIntersection(f),p=f.id,s={evt:e,pointerId:p};var t=d!==h;if(t&&d&&(d._fireAndBubble(n.pointerout,Object.assign({},s),h),d._fireAndBubble(n.pointerleave,Object.assign({},s),h)),h){if(o[h._id])return;o[h._id]=!0}h&&h.isListening()?(a=!0,t&&(h._fireAndBubble(n.pointerover,Object.assign({},s),d),h._fireAndBubble(n.pointerenter,Object.assign({},s),d),this[r+"targetShape"]=h),h._fireAndBubble(n.pointermove,Object.assign({},s))):d&&(this._fire(n.pointerover,{evt:e,target:this,currentTarget:this,pointerId:p}),this[r+"targetShape"]=null)}),a||this._fire(n.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const n=getEventsMap(e.type),r=getEventType(e.type);if(!n)return;this.setPointersPositions(e);const i=this[r+"ClickStartShape"],o=this[r+"ClickEndShape"];var a={};let d=!1;this._changedPointerPositions.forEach(f=>{const h=getCapturedShape(f.id)||this.getIntersection(f);if(h){if(h.releaseCapture(f.id),a[h._id])return;a[h._id]=!0}const p=f.id,s={evt:e,pointerId:p};let t=!1;Konva$2["_"+r+"InDblClickWindow"]?(t=!0,clearTimeout(this[r+"DblTimeout"])):DD.justDragged||(Konva$2["_"+r+"InDblClickWindow"]=!0,clearTimeout(this[r+"DblTimeout"])),this[r+"DblTimeout"]=setTimeout(function(){Konva$2["_"+r+"InDblClickWindow"]=!1},Konva$2.dblClickWindow),h&&h.isListening()?(d=!0,this[r+"ClickEndShape"]=h,h._fireAndBubble(n.pointerup,Object.assign({},s)),Konva$2["_"+r+"ListenClick"]&&i&&i===h&&(h._fireAndBubble(n.pointerclick,Object.assign({},s)),t&&o&&o===h&&h._fireAndBubble(n.pointerdblclick,Object.assign({},s)))):(this[r+"ClickEndShape"]=null,Konva$2["_"+r+"ListenClick"]&&this._fire(n.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:p}),t&&this._fire(n.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:p}))}),d||this._fire(n.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),Konva$2["_"+r+"ListenClick"]=!1,e.cancelable&&r!=="touch"&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);var n=this.getIntersection(this.getPointerPosition());n&&n.isListening()?n._fireAndBubble(CONTEXTMENU,{evt:e}):this._fire(CONTEXTMENU,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);var n=this.getIntersection(this.getPointerPosition());n&&n.isListening()?n._fireAndBubble(WHEEL,{evt:e}):this._fire(WHEEL,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const n=getCapturedShape(e.pointerId)||this.getIntersection(this.getPointerPosition());n&&n._fireAndBubble(POINTERUP,createEvent(e)),releaseCapture(e.pointerId)}_lostpointercapture(e){releaseCapture(e.pointerId)}setPointersPositions(e){var n=this._getContentPosition(),r=null,i=null;e=e||window.event,e.touches!==void 0?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,o=>{this._pointerPositions.push({id:o.identifier,x:(o.clientX-n.left)/n.scaleX,y:(o.clientY-n.top)/n.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,o=>{this._changedPointerPositions.push({id:o.identifier,x:(o.clientX-n.left)/n.scaleX,y:(o.clientY-n.top)/n.scaleY})})):(r=(e.clientX-n.left)/n.scaleX,i=(e.clientY-n.top)/n.scaleY,this.pointerPos={x:r,y:i},this._pointerPositions=[{x:r,y:i,id:Util._getFirstPointerId(e)}],this._changedPointerPositions=[{x:r,y:i,id:Util._getFirstPointerId(e)}])}_setPointerPosition(e){Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};var e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!!Konva$2.isBrowser){var e=this.container();if(!e)throw"Stage has no container. A container is required.";e.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),e.appendChild(this.content),this._resizeDOM()}}cache(){return Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(e){e.batchDraw()}),this}};Stage$1.prototype.nodeType=STAGE;_registerNode(Stage$1);Factory.addGetterSetter(Stage$1,"container");var HAS_SHADOW="hasShadow",SHADOW_RGBA="shadowRGBA",patternImage="patternImage",linearGradient="linearGradient",radialGradient="radialGradient";let dummyContext$1;function getDummyContext$1(){return dummyContext$1||(dummyContext$1=Util.createCanvasElement().getContext("2d"),dummyContext$1)}const shapes={};function _fillFunc$2(c){c.fill()}function _strokeFunc$2(c){c.stroke()}function _fillFuncHit(c){c.fill()}function _strokeFuncHit(c){c.stroke()}function _clearHasShadowCache(){this._clearCache(HAS_SHADOW)}function _clearGetShadowRGBACache(){this._clearCache(SHADOW_RGBA)}function _clearFillPatternCache(){this._clearCache(patternImage)}function _clearLinearGradientCache(){this._clearCache(linearGradient)}function _clearRadialGradientCache(){this._clearCache(radialGradient)}let Shape$1=class extends Node{constructor(e){super(e);let n;for(;n=Util.getRandomColor(),!(n&&!(n in shapes)););this.colorKey=n,shapes[n]=this}getContext(){return Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return Util.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(HAS_SHADOW,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(patternImage,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){var e=getDummyContext$1();const n=e.createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(n&&n.setTransform){const r=new Transform;r.translate(this.fillPatternX(),this.fillPatternY()),r.rotate(Konva$2.getAngle(this.fillPatternRotation())),r.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),r.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const i=r.getMatrix(),o=typeof DOMMatrix>"u"?{a:i[0],b:i[1],c:i[2],d:i[3],e:i[4],f:i[5]}:new DOMMatrix(i);n.setTransform(o)}return n}}_getLinearGradient(){return this._getCache(linearGradient,this.__getLinearGradient)}__getLinearGradient(){var e=this.fillLinearGradientColorStops();if(e){for(var n=getDummyContext$1(),r=this.fillLinearGradientStartPoint(),i=this.fillLinearGradientEndPoint(),o=n.createLinearGradient(r.x,r.y,i.x,i.y),a=0;a<e.length;a+=2)o.addColorStop(e[a],e[a+1]);return o}}_getRadialGradient(){return this._getCache(radialGradient,this.__getRadialGradient)}__getRadialGradient(){var e=this.fillRadialGradientColorStops();if(e){for(var n=getDummyContext$1(),r=this.fillRadialGradientStartPoint(),i=this.fillRadialGradientEndPoint(),o=n.createRadialGradient(r.x,r.y,this.fillRadialGradientStartRadius(),i.x,i.y,this.fillRadialGradientEndRadius()),a=0;a<e.length;a+=2)o.addColorStop(e[a],e[a+1]);return o}}getShadowRGBA(){return this._getCache(SHADOW_RGBA,this._getShadowRGBA)}_getShadowRGBA(){if(this.hasShadow()){var e=Util.colorToRGBA(this.shadowColor());if(e)return"rgba("+e.r+","+e.g+","+e.b+","+e.a*(this.shadowOpacity()||1)+")"}}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!!(this.stroke()||this.strokeLinearGradientColorStops()))}hasHitStroke(){const e=this.hitStrokeWidth();return e==="auto"?this.hasStroke():this.strokeEnabled()&&!!e}intersects(e){var n=this.getStage(),r=n.bufferHitCanvas,i;return r.getContext().clear(),this.drawHit(r,null,!0),i=r.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data,i[3]>0}destroy(){return Node.prototype.destroy.call(this),delete shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){var n;if(!this.getStage()||!((n=this.attrs.perfectDrawEnabled)!==null&&n!==void 0?n:!0))return!1;const i=e||this.hasFill(),o=this.hasStroke(),a=this.getAbsoluteOpacity()!==1;if(i&&o&&a)return!0;const d=this.hasShadow(),f=this.shadowForStrokeEnabled();return!!(i&&o&&d&&f)}setStrokeHitEnabled(e){Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),e?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){var e=this.size();return{x:this._centroid?-e.width/2:0,y:this._centroid?-e.height/2:0,width:e.width,height:e.height}}getClientRect(e={}){const n=e.skipTransform,r=e.relativeTo,i=this.getSelfRect(),a=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,d=i.width+a,f=i.height+a,h=!e.skipShadow&&this.hasShadow(),p=h?this.shadowOffsetX():0,s=h?this.shadowOffsetY():0,t=d+Math.abs(p),l=f+Math.abs(s),u=h&&this.shadowBlur()||0,g=t+u*2,m=l+u*2,_={width:g,height:m,x:-(a/2+u)+Math.min(p,0)+i.x,y:-(a/2+u)+Math.min(s,0)+i.y};return n?_:this._transformedRect(_,r)}drawScene(e,n){var r=this.getLayer(),i=e||r.getCanvas(),o=i.getContext(),a=this._getCanvasCache(),d=this.getSceneFunc(),f=this.hasShadow(),h,p,s,t=i.isCache,l=n===this;if(!this.isVisible()&&!l)return this;if(a){o.save();var u=this.getAbsoluteTransform(n).getMatrix();return o.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!d)return this;if(o.save(),this._useBufferCanvas()&&!t){h=this.getStage(),p=h.bufferCanvas,s=p.getContext(),s.clear(),s.save(),s._applyLineJoin(this);var g=this.getAbsoluteTransform(n).getMatrix();s.transform(g[0],g[1],g[2],g[3],g[4],g[5]),d.call(this,s,this),s.restore();var m=p.pixelRatio;f&&o._applyShadow(this),o._applyOpacity(this),o._applyGlobalCompositeOperation(this),o.drawImage(p._canvas,0,0,p.width/m,p.height/m)}else{if(o._applyLineJoin(this),!l){var g=this.getAbsoluteTransform(n).getMatrix();o.transform(g[0],g[1],g[2],g[3],g[4],g[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)}f&&o._applyShadow(this),d.call(this,o,this)}return o.restore(),this}drawHit(e,n,r=!1){if(!this.shouldDrawHit(n,r))return this;var i=this.getLayer(),o=e||i.hitCanvas,a=o&&o.getContext(),d=this.hitFunc()||this.sceneFunc(),f=this._getCanvasCache(),h=f&&f.hit;if(this.colorKey||Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),h){a.save();var p=this.getAbsoluteTransform(n).getMatrix();return a.transform(p[0],p[1],p[2],p[3],p[4],p[5]),this._drawCachedHitCanvas(a),a.restore(),this}if(!d)return this;if(a.save(),a._applyLineJoin(this),!(this===n)){var t=this.getAbsoluteTransform(n).getMatrix();a.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return d.call(this,a,this),a.restore(),this}drawHitFromCache(e=0){var n=this._getCanvasCache(),r=this._getCachedSceneCanvas(),i=n.hit,o=i.getContext(),a=i.getWidth(),d=i.getHeight(),f,h,p,s,t,l;o.clear(),o.drawImage(r._canvas,0,0,a,d);try{for(f=o.getImageData(0,0,a,d),h=f.data,p=h.length,s=Util._hexToRgb(this.colorKey),t=0;t<p;t+=4)l=h[t+3],l>e?(h[t]=s.r,h[t+1]=s.g,h[t+2]=s.b,h[t+3]=255):h[t+3]=0;o.putImageData(f,0,0)}catch(u){Util.error("Unable to draw hit graph from cached scene canvas. "+u.message)}return this}hasPointerCapture(e){return hasPointerCapture(e,this)}setPointerCapture(e){setPointerCapture(e,this)}releaseCapture(e){releaseCapture(e)}};Shape$1.prototype._fillFunc=_fillFunc$2;Shape$1.prototype._strokeFunc=_strokeFunc$2;Shape$1.prototype._fillFuncHit=_fillFuncHit;Shape$1.prototype._strokeFuncHit=_strokeFuncHit;Shape$1.prototype._centroid=!1;Shape$1.prototype.nodeType="Shape";_registerNode(Shape$1);Shape$1.prototype.eventListeners={};Shape$1.prototype.on.call(Shape$1.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",_clearHasShadowCache);Shape$1.prototype.on.call(Shape$1.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",_clearGetShadowRGBACache);Shape$1.prototype.on.call(Shape$1.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",_clearFillPatternCache);Shape$1.prototype.on.call(Shape$1.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",_clearLinearGradientCache);Shape$1.prototype.on.call(Shape$1.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",_clearRadialGradientCache);Factory.addGetterSetter(Shape$1,"stroke",void 0,getStringOrGradientValidator());Factory.addGetterSetter(Shape$1,"strokeWidth",2,getNumberValidator());Factory.addGetterSetter(Shape$1,"fillAfterStrokeEnabled",!1);Factory.addGetterSetter(Shape$1,"hitStrokeWidth","auto",getNumberOrAutoValidator());Factory.addGetterSetter(Shape$1,"strokeHitEnabled",!0,getBooleanValidator());Factory.addGetterSetter(Shape$1,"perfectDrawEnabled",!0,getBooleanValidator());Factory.addGetterSetter(Shape$1,"shadowForStrokeEnabled",!0,getBooleanValidator());Factory.addGetterSetter(Shape$1,"lineJoin");Factory.addGetterSetter(Shape$1,"lineCap");Factory.addGetterSetter(Shape$1,"sceneFunc");Factory.addGetterSetter(Shape$1,"hitFunc");Factory.addGetterSetter(Shape$1,"dash");Factory.addGetterSetter(Shape$1,"dashOffset",0,getNumberValidator());Factory.addGetterSetter(Shape$1,"shadowColor",void 0,getStringValidator());Factory.addGetterSetter(Shape$1,"shadowBlur",0,getNumberValidator());Factory.addGetterSetter(Shape$1,"shadowOpacity",1,getNumberValidator());Factory.addComponentsGetterSetter(Shape$1,"shadowOffset",["x","y"]);Factory.addGetterSetter(Shape$1,"shadowOffsetX",0,getNumberValidator());Factory.addGetterSetter(Shape$1,"shadowOffsetY",0,getNumberValidator());Factory.addGetterSetter(Shape$1,"fillPatternImage");Factory.addGetterSetter(Shape$1,"fill",void 0,getStringOrGradientValidator());Factory.addGetterSetter(Shape$1,"fillPatternX",0,getNumberValidator());Factory.addGetterSetter(Shape$1,"fillPatternY",0,getNumberValidator());Factory.addGetterSetter(Shape$1,"fillLinearGradientColorStops");Factory.addGetterSetter(Shape$1,"strokeLinearGradientColorStops");Factory.addGetterSetter(Shape$1,"fillRadialGradientStartRadius",0);Factory.addGetterSetter(Shape$1,"fillRadialGradientEndRadius",0);Factory.addGetterSetter(Shape$1,"fillRadialGradientColorStops");Factory.addGetterSetter(Shape$1,"fillPatternRepeat","repeat");Factory.addGetterSetter(Shape$1,"fillEnabled",!0);Factory.addGetterSetter(Shape$1,"strokeEnabled",!0);Factory.addGetterSetter(Shape$1,"shadowEnabled",!0);Factory.addGetterSetter(Shape$1,"dashEnabled",!0);Factory.addGetterSetter(Shape$1,"strokeScaleEnabled",!0);Factory.addGetterSetter(Shape$1,"fillPriority","color");Factory.addComponentsGetterSetter(Shape$1,"fillPatternOffset",["x","y"]);Factory.addGetterSetter(Shape$1,"fillPatternOffsetX",0,getNumberValidator());Factory.addGetterSetter(Shape$1,"fillPatternOffsetY",0,getNumberValidator());Factory.addComponentsGetterSetter(Shape$1,"fillPatternScale",["x","y"]);Factory.addGetterSetter(Shape$1,"fillPatternScaleX",1,getNumberValidator());Factory.addGetterSetter(Shape$1,"fillPatternScaleY",1,getNumberValidator());Factory.addComponentsGetterSetter(Shape$1,"fillLinearGradientStartPoint",["x","y"]);Factory.addComponentsGetterSetter(Shape$1,"strokeLinearGradientStartPoint",["x","y"]);Factory.addGetterSetter(Shape$1,"fillLinearGradientStartPointX",0);Factory.addGetterSetter(Shape$1,"strokeLinearGradientStartPointX",0);Factory.addGetterSetter(Shape$1,"fillLinearGradientStartPointY",0);Factory.addGetterSetter(Shape$1,"strokeLinearGradientStartPointY",0);Factory.addComponentsGetterSetter(Shape$1,"fillLinearGradientEndPoint",["x","y"]);Factory.addComponentsGetterSetter(Shape$1,"strokeLinearGradientEndPoint",["x","y"]);Factory.addGetterSetter(Shape$1,"fillLinearGradientEndPointX",0);Factory.addGetterSetter(Shape$1,"strokeLinearGradientEndPointX",0);Factory.addGetterSetter(Shape$1,"fillLinearGradientEndPointY",0);Factory.addGetterSetter(Shape$1,"strokeLinearGradientEndPointY",0);Factory.addComponentsGetterSetter(Shape$1,"fillRadialGradientStartPoint",["x","y"]);Factory.addGetterSetter(Shape$1,"fillRadialGradientStartPointX",0);Factory.addGetterSetter(Shape$1,"fillRadialGradientStartPointY",0);Factory.addComponentsGetterSetter(Shape$1,"fillRadialGradientEndPoint",["x","y"]);Factory.addGetterSetter(Shape$1,"fillRadialGradientEndPointX",0);Factory.addGetterSetter(Shape$1,"fillRadialGradientEndPointY",0);Factory.addGetterSetter(Shape$1,"fillPatternRotation",0);Factory.backCompat(Shape$1,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var HASH="#",BEFORE_DRAW="beforeDraw",DRAW="draw",INTERSECTION_OFFSETS=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],INTERSECTION_OFFSETS_LEN=INTERSECTION_OFFSETS.length;let Layer$1=class extends Container$1{constructor(e){super(e),this.canvas=new SceneCanvas,this.hitCanvas=new HitCanvas({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);var n=this.getStage();return n&&n.content&&(n.content.removeChild(this.getNativeCanvasElement()),e<n.children.length-1?n.content.insertBefore(this.getNativeCanvasElement(),n.children[e+1].getCanvas()._canvas):n.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){Node.prototype.moveToTop.call(this);var e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){var e=Node.prototype.moveUp.call(this);if(!e)return!1;var n=this.getStage();return!n||!n.content?!1:(n.content.removeChild(this.getNativeCanvasElement()),this.index<n.children.length-1?n.content.insertBefore(this.getNativeCanvasElement(),n.children[this.index+1].getCanvas()._canvas):n.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(Node.prototype.moveDown.call(this)){var e=this.getStage();if(e){var n=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),n[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(Node.prototype.moveToBottom.call(this)){var e=this.getStage();if(e){var n=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),n[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){var e=this.getNativeCanvasElement();return Node.prototype.remove.call(this),e&&e.parentNode&&Util._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:n}){return this.canvas.setSize(e,n),this.hitCanvas.setSize(e,n),this._setSmoothEnabled(),this}_validateAdd(e){var n=e.getType();n!=="Group"&&n!=="Shape"&&Util.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(e){return e=e||{},e.width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=e.x!==void 0?e.x:this.x(),e.y=e.y!==void 0?e.y:this.y(),Node.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){this.visible()?this.canvas._canvas.style.display="block":this.canvas._canvas.style.display="none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,Util.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;for(var n=1,r=!1;;){for(let i=0;i<INTERSECTION_OFFSETS_LEN;i++){const o=INTERSECTION_OFFSETS[i],a=this._getIntersection({x:e.x+o.x*n,y:e.y+o.y*n}),d=a.shape;if(d)return d;if(r=!!a.antialiased,!a.antialiased)break}if(r)n+=1;else return null}}_getIntersection(e){const n=this.hitCanvas.pixelRatio,r=this.hitCanvas.context.getImageData(Math.round(e.x*n),Math.round(e.y*n),1,1).data,i=r[3];if(i===255){const o=Util._rgbToHex(r[0],r[1],r[2]),a=shapes[HASH+o];return a?{shape:a}:{antialiased:!0}}else if(i>0)return{antialiased:!0};return{}}drawScene(e,n){var r=this.getLayer(),i=e||r&&r.getCanvas();return this._fire(BEFORE_DRAW,{node:this}),this.clearBeforeDraw()&&i.getContext().clear(),Container$1.prototype.drawScene.call(this,i,n),this._fire(DRAW,{node:this}),this}drawHit(e,n){var r=this.getLayer(),i=e||r&&r.hitCanvas;return r&&r.clearBeforeDraw()&&r.getHitCanvas().getContext().clear(),Container$1.prototype.drawHit.call(this,i,n),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!(!this.parent||!this.parent.content)){var e=this.parent,n=!!this.hitCanvas._canvas.parentNode;n?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}}destroy(){return Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};Layer$1.prototype.nodeType="Layer";_registerNode(Layer$1);Factory.addGetterSetter(Layer$1,"imageSmoothingEnabled",!0);Factory.addGetterSetter(Layer$1,"clearBeforeDraw",!0);Factory.addGetterSetter(Layer$1,"hitGraphEnabled",!0,getBooleanValidator());class FastLayer extends Layer$1{constructor(e){super(e),this.listening(!1),Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}FastLayer.prototype.nodeType="FastLayer";_registerNode(FastLayer);let Group$1=class extends Container$1{_validateAdd(e){var n=e.getType();n!=="Group"&&n!=="Shape"&&Util.throw("You may only add groups and shapes to groups.")}};Group$1.prototype.nodeType="Group";_registerNode(Group$1);var now=function(){return glob.performance&&glob.performance.now?function(){return glob.performance.now()}:function(){return new Date().getTime()}}();class Animation{constructor(e,n){this.id=Animation.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:now(),frameRate:0},this.func=e,this.setLayers(n)}setLayers(e){var n=[];return e?e.length>0?n=e:n=[e]:n=[],this.layers=n,this}getLayers(){return this.layers}addLayer(e){var n=this.layers,r=n.length,i;for(i=0;i<r;i++)if(n[i]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){var e=Animation,n=e.animations,r=n.length,i;for(i=0;i<r;i++)if(n[i].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=now(),Animation._addAnimation(this),this}stop(){return Animation._removeAnimation(this),this}_updateFrameObject(e){this.frame.timeDiff=e-this.frame.lastTime,this.frame.lastTime=e,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(e){this.animations.push(e),this._handleAnimation()}static _removeAnimation(e){var n=e.id,r=this.animations,i=r.length,o;for(o=0;o<i;o++)if(r[o].id===n){this.animations.splice(o,1);break}}static _runFrames(){var e={},n=this.animations,r,i,o,a,d,f,h,p,s;for(a=0;a<n.length;a++)if(r=n[a],i=r.layers,o=r.func,r._updateFrameObject(now()),f=i.length,o?s=o.call(r,r.frame)!==!1:s=!0,!!s)for(d=0;d<f;d++)h=i[d],h._id!==void 0&&(e[h._id]=h);for(p in e)e.hasOwnProperty(p)&&e[p].batchDraw()}static _animationLoop(){var e=Animation;e.animations.length?(e._runFrames(),Util.requestAnimFrame(e._animationLoop)):e.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Util.requestAnimFrame(this._animationLoop))}}Animation.animations=[];Animation.animIdCounter=0;Animation.animRunning=!1;var blacklist={node:1,duration:1,easing:1,onFinish:1,yoyo:1},PAUSED=1,PLAYING=2,REVERSING=3,idCounter=0,colorAttrs=["fill","stroke","shadowColor"];class TweenEngine{constructor(e,n,r,i,o,a,d){this.prop=e,this.propFunc=n,this.begin=i,this._pos=i,this.duration=a,this._change=0,this.prevPos=0,this.yoyo=d,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=r,this._change=o-this.begin,this.pause()}fire(e){var n=this[e];n&&n()}setTime(e){e>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return e===void 0&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=PLAYING,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=REVERSING,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(e){this.pause(),this._time=e,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){var e=this.getTimer()-this._startTime;this.state===PLAYING?this.setTime(e):this.state===REVERSING&&this.setTime(this.duration-e)}pause(){this.state=PAUSED,this.fire("onPause")}getTimer(){return new Date().getTime()}}class Tween{constructor(e){var n=this,r=e.node,i=r._id,o,a=e.easing||Easings.Linear,d=!!e.yoyo,f;typeof e.duration>"u"?o=.3:e.duration===0?o=.001:o=e.duration,this.node=r,this._id=idCounter++;var h=r.getLayer()||(r instanceof Konva$2.Stage?r.getLayers():null);h||Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new Animation(function(){n.tween.onEnterFrame()},h),this.tween=new TweenEngine(f,function(p){n._tweenFunc(p)},a,0,1,o*1e3,d),this._addListeners(),Tween.attrs[i]||(Tween.attrs[i]={}),Tween.attrs[i][this._id]||(Tween.attrs[i][this._id]={}),Tween.tweens[i]||(Tween.tweens[i]={});for(f in e)blacklist[f]===void 0&&this._addAttr(f,e[f]);this.reset(),this.onFinish=e.onFinish,this.onReset=e.onReset,this.onUpdate=e.onUpdate}_addAttr(e,n){var r=this.node,i=r._id,o,a,d,f,h,p,s,t;if(d=Tween.tweens[i][e],d&&delete Tween.attrs[i][d][e],o=r.getAttr(e),Util._isArray(n))if(a=[],h=Math.max(n.length,o.length),e==="points"&&n.length!==o.length&&(n.length>o.length?(s=o,o=Util._prepareArrayForTween(o,n,r.closed())):(p=n,n=Util._prepareArrayForTween(n,o,r.closed()))),e.indexOf("fill")===0)for(f=0;f<h;f++)if(f%2===0)a.push(n[f]-o[f]);else{var l=Util.colorToRGBA(o[f]);t=Util.colorToRGBA(n[f]),o[f]=l,a.push({r:t.r-l.r,g:t.g-l.g,b:t.b-l.b,a:t.a-l.a})}else for(f=0;f<h;f++)a.push(n[f]-o[f]);else colorAttrs.indexOf(e)!==-1?(o=Util.colorToRGBA(o),t=Util.colorToRGBA(n),a={r:t.r-o.r,g:t.g-o.g,b:t.b-o.b,a:t.a-o.a}):a=n-o;Tween.attrs[i][this._id][e]={start:o,diff:a,end:n,trueEnd:p,trueStart:s},Tween.tweens[i][e]=this._id}_tweenFunc(e){var n=this.node,r=Tween.attrs[n._id][this._id],i,o,a,d,f,h,p,s;for(i in r){if(o=r[i],a=o.start,d=o.diff,s=o.end,Util._isArray(a))if(f=[],p=Math.max(a.length,s.length),i.indexOf("fill")===0)for(h=0;h<p;h++)h%2===0?f.push((a[h]||0)+d[h]*e):f.push("rgba("+Math.round(a[h].r+d[h].r*e)+","+Math.round(a[h].g+d[h].g*e)+","+Math.round(a[h].b+d[h].b*e)+","+(a[h].a+d[h].a*e)+")");else for(h=0;h<p;h++)f.push((a[h]||0)+d[h]*e);else colorAttrs.indexOf(i)!==-1?f="rgba("+Math.round(a.r+d.r*e)+","+Math.round(a.g+d.g*e)+","+Math.round(a.b+d.b*e)+","+(a.a+d.a*e)+")":f=a+d*e;n.setAttr(i,f)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var e=this.node,n=Tween.attrs[e._id][this._id];n.points&&n.points.trueEnd&&e.setAttr("points",n.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var e=this.node,n=Tween.attrs[e._id][this._id];n.points&&n.points.trueStart&&e.points(n.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(e){return this.tween.seek(e*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var e=this.node._id,n=this._id,r=Tween.tweens[e],i;this.pause();for(i in r)delete Tween.tweens[e][i];delete Tween.attrs[e][n]}}Tween.attrs={};Tween.tweens={};Node.prototype.to=function(c){var e=c.onFinish;c.node=this,c.onFinish=function(){this.destroy(),e&&e()};var n=new Tween(c);n.play()};const Easings={BackEaseIn(c,e,n,r){var i=1.70158;return n*(c/=r)*c*((i+1)*c-i)+e},BackEaseOut(c,e,n,r){var i=1.70158;return n*((c=c/r-1)*c*((i+1)*c+i)+1)+e},BackEaseInOut(c,e,n,r){var i=1.70158;return(c/=r/2)<1?n/2*(c*c*(((i*=1.525)+1)*c-i))+e:n/2*((c-=2)*c*(((i*=1.525)+1)*c+i)+2)+e},ElasticEaseIn(c,e,n,r,i,o){var a=0;return c===0?e:(c/=r)===1?e+n:(o||(o=r*.3),!i||i<Math.abs(n)?(i=n,a=o/4):a=o/(2*Math.PI)*Math.asin(n/i),-(i*Math.pow(2,10*(c-=1))*Math.sin((c*r-a)*(2*Math.PI)/o))+e)},ElasticEaseOut(c,e,n,r,i,o){var a=0;return c===0?e:(c/=r)===1?e+n:(o||(o=r*.3),!i||i<Math.abs(n)?(i=n,a=o/4):a=o/(2*Math.PI)*Math.asin(n/i),i*Math.pow(2,-10*c)*Math.sin((c*r-a)*(2*Math.PI)/o)+n+e)},ElasticEaseInOut(c,e,n,r,i,o){var a=0;return c===0?e:(c/=r/2)===2?e+n:(o||(o=r*(.3*1.5)),!i||i<Math.abs(n)?(i=n,a=o/4):a=o/(2*Math.PI)*Math.asin(n/i),c<1?-.5*(i*Math.pow(2,10*(c-=1))*Math.sin((c*r-a)*(2*Math.PI)/o))+e:i*Math.pow(2,-10*(c-=1))*Math.sin((c*r-a)*(2*Math.PI)/o)*.5+n+e)},BounceEaseOut(c,e,n,r){return(c/=r)<1/2.75?n*(7.5625*c*c)+e:c<2/2.75?n*(7.5625*(c-=1.5/2.75)*c+.75)+e:c<2.5/2.75?n*(7.5625*(c-=2.25/2.75)*c+.9375)+e:n*(7.5625*(c-=2.625/2.75)*c+.984375)+e},BounceEaseIn(c,e,n,r){return n-Easings.BounceEaseOut(r-c,0,n,r)+e},BounceEaseInOut(c,e,n,r){return c<r/2?Easings.BounceEaseIn(c*2,0,n,r)*.5+e:Easings.BounceEaseOut(c*2-r,0,n,r)*.5+n*.5+e},EaseIn(c,e,n,r){return n*(c/=r)*c+e},EaseOut(c,e,n,r){return-n*(c/=r)*(c-2)+e},EaseInOut(c,e,n,r){return(c/=r/2)<1?n/2*c*c+e:-n/2*(--c*(c-2)-1)+e},StrongEaseIn(c,e,n,r){return n*(c/=r)*c*c*c*c+e},StrongEaseOut(c,e,n,r){return n*((c=c/r-1)*c*c*c*c+1)+e},StrongEaseInOut(c,e,n,r){return(c/=r/2)<1?n/2*c*c*c*c*c+e:n/2*((c-=2)*c*c*c*c+2)+e},Linear(c,e,n,r){return n*c/r+e}},Konva$1=Util._assign(Konva$2,{Util,Transform,Node,Container:Container$1,Stage:Stage$1,stages,Layer:Layer$1,FastLayer,Group:Group$1,DD,Shape:Shape$1,shapes,Animation,Tween,Easings,Context,Canvas});class Arc extends Shape$1{_sceneFunc(e){var n=Konva$2.getAngle(this.angle()),r=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,n,r),e.arc(0,0,this.innerRadius(),n,0,!r),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){const e=this.innerRadius(),n=this.outerRadius(),r=this.clockwise(),i=Konva$2.getAngle(r?360-this.angle():this.angle()),o=Math.cos(Math.min(i,Math.PI)),a=1,d=Math.sin(Math.min(Math.max(Math.PI,i),3*Math.PI/2)),f=Math.sin(Math.min(i,Math.PI/2)),h=o*(o>0?e:n),p=a*n,s=d*(d>0?e:n),t=f*(f>0?n:e);return{x:h,y:r?-1*t:s,width:p-h,height:t-s}}}Arc.prototype._centroid=!0;Arc.prototype.className="Arc";Arc.prototype._attrsAffectingSize=["innerRadius","outerRadius"];_registerNode(Arc);Factory.addGetterSetter(Arc,"innerRadius",0,getNumberValidator());Factory.addGetterSetter(Arc,"outerRadius",0,getNumberValidator());Factory.addGetterSetter(Arc,"angle",0,getNumberValidator());Factory.addGetterSetter(Arc,"clockwise",!1,getBooleanValidator());function getControlPoints(c,e,n,r,i,o,a){var d=Math.sqrt(Math.pow(n-c,2)+Math.pow(r-e,2)),f=Math.sqrt(Math.pow(i-n,2)+Math.pow(o-r,2)),h=a*d/(d+f),p=a*f/(d+f),s=n-h*(i-c),t=r-h*(o-e),l=n+p*(i-c),u=r+p*(o-e);return[s,t,l,u]}function expandPoints(c,e){var n=c.length,r=[],i,o;for(i=2;i<n-2;i+=2)o=getControlPoints(c[i-2],c[i-1],c[i],c[i+1],c[i+2],c[i+3],e),!isNaN(o[0])&&(r.push(o[0]),r.push(o[1]),r.push(c[i]),r.push(c[i+1]),r.push(o[2]),r.push(o[3]));return r}class Line extends Shape$1{constructor(e){super(e),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(e){var n=this.points(),r=n.length,i=this.tension(),o=this.closed(),a=this.bezier(),d,f,h;if(r){if(e.beginPath(),e.moveTo(n[0],n[1]),i!==0&&r>4){for(d=this.getTensionPoints(),f=d.length,h=o?0:4,o||e.quadraticCurveTo(d[0],d[1],d[2],d[3]);h<f-2;)e.bezierCurveTo(d[h++],d[h++],d[h++],d[h++],d[h++],d[h++]);o||e.quadraticCurveTo(d[f-2],d[f-1],n[r-2],n[r-1])}else if(a)for(h=2;h<r;)e.bezierCurveTo(n[h++],n[h++],n[h++],n[h++],n[h++],n[h++]);else for(h=2;h<r;h+=2)e.lineTo(n[h],n[h+1]);o?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():expandPoints(this.points(),this.tension())}_getTensionPointsClosed(){var e=this.points(),n=e.length,r=this.tension(),i=getControlPoints(e[n-2],e[n-1],e[0],e[1],e[2],e[3],r),o=getControlPoints(e[n-4],e[n-3],e[n-2],e[n-1],e[0],e[1],r),a=expandPoints(e,r),d=[i[2],i[3]].concat(a).concat([o[0],o[1],e[n-2],e[n-1],o[2],o[3],i[0],i[1],e[0],e[1]]);return d}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){var e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};this.tension()!==0?e=[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]]:e=this.points();for(var n=e[0],r=e[0],i=e[1],o=e[1],a,d,f=0;f<e.length/2;f++)a=e[f*2],d=e[f*2+1],n=Math.min(n,a),r=Math.max(r,a),i=Math.min(i,d),o=Math.max(o,d);return{x:n,y:i,width:r-n,height:o-i}}}Line.prototype.className="Line";Line.prototype._attrsAffectingSize=["points","bezier","tension"];_registerNode(Line);Factory.addGetterSetter(Line,"closed",!1);Factory.addGetterSetter(Line,"bezier",!1);Factory.addGetterSetter(Line,"tension",0,getNumberValidator());Factory.addGetterSetter(Line,"points",[],getNumberArrayValidator());let Path$1=class Me extends Shape$1{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this.dataArray=Me.parsePathData(this.data()),this.pathLength=0;for(var n=0;n<this.dataArray.length;++n)this.pathLength+=this.dataArray[n].pathLength;this.on("dataChange.konva",function(){this.dataArray=Me.parsePathData(this.data()),this.pathLength=0;for(var r=0;r<this.dataArray.length;++r)this.pathLength+=this.dataArray[r].pathLength})}_sceneFunc(e){var n=this.dataArray;e.beginPath();for(var r=!1,i=0;i<n.length;i++){var o=n[i].command,a=n[i].points;switch(o){case"L":e.lineTo(a[0],a[1]);break;case"M":e.moveTo(a[0],a[1]);break;case"C":e.bezierCurveTo(a[0],a[1],a[2],a[3],a[4],a[5]);break;case"Q":e.quadraticCurveTo(a[0],a[1],a[2],a[3]);break;case"A":var d=a[0],f=a[1],h=a[2],p=a[3],s=a[4],t=a[5],l=a[6],u=a[7],g=h>p?h:p,m=h>p?1:h/p,_=h>p?p/h:1;e.translate(d,f),e.rotate(l),e.scale(m,_),e.arc(0,0,g,s,s+t,1-u),e.scale(1/m,1/_),e.rotate(-l),e.translate(-d,-f);break;case"z":r=!0,e.closePath();break}}!r&&!this.hasFill()?e.strokeShape(this):e.fillStrokeShape(this)}getSelfRect(){var e=[];this.dataArray.forEach(function(h){if(h.command==="A"){var p=h.points[4],s=h.points[5],t=h.points[4]+s,l=Math.PI/180;if(Math.abs(p-t)<l&&(l=Math.abs(p-t)),s<0)for(let u=p-l;u>t;u-=l){const g=Me.getPointOnEllipticalArc(h.points[0],h.points[1],h.points[2],h.points[3],u,0);e.push(g.x,g.y)}else for(let u=p+l;u<t;u+=l){const g=Me.getPointOnEllipticalArc(h.points[0],h.points[1],h.points[2],h.points[3],u,0);e.push(g.x,g.y)}}else if(h.command==="C")for(let u=0;u<=1;u+=.01){const g=Me.getPointOnCubicBezier(u,h.start.x,h.start.y,h.points[0],h.points[1],h.points[2],h.points[3],h.points[4],h.points[5]);e.push(g.x,g.y)}else e=e.concat(h.points)});for(var n=e[0],r=e[0],i=e[1],o=e[1],a,d,f=0;f<e.length/2;f++)a=e[f*2],d=e[f*2+1],isNaN(a)||(n=Math.min(n,a),r=Math.max(r,a)),isNaN(d)||(i=Math.min(i,d),o=Math.max(o,d));return{x:n,y:i,width:r-n,height:o-i}}getLength(){return this.pathLength}getPointAtLength(e){var n,r=0,i=this.dataArray.length;if(!i)return null;for(;r<i&&e>this.dataArray[r].pathLength;)e-=this.dataArray[r].pathLength,++r;if(r===i)return n=this.dataArray[r-1].points.slice(-2),{x:n[0],y:n[1]};if(e<.01)return n=this.dataArray[r].points.slice(0,2),{x:n[0],y:n[1]};var o=this.dataArray[r],a=o.points;switch(o.command){case"L":return Me.getPointOnLine(e,o.start.x,o.start.y,a[0],a[1]);case"C":return Me.getPointOnCubicBezier(e/o.pathLength,o.start.x,o.start.y,a[0],a[1],a[2],a[3],a[4],a[5]);case"Q":return Me.getPointOnQuadraticBezier(e/o.pathLength,o.start.x,o.start.y,a[0],a[1],a[2],a[3]);case"A":var d=a[0],f=a[1],h=a[2],p=a[3],s=a[4],t=a[5],l=a[6];return s+=t*e/o.pathLength,Me.getPointOnEllipticalArc(d,f,h,p,s,l)}return null}static getLineLength(e,n,r,i){return Math.sqrt((r-e)*(r-e)+(i-n)*(i-n))}static getPointOnLine(e,n,r,i,o,a,d){a===void 0&&(a=n),d===void 0&&(d=r);var f=(o-r)/(i-n+1e-8),h=Math.sqrt(e*e/(1+f*f));i<n&&(h*=-1);var p=f*h,s;if(i===n)s={x:a,y:d+p};else if((d-r)/(a-n+1e-8)===f)s={x:a+h,y:d+p};else{var t,l,u=this.getLineLength(n,r,i,o),g=(a-n)*(i-n)+(d-r)*(o-r);g=g/(u*u),t=n+g*(i-n),l=r+g*(o-r);var m=this.getLineLength(a,d,t,l),_=Math.sqrt(e*e-m*m);h=Math.sqrt(_*_/(1+f*f)),i<n&&(h*=-1),p=f*h,s={x:t+h,y:l+p}}return s}static getPointOnCubicBezier(e,n,r,i,o,a,d,f,h){function p(m){return m*m*m}function s(m){return 3*m*m*(1-m)}function t(m){return 3*m*(1-m)*(1-m)}function l(m){return(1-m)*(1-m)*(1-m)}var u=f*p(e)+a*s(e)+i*t(e)+n*l(e),g=h*p(e)+d*s(e)+o*t(e)+r*l(e);return{x:u,y:g}}static getPointOnQuadraticBezier(e,n,r,i,o,a,d){function f(l){return l*l}function h(l){return 2*l*(1-l)}function p(l){return(1-l)*(1-l)}var s=a*f(e)+i*h(e)+n*p(e),t=d*f(e)+o*h(e)+r*p(e);return{x:s,y:t}}static getPointOnEllipticalArc(e,n,r,i,o,a){var d=Math.cos(a),f=Math.sin(a),h={x:r*Math.cos(o),y:i*Math.sin(o)};return{x:e+(h.x*d-h.y*f),y:n+(h.x*f+h.y*d)}}static parsePathData(e){if(!e)return[];var n=e,r=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];n=n.replace(new RegExp(" ","g"),",");for(var i=0;i<r.length;i++)n=n.replace(new RegExp(r[i],"g"),"|"+r[i]);var o=n.split("|"),a=[],d=[],f=0,h=0,p=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,s;for(i=1;i<o.length;i++){var t=o[i],l=t.charAt(0);for(t=t.slice(1),d.length=0;s=p.exec(t);)d.push(s[0]);for(var u=[],g=0,m=d.length;g<m;g++){if(d[g]==="00"){u.push(0,0);continue}var _=parseFloat(d[g]);isNaN(_)?u.push(0):u.push(_)}for(;u.length>0&&!isNaN(u[0]);){var b=null,y=[],v=f,T=h,w,S,x,P,I,N,L,E,M,k;switch(l){case"l":f+=u.shift(),h+=u.shift(),b="L",y.push(f,h);break;case"L":f=u.shift(),h=u.shift(),y.push(f,h);break;case"m":var A=u.shift(),R=u.shift();if(f+=A,h+=R,b="M",a.length>2&&a[a.length-1].command==="z"){for(var K=a.length-2;K>=0;K--)if(a[K].command==="M"){f=a[K].points[0]+A,h=a[K].points[1]+R;break}}y.push(f,h),l="l";break;case"M":f=u.shift(),h=u.shift(),b="M",y.push(f,h),l="L";break;case"h":f+=u.shift(),b="L",y.push(f,h);break;case"H":f=u.shift(),b="L",y.push(f,h);break;case"v":h+=u.shift(),b="L",y.push(f,h);break;case"V":h=u.shift(),b="L",y.push(f,h);break;case"C":y.push(u.shift(),u.shift(),u.shift(),u.shift()),f=u.shift(),h=u.shift(),y.push(f,h);break;case"c":y.push(f+u.shift(),h+u.shift(),f+u.shift(),h+u.shift()),f+=u.shift(),h+=u.shift(),b="C",y.push(f,h);break;case"S":S=f,x=h,w=a[a.length-1],w.command==="C"&&(S=f+(f-w.points[2]),x=h+(h-w.points[3])),y.push(S,x,u.shift(),u.shift()),f=u.shift(),h=u.shift(),b="C",y.push(f,h);break;case"s":S=f,x=h,w=a[a.length-1],w.command==="C"&&(S=f+(f-w.points[2]),x=h+(h-w.points[3])),y.push(S,x,f+u.shift(),h+u.shift()),f+=u.shift(),h+=u.shift(),b="C",y.push(f,h);break;case"Q":y.push(u.shift(),u.shift()),f=u.shift(),h=u.shift(),y.push(f,h);break;case"q":y.push(f+u.shift(),h+u.shift()),f+=u.shift(),h+=u.shift(),b="Q",y.push(f,h);break;case"T":S=f,x=h,w=a[a.length-1],w.command==="Q"&&(S=f+(f-w.points[0]),x=h+(h-w.points[1])),f=u.shift(),h=u.shift(),b="Q",y.push(S,x,f,h);break;case"t":S=f,x=h,w=a[a.length-1],w.command==="Q"&&(S=f+(f-w.points[0]),x=h+(h-w.points[1])),f+=u.shift(),h+=u.shift(),b="Q",y.push(S,x,f,h);break;case"A":P=u.shift(),I=u.shift(),N=u.shift(),L=u.shift(),E=u.shift(),M=f,k=h,f=u.shift(),h=u.shift(),b="A",y=this.convertEndpointToCenterParameterization(M,k,f,h,L,E,P,I,N);break;case"a":P=u.shift(),I=u.shift(),N=u.shift(),L=u.shift(),E=u.shift(),M=f,k=h,f+=u.shift(),h+=u.shift(),b="A",y=this.convertEndpointToCenterParameterization(M,k,f,h,L,E,P,I,N);break}a.push({command:b||l,points:y,start:{x:v,y:T},pathLength:this.calcLength(v,T,b||l,y)})}(l==="z"||l==="Z")&&a.push({command:"z",points:[],start:void 0,pathLength:0})}return a}static calcLength(e,n,r,i){var o,a,d,f,h=Me;switch(r){case"L":return h.getLineLength(e,n,i[0],i[1]);case"C":for(o=0,a=h.getPointOnCubicBezier(0,e,n,i[0],i[1],i[2],i[3],i[4],i[5]),f=.01;f<=1;f+=.01)d=h.getPointOnCubicBezier(f,e,n,i[0],i[1],i[2],i[3],i[4],i[5]),o+=h.getLineLength(a.x,a.y,d.x,d.y),a=d;return o;case"Q":for(o=0,a=h.getPointOnQuadraticBezier(0,e,n,i[0],i[1],i[2],i[3]),f=.01;f<=1;f+=.01)d=h.getPointOnQuadraticBezier(f,e,n,i[0],i[1],i[2],i[3]),o+=h.getLineLength(a.x,a.y,d.x,d.y),a=d;return o;case"A":o=0;var p=i[4],s=i[5],t=i[4]+s,l=Math.PI/180;if(Math.abs(p-t)<l&&(l=Math.abs(p-t)),a=h.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],p,0),s<0)for(f=p-l;f>t;f-=l)d=h.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],f,0),o+=h.getLineLength(a.x,a.y,d.x,d.y),a=d;else for(f=p+l;f<t;f+=l)d=h.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],f,0),o+=h.getLineLength(a.x,a.y,d.x,d.y),a=d;return d=h.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],t,0),o+=h.getLineLength(a.x,a.y,d.x,d.y),o}return 0}static convertEndpointToCenterParameterization(e,n,r,i,o,a,d,f,h){var p=h*(Math.PI/180),s=Math.cos(p)*(e-r)/2+Math.sin(p)*(n-i)/2,t=-1*Math.sin(p)*(e-r)/2+Math.cos(p)*(n-i)/2,l=s*s/(d*d)+t*t/(f*f);l>1&&(d*=Math.sqrt(l),f*=Math.sqrt(l));var u=Math.sqrt((d*d*(f*f)-d*d*(t*t)-f*f*(s*s))/(d*d*(t*t)+f*f*(s*s)));o===a&&(u*=-1),isNaN(u)&&(u=0);var g=u*d*t/f,m=u*-f*s/d,_=(e+r)/2+Math.cos(p)*g-Math.sin(p)*m,b=(n+i)/2+Math.sin(p)*g+Math.cos(p)*m,y=function(I){return Math.sqrt(I[0]*I[0]+I[1]*I[1])},v=function(I,N){return(I[0]*N[0]+I[1]*N[1])/(y(I)*y(N))},T=function(I,N){return(I[0]*N[1]<I[1]*N[0]?-1:1)*Math.acos(v(I,N))},w=T([1,0],[(s-g)/d,(t-m)/f]),S=[(s-g)/d,(t-m)/f],x=[(-1*s-g)/d,(-1*t-m)/f],P=T(S,x);return v(S,x)<=-1&&(P=Math.PI),v(S,x)>=1&&(P=0),a===0&&P>0&&(P=P-2*Math.PI),a===1&&P<0&&(P=P+2*Math.PI),[_,b,d,f,w,P,p,a]}};Path$1.prototype.className="Path";Path$1.prototype._attrsAffectingSize=["data"];_registerNode(Path$1);Factory.addGetterSetter(Path$1,"data");class Arrow extends Line{_sceneFunc(e){super._sceneFunc(e);var n=Math.PI*2,r=this.points(),i=r,o=this.tension()!==0&&r.length>4;o&&(i=this.getTensionPoints());var a=this.pointerLength(),d=r.length,f,h;if(o){const t=[i[i.length-4],i[i.length-3],i[i.length-2],i[i.length-1],r[d-2],r[d-1]],l=Path$1.calcLength(i[i.length-4],i[i.length-3],"C",t),u=Path$1.getPointOnQuadraticBezier(Math.min(1,1-a/l),t[0],t[1],t[2],t[3],t[4],t[5]);f=r[d-2]-u.x,h=r[d-1]-u.y}else f=r[d-2]-r[d-4],h=r[d-1]-r[d-3];var p=(Math.atan2(h,f)+n)%n,s=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(r[d-2],r[d-1]),e.rotate(p),e.moveTo(0,0),e.lineTo(-a,s/2),e.lineTo(-a,-s/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(r[0],r[1]),o?(f=(i[0]+i[2])/2-r[0],h=(i[1]+i[3])/2-r[1]):(f=r[2]-r[0],h=r[3]-r[1]),e.rotate((Math.atan2(-h,-f)+n)%n),e.moveTo(0,0),e.lineTo(-a,s/2),e.lineTo(-a,-s/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){var n=this.dashEnabled();n&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),n&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),n=this.pointerWidth()/2;return{x:e.x-n,y:e.y-n,width:e.width+n*2,height:e.height+n*2}}}Arrow.prototype.className="Arrow";_registerNode(Arrow);Factory.addGetterSetter(Arrow,"pointerLength",10,getNumberValidator());Factory.addGetterSetter(Arrow,"pointerWidth",10,getNumberValidator());Factory.addGetterSetter(Arrow,"pointerAtBeginning",!1);Factory.addGetterSetter(Arrow,"pointerAtEnding",!0);let Circle$1=class extends Shape$1{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}};Circle$1.prototype._centroid=!0;Circle$1.prototype.className="Circle";Circle$1.prototype._attrsAffectingSize=["radius"];_registerNode(Circle$1);Factory.addGetterSetter(Circle$1,"radius",0,getNumberValidator());class Ellipse extends Shape$1{_sceneFunc(e){var n=this.radiusX(),r=this.radiusY();e.beginPath(),e.save(),n!==r&&e.scale(1,r/n),e.arc(0,0,n,0,Math.PI*2,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radiusX()*2}getHeight(){return this.radiusY()*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}}Ellipse.prototype.className="Ellipse";Ellipse.prototype._centroid=!0;Ellipse.prototype._attrsAffectingSize=["radiusX","radiusY"];_registerNode(Ellipse);Factory.addComponentsGetterSetter(Ellipse,"radius",["x","y"]);Factory.addGetterSetter(Ellipse,"radiusX",0,getNumberValidator());Factory.addGetterSetter(Ellipse,"radiusY",0,getNumberValidator());let Image$2=class zt extends Shape$1{constructor(e){super(e),this.on("imageChange.konva",()=>{this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const e=this.image();e&&e.complete||e&&e.readyState===4||e&&e.addEventListener&&e.addEventListener("load",()=>{this._requestDraw()})}_useBufferCanvas(){return super._useBufferCanvas(!0)}_sceneFunc(e){const n=this.getWidth(),r=this.getHeight(),i=this.cornerRadius(),o=this.attrs.image;let a;if(o){const d=this.attrs.cropWidth,f=this.attrs.cropHeight;d&&f?a=[o,this.cropX(),this.cropY(),d,f,0,0,n,r]:a=[o,0,0,n,r]}(this.hasFill()||this.hasStroke()||i)&&(e.beginPath(),i?Util.drawRoundedRectPath(e,n,r,i):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)),o&&(i&&e.clip(),e.drawImage.apply(e,a))}_hitFunc(e){var n=this.width(),r=this.height(),i=this.cornerRadius();e.beginPath(),i?Util.drawRoundedRectPath(e,n,r,i):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}getWidth(){var e,n;return(e=this.attrs.width)!==null&&e!==void 0?e:(n=this.image())===null||n===void 0?void 0:n.width}getHeight(){var e,n;return(e=this.attrs.height)!==null&&e!==void 0?e:(n=this.image())===null||n===void 0?void 0:n.height}static fromURL(e,n,r=null){var i=Util.createImageElement();i.onload=function(){var o=new zt({image:i});n(o)},i.onerror=r,i.crossOrigin="Anonymous",i.src=e}};Image$2.prototype.className="Image";_registerNode(Image$2);Factory.addGetterSetter(Image$2,"cornerRadius",0,getNumberOrArrayOfNumbersValidator(4));Factory.addGetterSetter(Image$2,"image");Factory.addComponentsGetterSetter(Image$2,"crop",["x","y","width","height"]);Factory.addGetterSetter(Image$2,"cropX",0,getNumberValidator());Factory.addGetterSetter(Image$2,"cropY",0,getNumberValidator());Factory.addGetterSetter(Image$2,"cropWidth",0,getNumberValidator());Factory.addGetterSetter(Image$2,"cropHeight",0,getNumberValidator());var ATTR_CHANGE_LIST$2=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],CHANGE_KONVA$1="Change.konva",NONE$1="none",UP="up",RIGHT$1="right",DOWN="down",LEFT$1="left",attrChangeListLen$1=ATTR_CHANGE_LIST$2.length;class Label extends Group$1{constructor(e){super(e),this.on("add.konva",function(n){this._addListeners(n.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){var n=this,r,i=function(){n._sync()};for(r=0;r<attrChangeListLen$1;r++)e.on(ATTR_CHANGE_LIST$2[r]+CHANGE_KONVA$1,i)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var e=this.getText(),n=this.getTag(),r,i,o,a,d,f,h;if(e&&n){switch(r=e.width(),i=e.height(),o=n.pointerDirection(),a=n.pointerWidth(),h=n.pointerHeight(),d=0,f=0,o){case UP:d=r/2,f=-1*h;break;case RIGHT$1:d=r+a,f=i/2;break;case DOWN:d=r/2,f=i+h;break;case LEFT$1:d=-1*a,f=i/2;break}n.setAttrs({x:-1*d,y:-1*f,width:r,height:i}),e.setAttrs({x:-1*d,y:-1*f})}}}Label.prototype.className="Label";_registerNode(Label);class Tag extends Shape$1{_sceneFunc(e){var n=this.width(),r=this.height(),i=this.pointerDirection(),o=this.pointerWidth(),a=this.pointerHeight(),d=this.cornerRadius();let f=0,h=0,p=0,s=0;typeof d=="number"?f=h=p=s=Math.min(d,n/2,r/2):(f=Math.min(d[0]||0,n/2,r/2),h=Math.min(d[1]||0,n/2,r/2),s=Math.min(d[2]||0,n/2,r/2),p=Math.min(d[3]||0,n/2,r/2)),e.beginPath(),e.moveTo(f,0),i===UP&&(e.lineTo((n-o)/2,0),e.lineTo(n/2,-1*a),e.lineTo((n+o)/2,0)),e.lineTo(n-h,0),e.arc(n-h,h,h,Math.PI*3/2,0,!1),i===RIGHT$1&&(e.lineTo(n,(r-a)/2),e.lineTo(n+o,r/2),e.lineTo(n,(r+a)/2)),e.lineTo(n,r-s),e.arc(n-s,r-s,s,0,Math.PI/2,!1),i===DOWN&&(e.lineTo((n+o)/2,r),e.lineTo(n/2,r+a),e.lineTo((n-o)/2,r)),e.lineTo(p,r),e.arc(p,r-p,p,Math.PI/2,Math.PI,!1),i===LEFT$1&&(e.lineTo(0,(r+a)/2),e.lineTo(-1*o,r/2),e.lineTo(0,(r-a)/2)),e.lineTo(0,f),e.arc(f,f,f,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){var e=0,n=0,r=this.pointerWidth(),i=this.pointerHeight(),o=this.pointerDirection(),a=this.width(),d=this.height();return o===UP?(n-=i,d+=i):o===DOWN?d+=i:o===LEFT$1?(e-=r*1.5,a+=r):o===RIGHT$1&&(a+=r*1.5),{x:e,y:n,width:a,height:d}}}Tag.prototype.className="Tag";_registerNode(Tag);Factory.addGetterSetter(Tag,"pointerDirection",NONE$1);Factory.addGetterSetter(Tag,"pointerWidth",0,getNumberValidator());Factory.addGetterSetter(Tag,"pointerHeight",0,getNumberValidator());Factory.addGetterSetter(Tag,"cornerRadius",0,getNumberOrArrayOfNumbersValidator(4));class Rect extends Shape$1{_sceneFunc(e){var n=this.cornerRadius(),r=this.width(),i=this.height();e.beginPath(),n?Util.drawRoundedRectPath(e,r,i,n):e.rect(0,0,r,i),e.closePath(),e.fillStrokeShape(this)}}Rect.prototype.className="Rect";_registerNode(Rect);Factory.addGetterSetter(Rect,"cornerRadius",0,getNumberOrArrayOfNumbersValidator(4));class RegularPolygon extends Shape$1{_sceneFunc(e){const n=this._getPoints();e.beginPath(),e.moveTo(n[0].x,n[0].y);for(var r=1;r<n.length;r++)e.lineTo(n[r].x,n[r].y);e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,n=this.attrs.radius||0,r=[];for(var i=0;i<e;i++)r.push({x:n*Math.sin(i*2*Math.PI/e),y:-1*n*Math.cos(i*2*Math.PI/e)});return r}getSelfRect(){const e=this._getPoints();var n=e[0].x,r=e[0].y,i=e[0].x,o=e[0].y;return e.forEach(a=>{n=Math.min(n,a.x),r=Math.max(r,a.x),i=Math.min(i,a.y),o=Math.max(o,a.y)}),{x:n,y:i,width:r-n,height:o-i}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}RegularPolygon.prototype.className="RegularPolygon";RegularPolygon.prototype._centroid=!0;RegularPolygon.prototype._attrsAffectingSize=["radius"];_registerNode(RegularPolygon);Factory.addGetterSetter(RegularPolygon,"radius",0,getNumberValidator());Factory.addGetterSetter(RegularPolygon,"sides",0,getNumberValidator());var PIx2=Math.PI*2;class Ring extends Shape$1{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,PIx2,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),PIx2,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}Ring.prototype.className="Ring";Ring.prototype._centroid=!0;Ring.prototype._attrsAffectingSize=["innerRadius","outerRadius"];_registerNode(Ring);Factory.addGetterSetter(Ring,"innerRadius",0,getNumberValidator());Factory.addGetterSetter(Ring,"outerRadius",0,getNumberValidator());class Sprite extends Shape$1{constructor(e){super(e),this._updated=!0,this.anim=new Animation(()=>{var n=this._updated;return this._updated=!1,n}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(e){var n=this.animation(),r=this.frameIndex(),i=r*4,o=this.animations()[n],a=this.frameOffsets(),d=o[i+0],f=o[i+1],h=o[i+2],p=o[i+3],s=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,h,p),e.closePath(),e.fillStrokeShape(this)),s)if(a){var t=a[n],l=r*2;e.drawImage(s,d,f,h,p,t[l+0],t[l+1],h,p)}else e.drawImage(s,d,f,h,p,0,0,h,p)}_hitFunc(e){var n=this.animation(),r=this.frameIndex(),i=r*4,o=this.animations()[n],a=this.frameOffsets(),d=o[i+2],f=o[i+3];if(e.beginPath(),a){var h=a[n],p=r*2;e.rect(h[p+0],h[p+1],d,f)}else e.rect(0,0,d,f);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){var e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(!this.isRunning()){var e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){var e=this.frameIndex(),n=this.animation(),r=this.animations(),i=r[n],o=i.length/4;e<o-1?this.frameIndex(e+1):this.frameIndex(0)}}Sprite.prototype.className="Sprite";_registerNode(Sprite);Factory.addGetterSetter(Sprite,"animation");Factory.addGetterSetter(Sprite,"animations");Factory.addGetterSetter(Sprite,"frameOffsets");Factory.addGetterSetter(Sprite,"image");Factory.addGetterSetter(Sprite,"frameIndex",0,getNumberValidator());Factory.addGetterSetter(Sprite,"frameRate",17,getNumberValidator());Factory.backCompat(Sprite,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class Star extends Shape$1{_sceneFunc(e){var n=this.innerRadius(),r=this.outerRadius(),i=this.numPoints();e.beginPath(),e.moveTo(0,0-r);for(var o=1;o<i*2;o++){var a=o%2===0?r:n,d=a*Math.sin(o*Math.PI/i),f=-1*a*Math.cos(o*Math.PI/i);e.lineTo(d,f)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}Star.prototype.className="Star";Star.prototype._centroid=!0;Star.prototype._attrsAffectingSize=["innerRadius","outerRadius"];_registerNode(Star);Factory.addGetterSetter(Star,"numPoints",5,getNumberValidator());Factory.addGetterSetter(Star,"innerRadius",0,getNumberValidator());Factory.addGetterSetter(Star,"outerRadius",0,getNumberValidator());function stringToArray(c){return Array.from(c)}var AUTO="auto",CENTER="center",JUSTIFY="justify",CHANGE_KONVA="Change.konva",CONTEXT_2D="2d",DASH="-",LEFT="left",TEXT="text",TEXT_UPPER="Text",TOP="top",BOTTOM="bottom",MIDDLE="middle",NORMAL$1="normal",PX_SPACE="px ",SPACE=" ",RIGHT="right",WORD="word",CHAR="char",NONE="none",ELLIPSIS="…",ATTR_CHANGE_LIST$1=["fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],attrChangeListLen=ATTR_CHANGE_LIST$1.length;function normalizeFontFamily(c){return c.split(",").map(e=>{e=e.trim();const n=e.indexOf(" ")>=0,r=e.indexOf('"')>=0||e.indexOf("'")>=0;return n&&!r&&(e=`"${e}"`),e}).join(", ")}var dummyContext;function getDummyContext(){return dummyContext||(dummyContext=Util.createCanvasElement().getContext(CONTEXT_2D),dummyContext)}function _fillFunc$1(c){c.fillText(this._partialText,this._partialTextX,this._partialTextY)}function _strokeFunc$1(c){c.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function checkDefaultFill(c){return c=c||{},!c.fillLinearGradientColorStops&&!c.fillRadialGradientColorStops&&!c.fillPatternImage&&(c.fill=c.fill||"black"),c}class Text extends Shape$1{constructor(e){super(checkDefaultFill(e)),this._partialTextX=0,this._partialTextY=0;for(var n=0;n<attrChangeListLen;n++)this.on(ATTR_CHANGE_LIST$1[n]+CHANGE_KONVA,this._setTextData);this._setTextData()}_sceneFunc(e){var n=this.textArr,r=n.length;if(this.text()){var i=this.padding(),o=this.fontSize(),a=this.lineHeight()*o,d=this.verticalAlign(),f=0,h=this.align(),p=this.getWidth(),s=this.letterSpacing(),t=this.fill(),l=this.textDecoration(),u=l.indexOf("underline")!==-1,g=l.indexOf("line-through")!==-1,m,_=0,_=a/2,b=0,y=0;for(e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",MIDDLE),e.setAttr("textAlign",LEFT),d===MIDDLE?f=(this.getHeight()-r*a-i*2)/2:d===BOTTOM&&(f=this.getHeight()-r*a-i*2),e.translate(i,f+i),m=0;m<r;m++){var b=0,y=0,v=n[m],T=v.text,w=v.width,S=v.lastInParagraph,x,P,I;if(e.save(),h===RIGHT?b+=p-w-i*2:h===CENTER&&(b+=(p-w-i*2)/2),u){e.save(),e.beginPath(),e.moveTo(b,_+y+Math.round(o/2)),x=T.split(" ").length-1,P=x===0,I=h===JUSTIFY&&!S?p-i*2:w,e.lineTo(b+Math.round(I),_+y+Math.round(o/2)),e.lineWidth=o/15;const A=this._getLinearGradient();e.strokeStyle=A||t,e.stroke(),e.restore()}if(g){e.save(),e.beginPath(),e.moveTo(b,_+y),x=T.split(" ").length-1,P=x===0,I=h===JUSTIFY&&S&&!P?p-i*2:w,e.lineTo(b+Math.round(I),_+y),e.lineWidth=o/15;const A=this._getLinearGradient();e.strokeStyle=A||t,e.stroke(),e.restore()}if(s!==0||h===JUSTIFY){x=T.split(" ").length-1;for(var N=stringToArray(T),L=0;L<N.length;L++){var E=N[L];E===" "&&!S&&h===JUSTIFY&&(b+=(p-i*2-w)/x),this._partialTextX=b,this._partialTextY=_+y,this._partialText=E,e.fillStrokeShape(this),b+=this.measureSize(E).width+s}}else this._partialTextX=b,this._partialTextY=_+y,this._partialText=T,e.fillStrokeShape(this);e.restore(),r>1&&(_+=a)}}}_hitFunc(e){var n=this.getWidth(),r=this.getHeight();e.beginPath(),e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}setText(e){var n=Util._isString(e)?e:e==null?"":e+"";return this._setAttr(TEXT,n),this}getWidth(){var e=this.attrs.width===AUTO||this.attrs.width===void 0;return e?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){var e=this.attrs.height===AUTO||this.attrs.height===void 0;return e?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(e){var n=getDummyContext(),r=this.fontSize(),i;return n.save(),n.font=this._getContextFont(),i=n.measureText(e),n.restore(),{width:i.width,height:r}}_getContextFont(){return this.fontStyle()+SPACE+this.fontVariant()+SPACE+(this.fontSize()+PX_SPACE)+normalizeFontFamily(this.fontFamily())}_addTextLine(e){this.align()===JUSTIFY&&(e=e.trim());var r=this._getTextWidth(e);return this.textArr.push({text:e,width:r,lastInParagraph:!1})}_getTextWidth(e){var n=this.letterSpacing(),r=e.length;return getDummyContext().measureText(e).width+(r?n*(r-1):0)}_setTextData(){var e=this.text().split(`
`),n=+this.fontSize(),r=0,i=this.lineHeight()*n,o=this.attrs.width,a=this.attrs.height,d=o!==AUTO&&o!==void 0,f=a!==AUTO&&a!==void 0,h=this.padding(),p=o-h*2,s=a-h*2,t=0,l=this.wrap(),u=l!==NONE,g=l!==CHAR&&u,m=this.ellipsis();this.textArr=[],getDummyContext().font=this._getContextFont();for(var _=m?this._getTextWidth(ELLIPSIS):0,b=0,y=e.length;b<y;++b){var v=e[b],T=this._getTextWidth(v);if(d&&T>p)for(;v.length>0;){for(var w=0,S=v.length,x="",P=0;w<S;){var I=w+S>>>1,N=v.slice(0,I+1),L=this._getTextWidth(N)+_;L<=p?(w=I+1,x=N,P=L):S=I}if(x){if(g){var E,M=v[x.length],k=M===SPACE||M===DASH;k&&P<=p?E=x.length:E=Math.max(x.lastIndexOf(SPACE),x.lastIndexOf(DASH))+1,E>0&&(w=E,x=x.slice(0,w),P=this._getTextWidth(x))}x=x.trimRight(),this._addTextLine(x),r=Math.max(r,P),t+=i;var A=this._shouldHandleEllipsis(t);if(A){this._tryToAddEllipsisToLastLine();break}if(v=v.slice(w),v=v.trimLeft(),v.length>0&&(T=this._getTextWidth(v),T<=p)){this._addTextLine(v),t+=i,r=Math.max(r,T);break}}else break}else this._addTextLine(v),t+=i,r=Math.max(r,T),this._shouldHandleEllipsis(t)&&b<y-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),f&&t+i>s)break}this.textHeight=n,this.textWidth=r}_shouldHandleEllipsis(e){var n=+this.fontSize(),r=this.lineHeight()*n,i=this.attrs.height,o=i!==AUTO&&i!==void 0,a=this.padding(),d=i-a*2,f=this.wrap(),h=f!==NONE;return!h||o&&e+r>d}_tryToAddEllipsisToLastLine(){var e=this.attrs.width,n=e!==AUTO&&e!==void 0,r=this.padding(),i=e-r*2,o=this.ellipsis(),a=this.textArr[this.textArr.length-1];if(!(!a||!o)){if(n){var d=this._getTextWidth(a.text+ELLIPSIS)<i;d||(a.text=a.text.slice(0,a.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(a.text+ELLIPSIS)}}getStrokeScaleEnabled(){return!0}}Text.prototype._fillFunc=_fillFunc$1;Text.prototype._strokeFunc=_strokeFunc$1;Text.prototype.className=TEXT_UPPER;Text.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"];_registerNode(Text);Factory.overWriteSetter(Text,"width",getNumberOrAutoValidator());Factory.overWriteSetter(Text,"height",getNumberOrAutoValidator());Factory.addGetterSetter(Text,"fontFamily","Arial");Factory.addGetterSetter(Text,"fontSize",12,getNumberValidator());Factory.addGetterSetter(Text,"fontStyle",NORMAL$1);Factory.addGetterSetter(Text,"fontVariant",NORMAL$1);Factory.addGetterSetter(Text,"padding",0,getNumberValidator());Factory.addGetterSetter(Text,"align",LEFT);Factory.addGetterSetter(Text,"verticalAlign",TOP);Factory.addGetterSetter(Text,"lineHeight",1,getNumberValidator());Factory.addGetterSetter(Text,"wrap",WORD);Factory.addGetterSetter(Text,"ellipsis",!1,getBooleanValidator());Factory.addGetterSetter(Text,"letterSpacing",0,getNumberValidator());Factory.addGetterSetter(Text,"text","",getStringValidator());Factory.addGetterSetter(Text,"textDecoration","");var EMPTY_STRING="",NORMAL="normal";function _fillFunc(c){c.fillText(this.partialText,0,0)}function _strokeFunc(c){c.strokeText(this.partialText,0,0)}class TextPath extends Shape$1{constructor(e){super(e),this.dummyCanvas=Util.createCanvasElement(),this.dataArray=[],this.dataArray=Path$1.parsePathData(this.attrs.data),this.on("dataChange.konva",function(){this.dataArray=Path$1.parsePathData(this.attrs.data),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();var n=this.textDecoration(),r=this.fill(),i=this.fontSize(),o=this.glyphInfo;n==="underline"&&e.beginPath();for(var a=0;a<o.length;a++){e.save();var d=o[a].p0;e.translate(d.x,d.y),e.rotate(o[a].rotation),this.partialText=o[a].text,e.fillStrokeShape(this),n==="underline"&&(a===0&&e.moveTo(0,i/2+1),e.lineTo(i,i/2+1)),e.restore()}n==="underline"&&(e.strokeStyle=r,e.lineWidth=i/20,e.stroke()),e.restore()}_hitFunc(e){e.beginPath();var n=this.glyphInfo;if(n.length>=1){var r=n[0].p0;e.moveTo(r.x,r.y)}for(var i=0;i<n.length;i++){var o=n[i].p1;e.lineTo(o.x,o.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return Text.prototype.setText.call(this,e)}_getContextFont(){return Text.prototype._getContextFont.call(this)}_getTextSize(e){var n=this.dummyCanvas,r=n.getContext("2d");r.save(),r.font=this._getContextFont();var i=r.measureText(e);return r.restore(),{width:i.width,height:parseInt(this.attrs.fontSize,10)}}_setTextData(){var e=this,n=this._getTextSize(this.attrs.text),r=this.letterSpacing(),i=this.align(),o=this.kerningFunc();this.textWidth=n.width,this.textHeight=n.height;var a=Math.max(this.textWidth+((this.attrs.text||"").length-1)*r,0);this.glyphInfo=[];for(var d=0,f=0;f<e.dataArray.length;f++)e.dataArray[f].pathLength>0&&(d+=e.dataArray[f].pathLength);var h=0;i==="center"&&(h=Math.max(0,d/2-a/2)),i==="right"&&(h=Math.max(0,d-a));for(var p=stringToArray(this.text()),s=this.text().split(" ").length-1,t,l,u,g=-1,m=0,_=function(){m=0;for(var L=e.dataArray,E=g+1;E<L.length;E++){if(L[E].pathLength>0)return g=E,L[E];L[E].command==="M"&&(t={x:L[E].points[0],y:L[E].points[1]})}return{}},b=function(L){var E=e._getTextSize(L).width+r;L===" "&&i==="justify"&&(E+=(d-a)/s);var M=0,k=0;for(l=void 0;Math.abs(E-M)/E>.01&&k<20;){k++;for(var A=M;u===void 0;)u=_(),u&&A+u.pathLength<E&&(A+=u.pathLength,u=void 0);if(Object.keys(u).length===0||t===void 0)return;var R=!1;switch(u.command){case"L":Path$1.getLineLength(t.x,t.y,u.points[0],u.points[1])>E?l=Path$1.getPointOnLine(E,t.x,t.y,u.points[0],u.points[1],t.x,t.y):u=void 0;break;case"A":var K=u.points[4],Z=u.points[5],J=u.points[4]+Z;m===0?m=K+1e-8:E>M?m+=Math.PI/180*Z/Math.abs(Z):m-=Math.PI/360*Z/Math.abs(Z),(Z<0&&m<J||Z>=0&&m>J)&&(m=J,R=!0),l=Path$1.getPointOnEllipticalArc(u.points[0],u.points[1],u.points[2],u.points[3],m,u.points[6]);break;case"C":m===0?E>u.pathLength?m=1e-8:m=E/u.pathLength:E>M?m+=(E-M)/u.pathLength/2:m=Math.max(m-(M-E)/u.pathLength/2,0),m>1&&(m=1,R=!0),l=Path$1.getPointOnCubicBezier(m,u.start.x,u.start.y,u.points[0],u.points[1],u.points[2],u.points[3],u.points[4],u.points[5]);break;case"Q":m===0?m=E/u.pathLength:E>M?m+=(E-M)/u.pathLength:m-=(M-E)/u.pathLength,m>1&&(m=1,R=!0),l=Path$1.getPointOnQuadraticBezier(m,u.start.x,u.start.y,u.points[0],u.points[1],u.points[2],u.points[3]);break}l!==void 0&&(M=Path$1.getLineLength(t.x,t.y,l.x,l.y)),R&&(R=!1,u=void 0)}},y="C",v=e._getTextSize(y).width+r,T=h/v-1,w=0;w<T&&(b(y),!(t===void 0||l===void 0));w++)t=l;for(var S=0;S<p.length&&(b(p[S]),!(t===void 0||l===void 0));S++){var x=Path$1.getLineLength(t.x,t.y,l.x,l.y),P=0;if(o)try{P=o(p[S-1],p[S])*this.fontSize()}catch{P=0}t.x+=P,l.x+=P,this.textWidth+=P;var I=Path$1.getPointOnLine(P+x/2,t.x,t.y,l.x,l.y),N=Math.atan2(l.y-t.y,l.x-t.x);this.glyphInfo.push({transposeX:I.x,transposeY:I.y,text:p[S],rotation:N,p0:t,p1:l}),t=l}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};var e=[];this.glyphInfo.forEach(function(p){e.push(p.p0.x),e.push(p.p0.y),e.push(p.p1.x),e.push(p.p1.y)});for(var n=e[0]||0,r=e[0]||0,i=e[1]||0,o=e[1]||0,a,d,f=0;f<e.length/2;f++)a=e[f*2],d=e[f*2+1],n=Math.min(n,a),r=Math.max(r,a),i=Math.min(i,d),o=Math.max(o,d);var h=this.fontSize();return{x:n-h/2,y:i-h/2,width:r-n+h,height:o-i+h}}destroy(){return Util.releaseCanvas(this.dummyCanvas),super.destroy()}}TextPath.prototype._fillFunc=_fillFunc;TextPath.prototype._strokeFunc=_strokeFunc;TextPath.prototype._fillFuncHit=_fillFunc;TextPath.prototype._strokeFuncHit=_strokeFunc;TextPath.prototype.className="TextPath";TextPath.prototype._attrsAffectingSize=["text","fontSize","data"];_registerNode(TextPath);Factory.addGetterSetter(TextPath,"data");Factory.addGetterSetter(TextPath,"fontFamily","Arial");Factory.addGetterSetter(TextPath,"fontSize",12,getNumberValidator());Factory.addGetterSetter(TextPath,"fontStyle",NORMAL);Factory.addGetterSetter(TextPath,"align","left");Factory.addGetterSetter(TextPath,"letterSpacing",0,getNumberValidator());Factory.addGetterSetter(TextPath,"textBaseline","middle");Factory.addGetterSetter(TextPath,"fontVariant",NORMAL);Factory.addGetterSetter(TextPath,"text",EMPTY_STRING);Factory.addGetterSetter(TextPath,"textDecoration",null);Factory.addGetterSetter(TextPath,"kerningFunc",null);var EVENTS_NAME="tr-konva",ATTR_CHANGE_LIST=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange"].map(c=>c+`.${EVENTS_NAME}`).join(" "),NODES_RECT="nodesRect",TRANSFORM_CHANGE_STR=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],ANGLES={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135};const TOUCH_DEVICE="ontouchstart"in Konva$2._global;function getCursor(c,e){if(c==="rotater")return"crosshair";e+=Util.degToRad(ANGLES[c]||0);var n=(Util.radToDeg(e)%360+360)%360;return Util._inRange(n,315+22.5,360)||Util._inRange(n,0,22.5)?"ns-resize":Util._inRange(n,45-22.5,45+22.5)?"nesw-resize":Util._inRange(n,90-22.5,90+22.5)?"ew-resize":Util._inRange(n,135-22.5,135+22.5)?"nwse-resize":Util._inRange(n,180-22.5,180+22.5)?"ns-resize":Util._inRange(n,225-22.5,225+22.5)?"nesw-resize":Util._inRange(n,270-22.5,270+22.5)?"ew-resize":Util._inRange(n,315-22.5,315+22.5)?"nwse-resize":(Util.error("Transformer has unknown angle for cursor detection: "+n),"pointer")}var ANCHORS_NAMES=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],MAX_SAFE_INTEGER=1e8;function getCenter(c){return{x:c.x+c.width/2*Math.cos(c.rotation)+c.height/2*Math.sin(-c.rotation),y:c.y+c.height/2*Math.cos(c.rotation)+c.width/2*Math.sin(c.rotation)}}function rotateAroundPoint(c,e,n){const r=n.x+(c.x-n.x)*Math.cos(e)-(c.y-n.y)*Math.sin(e),i=n.y+(c.x-n.x)*Math.sin(e)+(c.y-n.y)*Math.cos(e);return Object.assign(Object.assign({},c),{rotation:c.rotation+e,x:r,y:i})}function rotateAroundCenter(c,e){const n=getCenter(c);return rotateAroundPoint(c,e,n)}function getSnap(c,e,n){let r=e;for(let i=0;i<c.length;i++){const o=Konva$2.getAngle(c[i]),a=Math.abs(o-e)%(Math.PI*2);Math.min(a,Math.PI*2-a)<n&&(r=o)}return r}class Transformer extends Group$1{constructor(e){super(e),this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(ATTR_CHANGE_LIST,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return EVENTS_NAME+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const n=e.filter(i=>i.isAncestorOf(this)?(Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1):!0);this._nodes=e=n,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(i=>{const o=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()},a=i._attrsAffectingSize.map(d=>d+"Change."+this._getEventNamespace()).join(" ");i.on(a,o),i.on(TRANSFORM_CHANGE_STR.map(d=>d+`.${this._getEventNamespace()}`).join(" "),o),i.on(`absoluteTransformChange.${this._getEventNamespace()}`,o),this._proxyDrag(i)}),this._resetTransformCache();var r=!!this.findOne(".top-left");return r&&this.update(),this}_proxyDrag(e){let n;e.on(`dragstart.${this._getEventNamespace()}`,r=>{n=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back")&&this.startDrag(r,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,r=>{if(!n)return;const i=e.getAbsolutePosition(),o=i.x-n.x,a=i.y-n.y;this.nodes().forEach(d=>{if(d===e||d.isDragging())return;const f=d.getAbsolutePosition();d.setAbsolutePosition({x:f.x+o,y:f.y+a}),d.startDrag(r)}),n=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(e=>{e.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(NODES_RECT),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(NODES_RECT,this.__getNodeRect)}__getNodeShape(e,n=this.rotation(),r){var i=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),o=e.getAbsoluteScale(r),a=e.getAbsolutePosition(r),d=i.x*o.x-e.offsetX()*o.x,f=i.y*o.y-e.offsetY()*o.y;const h=(Konva$2.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2),p={x:a.x+d*Math.cos(h)+f*Math.sin(-h),y:a.y+f*Math.cos(h)+d*Math.sin(h),width:i.width*o.x,height:i.height*o.y,rotation:h};return rotateAroundPoint(p,-Konva$2.getAngle(n),{x:0,y:0})}__getNodeRect(){var e=this.getNode();if(!e)return{x:-MAX_SAFE_INTEGER,y:-MAX_SAFE_INTEGER,width:0,height:0,rotation:0};const n=[];this.nodes().map(h=>{const p=h.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()});var s=[{x:p.x,y:p.y},{x:p.x+p.width,y:p.y},{x:p.x+p.width,y:p.y+p.height},{x:p.x,y:p.y+p.height}],t=h.getAbsoluteTransform();s.forEach(function(l){var u=t.point(l);n.push(u)})});const r=new Transform;r.rotate(-Konva$2.getAngle(this.rotation()));var i,o,a,d;n.forEach(function(h){var p=r.point(h);i===void 0&&(i=a=p.x,o=d=p.y),i=Math.min(i,p.x),o=Math.min(o,p.y),a=Math.max(a,p.x),d=Math.max(d,p.y)}),r.invert();const f=r.point({x:i,y:o});return{x:f.x,y:f.y,width:a-i,height:d-o,rotation:Konva$2.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),ANCHORS_NAMES.forEach((function(e){this._createAnchor(e)}).bind(this)),this._createAnchor("rotater")}_createAnchor(e){var n=new Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:TOUCH_DEVICE?10:"auto"}),r=this;n.on("mousedown touchstart",function(i){r._handleMouseDown(i)}),n.on("dragstart",i=>{n.stopDrag(),i.cancelBubble=!0}),n.on("dragend",i=>{i.cancelBubble=!0}),n.on("mouseenter",()=>{var i=Konva$2.getAngle(this.rotation()),o=getCursor(e,i);n.getStage().content&&(n.getStage().content.style.cursor=o),this._cursorChange=!0}),n.on("mouseout",()=>{n.getStage().content&&(n.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(n)}_createBack(){var e=new Shape$1({name:"back",width:0,height:0,draggable:!0,sceneFunc(n){var r=this.getParent(),i=r.padding();n.beginPath(),n.rect(-i,-i,this.width()+i*2,this.height()+i*2),n.moveTo(this.width()/2,-i),r.rotateEnabled()&&n.lineTo(this.width()/2,-r.rotateAnchorOffset()*Util._sign(this.height())-i),n.fillStrokeShape(this)},hitFunc:(n,r)=>{if(this.shouldOverdrawWholeArea()){var i=this.padding();n.beginPath(),n.rect(-i,-i,r.width()+i*2,r.height()+i*2),n.fillStrokeShape(r)}}});this.add(e),this._proxyDrag(e),e.on("dragstart",n=>{n.cancelBubble=!0}),e.on("dragmove",n=>{n.cancelBubble=!0}),e.on("dragend",n=>{n.cancelBubble=!0}),this.on("dragmove",n=>{this.update()})}_handleMouseDown(e){this._movingAnchorName=e.target.name().split(" ")[0];var n=this._getNodeRect(),r=n.width,i=n.height,o=Math.sqrt(Math.pow(r,2)+Math.pow(i,2));this.sin=Math.abs(i/o),this.cos=Math.abs(r/o),typeof window<"u"&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;var a=e.target.getAbsolutePosition(),d=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:d.x-a.x,y:d.y-a.y},this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach(f=>{f._fire("transformstart",{evt:e.evt,target:f})})}_handleMouseMove(e){var n,r,i,o=this.findOne("."+this._movingAnchorName),a=o.getStage();a.setPointersPositions(e);const d=a.getPointerPosition();let f={x:d.x-this._anchorDragOffset.x,y:d.y-this._anchorDragOffset.y};const h=o.getAbsolutePosition();this.anchorDragBoundFunc()&&(f=this.anchorDragBoundFunc()(h,f,e)),o.setAbsolutePosition(f);const p=o.getAbsolutePosition();if(!(h.x===p.x&&h.y===p.y)){if(this._movingAnchorName==="rotater"){var s=this._getNodeRect();n=o.x()-s.width/2,r=-o.y()+s.height/2;let L=Math.atan2(-r,n)+Math.PI/2;s.height<0&&(L-=Math.PI);var t=Konva$2.getAngle(this.rotation());const E=t+L,M=Konva$2.getAngle(this.rotationSnapTolerance()),A=getSnap(this.rotationSnaps(),E,M)-s.rotation,R=rotateAroundCenter(s,A);this._fitNodesInto(R,e);return}var l=this.keepRatio()||e.shiftKey,b=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(l){var u=b?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};i=Math.sqrt(Math.pow(u.x-o.x(),2)+Math.pow(u.y-o.y(),2));var g=this.findOne(".top-left").x()>u.x?-1:1,m=this.findOne(".top-left").y()>u.y?-1:1;n=i*this.cos*g,r=i*this.sin*m,this.findOne(".top-left").x(u.x-n),this.findOne(".top-left").y(u.y-r)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(o.y());else if(this._movingAnchorName==="top-right"){if(l){var u=b?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};i=Math.sqrt(Math.pow(o.x()-u.x,2)+Math.pow(u.y-o.y(),2));var g=this.findOne(".top-right").x()<u.x?-1:1,m=this.findOne(".top-right").y()>u.y?-1:1;n=i*this.cos*g,r=i*this.sin*m,this.findOne(".top-right").x(u.x+n),this.findOne(".top-right").y(u.y-r)}var _=o.position();this.findOne(".top-left").y(_.y),this.findOne(".bottom-right").x(_.x)}else if(this._movingAnchorName==="middle-left")this.findOne(".top-left").x(o.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(o.x());else if(this._movingAnchorName==="bottom-left"){if(l){var u=b?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};i=Math.sqrt(Math.pow(u.x-o.x(),2)+Math.pow(o.y()-u.y,2));var g=u.x<o.x()?-1:1,m=o.y()<u.y?-1:1;n=i*this.cos*g,r=i*this.sin*m,o.x(u.x-n),o.y(u.y+r)}_=o.position(),this.findOne(".top-left").x(_.x),this.findOne(".bottom-right").y(_.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(o.y());else if(this._movingAnchorName==="bottom-right"){if(l){var u=b?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};i=Math.sqrt(Math.pow(o.x()-u.x,2)+Math.pow(o.y()-u.y,2));var g=this.findOne(".bottom-right").x()<u.x?-1:1,m=this.findOne(".bottom-right").y()<u.y?-1:1;n=i*this.cos*g,r=i*this.sin*m,this.findOne(".bottom-right").x(u.x+n),this.findOne(".bottom-right").y(u.y+r)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));var b=this.centeredScaling()||e.altKey;if(b){var y=this.findOne(".top-left"),v=this.findOne(".bottom-right"),T=y.x(),w=y.y(),S=this.getWidth()-v.x(),x=this.getHeight()-v.y();v.move({x:-T,y:-w}),y.move({x:S,y:x})}var P=this.findOne(".top-left").getAbsolutePosition();n=P.x,r=P.y;var I=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),N=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:n,y:r,width:I,height:N,rotation:Konva$2.getAngle(this.rotation())},e)}}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){if(this._transforming){this._transforming=!1,typeof window<"u"&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));var n=this.getNode();this._fire("transformend",{evt:e,target:n}),n&&this._nodes.forEach(r=>{r._fire("transformend",{evt:e,target:r})}),this._movingAnchorName=null}}_fitNodesInto(e,n){var r=this._getNodeRect();const i=1;if(Util._inRange(e.width,-this.padding()*2-i,i)){this.update();return}if(Util._inRange(e.height,-this.padding()*2-i,i)){this.update();return}const o=this.flipEnabled();var a=new Transform;if(a.rotate(Konva$2.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const s=a.point({x:-this.padding()*2,y:0});if(e.x+=s.x,e.y+=s.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=s.x,this._anchorDragOffset.y-=s.y,!o){this.update();return}}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const s=a.point({x:this.padding()*2,y:0});if(this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=s.x,this._anchorDragOffset.y-=s.y,e.width+=this.padding()*2,!o){this.update();return}}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const s=a.point({x:0,y:-this.padding()*2});if(e.x+=s.x,e.y+=s.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=s.x,this._anchorDragOffset.y-=s.y,e.height+=this.padding()*2,!o){this.update();return}}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const s=a.point({x:0,y:this.padding()*2});if(this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=s.x,this._anchorDragOffset.y-=s.y,e.height+=this.padding()*2,!o){this.update();return}}if(this.boundBoxFunc()){const s=this.boundBoxFunc()(r,e);s?e=s:Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const d=1e7,f=new Transform;f.translate(r.x,r.y),f.rotate(r.rotation),f.scale(r.width/d,r.height/d);const h=new Transform;h.translate(e.x,e.y),h.rotate(e.rotation),h.scale(e.width/d,e.height/d);const p=h.multiply(f.invert());this._nodes.forEach(s=>{var t;const l=s.getParent().getAbsoluteTransform(),u=s.getTransform().copy();u.translate(s.offsetX(),s.offsetY());const g=new Transform;g.multiply(l.copy().invert()).multiply(p).multiply(l).multiply(u);const m=g.decompose();s.setAttrs(m),this._fire("transform",{evt:n,target:s}),s._fire("transform",{evt:n,target:s}),(t=s.getLayer())===null||t===void 0||t.batchDraw()}),this.rotation(Util._getRotation(e.rotation)),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,n){this.findOne(e).setAttrs(n)}update(){var e,n=this._getNodeRect();this.rotation(Util._getRotation(n.rotation));var r=n.width,i=n.height,o=this.enabledAnchors(),a=this.resizeEnabled(),d=this.padding(),f=this.anchorSize();this.find("._anchor").forEach(h=>{h.setAttrs({width:f,height:f,offsetX:f/2,offsetY:f/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:f/2+d,offsetY:f/2+d,visible:a&&o.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:r/2,y:0,offsetY:f/2+d,visible:a&&o.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:r,y:0,offsetX:f/2-d,offsetY:f/2+d,visible:a&&o.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:i/2,offsetX:f/2+d,visible:a&&o.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:r,y:i/2,offsetX:f/2-d,visible:a&&o.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:i,offsetX:f/2+d,offsetY:f/2-d,visible:a&&o.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:r/2,y:i,offsetY:f/2-d,visible:a&&o.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:r,y:i,offsetX:f/2-d,offsetY:f/2-d,visible:a&&o.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:r/2,y:-this.rotateAnchorOffset()*Util._sign(i)-d,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:r,height:i,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0}),(e=this.getLayer())===null||e===void 0||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();var e=this.findOne("."+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),Group$1.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return Node.prototype.toObject.call(this)}clone(e){var n=Node.prototype.clone.call(this,e);return n}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}function validateAnchors(c){return c instanceof Array||Util.warn("enabledAnchors value should be an array"),c instanceof Array&&c.forEach(function(e){ANCHORS_NAMES.indexOf(e)===-1&&Util.warn("Unknown anchor name: "+e+". Available names are: "+ANCHORS_NAMES.join(", "))}),c||[]}Transformer.prototype.className="Transformer";_registerNode(Transformer);Factory.addGetterSetter(Transformer,"enabledAnchors",ANCHORS_NAMES,validateAnchors);Factory.addGetterSetter(Transformer,"flipEnabled",!0,getBooleanValidator());Factory.addGetterSetter(Transformer,"resizeEnabled",!0);Factory.addGetterSetter(Transformer,"anchorSize",10,getNumberValidator());Factory.addGetterSetter(Transformer,"rotateEnabled",!0);Factory.addGetterSetter(Transformer,"rotationSnaps",[]);Factory.addGetterSetter(Transformer,"rotateAnchorOffset",50,getNumberValidator());Factory.addGetterSetter(Transformer,"rotationSnapTolerance",5,getNumberValidator());Factory.addGetterSetter(Transformer,"borderEnabled",!0);Factory.addGetterSetter(Transformer,"anchorStroke","rgb(0, 161, 255)");Factory.addGetterSetter(Transformer,"anchorStrokeWidth",1,getNumberValidator());Factory.addGetterSetter(Transformer,"anchorFill","white");Factory.addGetterSetter(Transformer,"anchorCornerRadius",0,getNumberValidator());Factory.addGetterSetter(Transformer,"borderStroke","rgb(0, 161, 255)");Factory.addGetterSetter(Transformer,"borderStrokeWidth",1,getNumberValidator());Factory.addGetterSetter(Transformer,"borderDash");Factory.addGetterSetter(Transformer,"keepRatio",!0);Factory.addGetterSetter(Transformer,"centeredScaling",!1);Factory.addGetterSetter(Transformer,"ignoreStroke",!1);Factory.addGetterSetter(Transformer,"padding",0,getNumberValidator());Factory.addGetterSetter(Transformer,"node");Factory.addGetterSetter(Transformer,"nodes");Factory.addGetterSetter(Transformer,"boundBoxFunc");Factory.addGetterSetter(Transformer,"anchorDragBoundFunc");Factory.addGetterSetter(Transformer,"shouldOverdrawWholeArea",!1);Factory.addGetterSetter(Transformer,"useSingleNodeRotation",!0);Factory.backCompat(Transformer,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});class Wedge extends Shape$1{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,Konva$2.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}Wedge.prototype.className="Wedge";Wedge.prototype._centroid=!0;Wedge.prototype._attrsAffectingSize=["radius"];_registerNode(Wedge);Factory.addGetterSetter(Wedge,"radius",0,getNumberValidator());Factory.addGetterSetter(Wedge,"angle",0,getNumberValidator());Factory.addGetterSetter(Wedge,"clockwise",!1);Factory.backCompat(Wedge,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function BlurStack(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var mul_table=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],shg_table=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function filterGaussBlurRGBA(c,e){var n=c.data,r=c.width,i=c.height,o,a,d,f,h,p,s,t,l,u,g,m,_,b,y,v,T,w,S,x,P,I,N,L,E=e+e+1,M=r-1,k=i-1,A=e+1,R=A*(A+1)/2,K=new BlurStack,Z=null,J=K,X=null,te=null,oe=mul_table[e],ae=shg_table[e];for(d=1;d<E;d++)J=J.next=new BlurStack,d===A&&(Z=J);for(J.next=K,s=p=0,a=0;a<i;a++){for(v=T=w=S=t=l=u=g=0,m=A*(x=n[p]),_=A*(P=n[p+1]),b=A*(I=n[p+2]),y=A*(N=n[p+3]),t+=R*x,l+=R*P,u+=R*I,g+=R*N,J=K,d=0;d<A;d++)J.r=x,J.g=P,J.b=I,J.a=N,J=J.next;for(d=1;d<A;d++)f=p+((M<d?M:d)<<2),t+=(J.r=x=n[f])*(L=A-d),l+=(J.g=P=n[f+1])*L,u+=(J.b=I=n[f+2])*L,g+=(J.a=N=n[f+3])*L,v+=x,T+=P,w+=I,S+=N,J=J.next;for(X=K,te=Z,o=0;o<r;o++)n[p+3]=N=g*oe>>ae,N!==0?(N=255/N,n[p]=(t*oe>>ae)*N,n[p+1]=(l*oe>>ae)*N,n[p+2]=(u*oe>>ae)*N):n[p]=n[p+1]=n[p+2]=0,t-=m,l-=_,u-=b,g-=y,m-=X.r,_-=X.g,b-=X.b,y-=X.a,f=s+((f=o+e+1)<M?f:M)<<2,v+=X.r=n[f],T+=X.g=n[f+1],w+=X.b=n[f+2],S+=X.a=n[f+3],t+=v,l+=T,u+=w,g+=S,X=X.next,m+=x=te.r,_+=P=te.g,b+=I=te.b,y+=N=te.a,v-=x,T-=P,w-=I,S-=N,te=te.next,p+=4;s+=r}for(o=0;o<r;o++){for(T=w=S=v=l=u=g=t=0,p=o<<2,m=A*(x=n[p]),_=A*(P=n[p+1]),b=A*(I=n[p+2]),y=A*(N=n[p+3]),t+=R*x,l+=R*P,u+=R*I,g+=R*N,J=K,d=0;d<A;d++)J.r=x,J.g=P,J.b=I,J.a=N,J=J.next;for(h=r,d=1;d<=e;d++)p=h+o<<2,t+=(J.r=x=n[p])*(L=A-d),l+=(J.g=P=n[p+1])*L,u+=(J.b=I=n[p+2])*L,g+=(J.a=N=n[p+3])*L,v+=x,T+=P,w+=I,S+=N,J=J.next,d<k&&(h+=r);for(p=o,X=K,te=Z,a=0;a<i;a++)f=p<<2,n[f+3]=N=g*oe>>ae,N>0?(N=255/N,n[f]=(t*oe>>ae)*N,n[f+1]=(l*oe>>ae)*N,n[f+2]=(u*oe>>ae)*N):n[f]=n[f+1]=n[f+2]=0,t-=m,l-=_,u-=b,g-=y,m-=X.r,_-=X.g,b-=X.b,y-=X.a,f=o+((f=a+A)<k?f:k)*r<<2,t+=v+=X.r=n[f],l+=T+=X.g=n[f+1],u+=w+=X.b=n[f+2],g+=S+=X.a=n[f+3],X=X.next,m+=x=te.r,_+=P=te.g,b+=I=te.b,y+=N=te.a,v-=x,T-=P,w-=I,S-=N,te=te.next,p+=r}}const Blur=function c(e){var n=Math.round(this.blurRadius());n>0&&filterGaussBlurRGBA(e,n)};Factory.addGetterSetter(Node,"blurRadius",0,getNumberValidator(),Factory.afterSetFilter);const Brighten=function(c){var e=this.brightness()*255,n=c.data,r=n.length,i;for(i=0;i<r;i+=4)n[i]+=e,n[i+1]+=e,n[i+2]+=e};Factory.addGetterSetter(Node,"brightness",0,getNumberValidator(),Factory.afterSetFilter);const Contrast=function(c){var e=Math.pow((this.contrast()+100)/100,2),n=c.data,r=n.length,i=150,o=150,a=150,d;for(d=0;d<r;d+=4)i=n[d],o=n[d+1],a=n[d+2],i/=255,i-=.5,i*=e,i+=.5,i*=255,o/=255,o-=.5,o*=e,o+=.5,o*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,i=i<0?0:i>255?255:i,o=o<0?0:o>255?255:o,a=a<0?0:a>255?255:a,n[d]=i,n[d+1]=o,n[d+2]=a};Factory.addGetterSetter(Node,"contrast",0,getNumberValidator(),Factory.afterSetFilter);const Emboss=function(c){var e=this.embossStrength()*10,n=this.embossWhiteLevel()*255,r=this.embossDirection(),i=this.embossBlend(),o=0,a=0,d=c.data,f=c.width,h=c.height,p=f*4,s=h;switch(r){case"top-left":o=-1,a=-1;break;case"top":o=-1,a=0;break;case"top-right":o=-1,a=1;break;case"right":o=0,a=1;break;case"bottom-right":o=1,a=1;break;case"bottom":o=1,a=0;break;case"bottom-left":o=1,a=-1;break;case"left":o=0,a=-1;break;default:Util.error("Unknown emboss direction: "+r)}do{var t=(s-1)*p,l=o;s+l<1&&(l=0),s+l>h&&(l=0);var u=(s-1+l)*f*4,g=f;do{var m=t+(g-1)*4,_=a;g+_<1&&(_=0),g+_>f&&(_=0);var b=u+(g-1+_)*4,y=d[m]-d[b],v=d[m+1]-d[b+1],T=d[m+2]-d[b+2],w=y,S=w>0?w:-w,x=v>0?v:-v,P=T>0?T:-T;if(x>S&&(w=v),P>S&&(w=T),w*=e,i){var I=d[m]+w,N=d[m+1]+w,L=d[m+2]+w;d[m]=I>255?255:I<0?0:I,d[m+1]=N>255?255:N<0?0:N,d[m+2]=L>255?255:L<0?0:L}else{var E=n-w;E<0?E=0:E>255&&(E=255),d[m]=d[m+1]=d[m+2]=E}}while(--g)}while(--s)};Factory.addGetterSetter(Node,"embossStrength",.5,getNumberValidator(),Factory.afterSetFilter);Factory.addGetterSetter(Node,"embossWhiteLevel",.5,getNumberValidator(),Factory.afterSetFilter);Factory.addGetterSetter(Node,"embossDirection","top-left",null,Factory.afterSetFilter);Factory.addGetterSetter(Node,"embossBlend",!1,null,Factory.afterSetFilter);function remap(c,e,n,r,i){var o=n-e,a=i-r,d;return o===0?r+a/2:a===0?r:(d=(c-e)/o,d=a*d+r,d)}const Enhance=function(c){var e=c.data,n=e.length,r=e[0],i=r,o,a=e[1],d=a,f,h=e[2],p=h,s,t,l=this.enhance();if(l!==0){for(t=0;t<n;t+=4)o=e[t+0],o<r?r=o:o>i&&(i=o),f=e[t+1],f<a?a=f:f>d&&(d=f),s=e[t+2],s<h?h=s:s>p&&(p=s);i===r&&(i=255,r=0),d===a&&(d=255,a=0),p===h&&(p=255,h=0);var u,g,m,_,b,y,v,T,w;for(l>0?(g=i+l*(255-i),m=r-l*(r-0),b=d+l*(255-d),y=a-l*(a-0),T=p+l*(255-p),w=h-l*(h-0)):(u=(i+r)*.5,g=i+l*(i-u),m=r+l*(r-u),_=(d+a)*.5,b=d+l*(d-_),y=a+l*(a-_),v=(p+h)*.5,T=p+l*(p-v),w=h+l*(h-v)),t=0;t<n;t+=4)e[t+0]=remap(e[t+0],r,i,m,g),e[t+1]=remap(e[t+1],a,d,y,b),e[t+2]=remap(e[t+2],h,p,w,T)}};Factory.addGetterSetter(Node,"enhance",0,getNumberValidator(),Factory.afterSetFilter);const Grayscale=function(c){var e=c.data,n=e.length,r,i;for(r=0;r<n;r+=4)i=.34*e[r]+.5*e[r+1]+.16*e[r+2],e[r]=i,e[r+1]=i,e[r+2]=i};Factory.addGetterSetter(Node,"hue",0,getNumberValidator(),Factory.afterSetFilter);Factory.addGetterSetter(Node,"saturation",0,getNumberValidator(),Factory.afterSetFilter);Factory.addGetterSetter(Node,"luminance",0,getNumberValidator(),Factory.afterSetFilter);const HSL=function(c){var e=c.data,n=e.length,r=1,i=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,a=this.luminance()*127,d,f=r*i*Math.cos(o*Math.PI/180),h=r*i*Math.sin(o*Math.PI/180),p=.299*r+.701*f+.167*h,s=.587*r-.587*f+.33*h,t=.114*r-.114*f-.497*h,l=.299*r-.299*f-.328*h,u=.587*r+.413*f+.035*h,g=.114*r-.114*f+.293*h,m=.299*r-.3*f+1.25*h,_=.587*r-.586*f-1.05*h,b=.114*r+.886*f-.2*h,y,v,T,w;for(d=0;d<n;d+=4)y=e[d+0],v=e[d+1],T=e[d+2],w=e[d+3],e[d+0]=p*y+s*v+t*T+a,e[d+1]=l*y+u*v+g*T+a,e[d+2]=m*y+_*v+b*T+a,e[d+3]=w},HSV=function(c){var e=c.data,n=e.length,r=Math.pow(2,this.value()),i=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,a,d=r*i*Math.cos(o*Math.PI/180),f=r*i*Math.sin(o*Math.PI/180),h=.299*r+.701*d+.167*f,p=.587*r-.587*d+.33*f,s=.114*r-.114*d-.497*f,t=.299*r-.299*d-.328*f,l=.587*r+.413*d+.035*f,u=.114*r-.114*d+.293*f,g=.299*r-.3*d+1.25*f,m=.587*r-.586*d-1.05*f,_=.114*r+.886*d-.2*f,b,y,v,T;for(a=0;a<n;a+=4)b=e[a+0],y=e[a+1],v=e[a+2],T=e[a+3],e[a+0]=h*b+p*y+s*v,e[a+1]=t*b+l*y+u*v,e[a+2]=g*b+m*y+_*v,e[a+3]=T};Factory.addGetterSetter(Node,"hue",0,getNumberValidator(),Factory.afterSetFilter);Factory.addGetterSetter(Node,"saturation",0,getNumberValidator(),Factory.afterSetFilter);Factory.addGetterSetter(Node,"value",0,getNumberValidator(),Factory.afterSetFilter);const Invert=function(c){var e=c.data,n=e.length,r;for(r=0;r<n;r+=4)e[r]=255-e[r],e[r+1]=255-e[r+1],e[r+2]=255-e[r+2]};var ToPolar=function(c,e,n){var r=c.data,i=e.data,o=c.width,a=c.height,d=n.polarCenterX||o/2,f=n.polarCenterY||a/2,h,p,s,t=0,l=0,u=0,g=0,m,_=Math.sqrt(d*d+f*f);p=o-d,s=a-f,m=Math.sqrt(p*p+s*s),_=m>_?m:_;var b=a,y=o,v,T,w=360/y*Math.PI/180,S,x;for(T=0;T<y;T+=1)for(S=Math.sin(T*w),x=Math.cos(T*w),v=0;v<b;v+=1)p=Math.floor(d+_*v/b*x),s=Math.floor(f+_*v/b*S),h=(s*o+p)*4,t=r[h+0],l=r[h+1],u=r[h+2],g=r[h+3],h=(T+v*o)*4,i[h+0]=t,i[h+1]=l,i[h+2]=u,i[h+3]=g},FromPolar=function(c,e,n){var r=c.data,i=e.data,o=c.width,a=c.height,d=n.polarCenterX||o/2,f=n.polarCenterY||a/2,h,p,s,t,l,u=0,g=0,m=0,_=0,b,y=Math.sqrt(d*d+f*f);p=o-d,s=a-f,b=Math.sqrt(p*p+s*s),y=b>y?b:y;var v=a,T=o,w,S,x=n.polarRotation||0,P,I;for(p=0;p<o;p+=1)for(s=0;s<a;s+=1)t=p-d,l=s-f,w=Math.sqrt(t*t+l*l)*v/y,S=(Math.atan2(l,t)*180/Math.PI+360+x)%360,S=S*T/360,P=Math.floor(S),I=Math.floor(w),h=(I*o+P)*4,u=r[h+0],g=r[h+1],m=r[h+2],_=r[h+3],h=(s*o+p)*4,i[h+0]=u,i[h+1]=g,i[h+2]=m,i[h+3]=_};const Kaleidoscope=function(c){var e=c.width,n=c.height,r,i,o,a,d,f,h,p,s,t,l=Math.round(this.kaleidoscopePower()),u=Math.round(this.kaleidoscopeAngle()),g=Math.floor(e*(u%360)/360);if(!(l<1)){var m=Util.createCanvasElement();m.width=e,m.height=n;var _=m.getContext("2d").getImageData(0,0,e,n);Util.releaseCanvas(m),ToPolar(c,_,{polarCenterX:e/2,polarCenterY:n/2});for(var b=e/Math.pow(2,l);b<=8;)b=b*2,l-=1;b=Math.ceil(b);var y=b,v=0,T=y,w=1;for(g+b>e&&(v=y,T=0,w=-1),i=0;i<n;i+=1)for(r=v;r!==T;r+=w)o=Math.round(r+g)%e,s=(e*i+o)*4,d=_.data[s+0],f=_.data[s+1],h=_.data[s+2],p=_.data[s+3],t=(e*i+r)*4,_.data[t+0]=d,_.data[t+1]=f,_.data[t+2]=h,_.data[t+3]=p;for(i=0;i<n;i+=1)for(y=Math.floor(b),a=0;a<l;a+=1){for(r=0;r<y+1;r+=1)s=(e*i+r)*4,d=_.data[s+0],f=_.data[s+1],h=_.data[s+2],p=_.data[s+3],t=(e*i+y*2-r-1)*4,_.data[t+0]=d,_.data[t+1]=f,_.data[t+2]=h,_.data[t+3]=p;y*=2}FromPolar(_,c,{polarRotation:0})}};Factory.addGetterSetter(Node,"kaleidoscopePower",2,getNumberValidator(),Factory.afterSetFilter);Factory.addGetterSetter(Node,"kaleidoscopeAngle",0,getNumberValidator(),Factory.afterSetFilter);function pixelAt(c,e,n){var r=(n*c.width+e)*4,i=[];return i.push(c.data[r++],c.data[r++],c.data[r++],c.data[r++]),i}function rgbDistance(c,e){return Math.sqrt(Math.pow(c[0]-e[0],2)+Math.pow(c[1]-e[1],2)+Math.pow(c[2]-e[2],2))}function rgbMean(c){for(var e=[0,0,0],n=0;n<c.length;n++)e[0]+=c[n][0],e[1]+=c[n][1],e[2]+=c[n][2];return e[0]/=c.length,e[1]/=c.length,e[2]/=c.length,e}function backgroundMask(c,e){var n=pixelAt(c,0,0),r=pixelAt(c,c.width-1,0),i=pixelAt(c,0,c.height-1),o=pixelAt(c,c.width-1,c.height-1),a=e||10;if(rgbDistance(n,r)<a&&rgbDistance(r,o)<a&&rgbDistance(o,i)<a&&rgbDistance(i,n)<a){for(var d=rgbMean([r,n,o,i]),f=[],h=0;h<c.width*c.height;h++){var p=rgbDistance(d,[c.data[h*4],c.data[h*4+1],c.data[h*4+2]]);f[h]=p<a?0:255}return f}}function applyMask(c,e){for(var n=0;n<c.width*c.height;n++)c.data[4*n+3]=e[n]}function erodeMask(c,e,n){for(var r=[1,1,1,1,0,1,1,1,1],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),a=[],d=0;d<n;d++)for(var f=0;f<e;f++){for(var h=d*e+f,p=0,s=0;s<i;s++)for(var t=0;t<i;t++){var l=d+s-o,u=f+t-o;if(l>=0&&l<n&&u>=0&&u<e){var g=l*e+u,m=r[s*i+t];p+=c[g]*m}}a[h]=p===255*8?255:0}return a}function dilateMask(c,e,n){for(var r=[1,1,1,1,1,1,1,1,1],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),a=[],d=0;d<n;d++)for(var f=0;f<e;f++){for(var h=d*e+f,p=0,s=0;s<i;s++)for(var t=0;t<i;t++){var l=d+s-o,u=f+t-o;if(l>=0&&l<n&&u>=0&&u<e){var g=l*e+u,m=r[s*i+t];p+=c[g]*m}}a[h]=p>=255*4?255:0}return a}function smoothEdgeMask(c,e,n){for(var r=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),a=[],d=0;d<n;d++)for(var f=0;f<e;f++){for(var h=d*e+f,p=0,s=0;s<i;s++)for(var t=0;t<i;t++){var l=d+s-o,u=f+t-o;if(l>=0&&l<n&&u>=0&&u<e){var g=l*e+u,m=r[s*i+t];p+=c[g]*m}}a[h]=p}return a}const Mask=function(c){var e=this.threshold(),n=backgroundMask(c,e);return n&&(n=erodeMask(n,c.width,c.height),n=dilateMask(n,c.width,c.height),n=smoothEdgeMask(n,c.width,c.height),applyMask(c,n)),c};Factory.addGetterSetter(Node,"threshold",0,getNumberValidator(),Factory.afterSetFilter);const Noise=function(c){var e=this.noise()*255,n=c.data,r=n.length,i=e/2,o;for(o=0;o<r;o+=4)n[o+0]+=i-2*i*Math.random(),n[o+1]+=i-2*i*Math.random(),n[o+2]+=i-2*i*Math.random()};Factory.addGetterSetter(Node,"noise",.2,getNumberValidator(),Factory.afterSetFilter);const Pixelate=function(c){var e=Math.ceil(this.pixelSize()),n=c.width,r=c.height,i,o,a,d,f,h,p,s=Math.ceil(n/e),t=Math.ceil(r/e),l,u,g,m,_,b,y,v=c.data;if(e<=0){Util.error("pixelSize value can not be <= 0");return}for(_=0;_<s;_+=1)for(b=0;b<t;b+=1){for(d=0,f=0,h=0,p=0,l=_*e,u=l+e,g=b*e,m=g+e,y=0,i=l;i<u;i+=1)if(!(i>=n))for(o=g;o<m;o+=1)o>=r||(a=(n*o+i)*4,d+=v[a+0],f+=v[a+1],h+=v[a+2],p+=v[a+3],y+=1);for(d=d/y,f=f/y,h=h/y,p=p/y,i=l;i<u;i+=1)if(!(i>=n))for(o=g;o<m;o+=1)o>=r||(a=(n*o+i)*4,v[a+0]=d,v[a+1]=f,v[a+2]=h,v[a+3]=p)}};Factory.addGetterSetter(Node,"pixelSize",8,getNumberValidator(),Factory.afterSetFilter);const Posterize=function(c){var e=Math.round(this.levels()*254)+1,n=c.data,r=n.length,i=255/e,o;for(o=0;o<r;o+=1)n[o]=Math.floor(n[o]/i)*i};Factory.addGetterSetter(Node,"levels",.5,getNumberValidator(),Factory.afterSetFilter);const RGB=function(c){var e=c.data,n=e.length,r=this.red(),i=this.green(),o=this.blue(),a,d;for(a=0;a<n;a+=4)d=(.34*e[a]+.5*e[a+1]+.16*e[a+2])/255,e[a]=d*r,e[a+1]=d*i,e[a+2]=d*o,e[a+3]=e[a+3]};Factory.addGetterSetter(Node,"red",0,function(c){return this._filterUpToDate=!1,c>255?255:c<0?0:Math.round(c)});Factory.addGetterSetter(Node,"green",0,function(c){return this._filterUpToDate=!1,c>255?255:c<0?0:Math.round(c)});Factory.addGetterSetter(Node,"blue",0,RGBComponent,Factory.afterSetFilter);const RGBA=function(c){var e=c.data,n=e.length,r=this.red(),i=this.green(),o=this.blue(),a=this.alpha(),d,f;for(d=0;d<n;d+=4)f=1-a,e[d]=r*a+e[d]*f,e[d+1]=i*a+e[d+1]*f,e[d+2]=o*a+e[d+2]*f};Factory.addGetterSetter(Node,"red",0,function(c){return this._filterUpToDate=!1,c>255?255:c<0?0:Math.round(c)});Factory.addGetterSetter(Node,"green",0,function(c){return this._filterUpToDate=!1,c>255?255:c<0?0:Math.round(c)});Factory.addGetterSetter(Node,"blue",0,RGBComponent,Factory.afterSetFilter);Factory.addGetterSetter(Node,"alpha",1,function(c){return this._filterUpToDate=!1,c>1?1:c<0?0:c});const Sepia=function(c){var e=c.data,n=e.length,r,i,o,a;for(r=0;r<n;r+=4)i=e[r+0],o=e[r+1],a=e[r+2],e[r+0]=Math.min(255,i*.393+o*.769+a*.189),e[r+1]=Math.min(255,i*.349+o*.686+a*.168),e[r+2]=Math.min(255,i*.272+o*.534+a*.131)},Solarize=function(c){var e=c.data,n=c.width,r=c.height,i=n*4,o=r;do{var a=(o-1)*i,d=n;do{var f=a+(d-1)*4,h=e[f],p=e[f+1],s=e[f+2];h>127&&(h=255-h),p>127&&(p=255-p),s>127&&(s=255-s),e[f]=h,e[f+1]=p,e[f+2]=s}while(--d)}while(--o)},Threshold=function(c){var e=this.threshold()*255,n=c.data,r=n.length,i;for(i=0;i<r;i+=1)n[i]=n[i]<e?0:255};Factory.addGetterSetter(Node,"threshold",.5,getNumberValidator(),Factory.afterSetFilter);const Konva=Konva$1.Util._assign(Konva$1,{Arc,Arrow,Circle:Circle$1,Ellipse,Image:Image$2,Label,Tag,Line,Path:Path$1,Rect,RegularPolygon,Ring,Sprite,Star,Text,TextPath,Transformer,Wedge,Filters:{Blur,Brighten,Contrast,Emboss,Enhance,Grayscale,HSL,HSV,Invert,Kaleidoscope,Mask,Noise,Pixelate,Posterize,RGB,RGBA,Sepia,Solarize,Threshold}});let nanoid=(c=21)=>crypto.getRandomValues(new Uint8Array(c)).reduce((e,n)=>(n&=63,n<36?e+=n.toString(36):n<62?e+=(n-26).toString(36).toUpperCase():n>62?e+="-":e+="_",e),"");const KONVA_EVENTS=["mouseover","mouseout","mouseenter","mouseleave","mousemove","mousedown","mouseup","wheel","click","dblclick","touchstart","touchmove","touchend","tap","dbltap","pointerdown","pointermove","pointerup","pointercancel","pointerover","pointerenter","pointerout","pointerleave","pointerclick","pointerdblclick","dragstart","dragmove","dragend","transformstart","transform","transformend"];function registerEvents(c,e){KONVA_EVENTS.forEach(n=>{e.on(n,r=>{c(n,r,{cancelable:!0})||(r.cancelBubble=!0)})})}const CONTAINER_COMPONENT_KEYS=["svelte-konva-stage","svelte-konva-layer","svelte-konva-group","svelte-konva-label"];var Container;(function(c){c[c.Stage=0]="Stage",c[c.Layer=1]="Layer",c[c.Group=2]="Group",c[c.Label=3]="Label"})(Container||(Container={}));const CONTAINER_ERROR="svelte-konva: Component does not have any parent container. Please make sure that the component is wrapped inside a Layer or Group.",LAYER_ERROR="svelte-konva: A Layer needs to have a Stage as parent.";function setContainerContext(c,e){CONTAINER_COMPONENT_KEYS.forEach(n=>{setContext(n,null)}),setContext(CONTAINER_COMPONENT_KEYS[c],e)}function getParentContainer(){for(let c=1;c<4;c++){const e=getContext(CONTAINER_COMPONENT_KEYS[c]);if(e)return e}throw new Error(CONTAINER_ERROR)}function getParentStage(){const c=getContext(CONTAINER_COMPONENT_KEYS[Container.Stage]);if(c)return c;throw new Error(LAYER_ERROR)}function copyExistingKeys(c,e){for(const n in c)Object.prototype.hasOwnProperty.call(e,n)&&(c[n]=e[n])}function instance$l(c,e,n){let r,{config:i}=e,{handle:o=new Konva.Circle(i)}=e,a=getParentContainer();component_subscribe(c,a,f=>n(3,r=f));let d=createEventDispatcher();return onMount(()=>{r.add(o),o.on("transformend",()=>{copyExistingKeys(i,o.getAttrs()),n(1,i)}),o.on("dragend",()=>{copyExistingKeys(i,o.getAttrs()),n(1,i)}),registerEvents(d,o)}),onDestroy(()=>{o.destroy()}),c.$$set=f=>{"config"in f&&n(1,i=f.config),"handle"in f&&n(2,o=f.handle)},c.$$.update=()=>{c.$$.dirty&6&&o.setAttrs(i)},[a,i,o]}class Circle extends SvelteComponent{constructor(e){super(),init(this,e,instance$l,null,safe_not_equal,{config:1,handle:2})}}function create_if_block$f(c){let e;const n=c[5].default,r=create_slot(n,c,c[4],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&16)&&update_slot_base(r,n,i,i[4],e?get_slot_changes(n,i[4],o,null):get_all_dirty_from_scope(i[4]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$h(c){let e,n,r=c[0]&&create_if_block$f(c);return{c(){r&&r.c(),e=empty()},l(i){r&&r.l(i),e=empty()},m(i,o){r&&r.m(i,o),insert_hydration(i,e,o),n=!0},p(i,[o]){i[0]?r?(r.p(i,o),o&1&&transition_in(r,1)):(r=create_if_block$f(i),r.c(),transition_in(r,1),r.m(e.parentNode,e)):r&&(group_outros(),transition_out(r,1,1,()=>{r=null}),check_outros())},i(i){n||(transition_in(r),n=!0)},o(i){transition_out(r),n=!1},d(i){i&&detach(e),r&&r.d(i)}}}function instance$k(c,e,n){let r,{$$slots:i={},$$scope:o}=e,{config:a={}}=e,{handle:d=new Konva.Group(a)}=e,f=writable(null),h=createEventDispatcher(),p=!1,s=getParentContainer();return component_subscribe(c,s,t=>n(6,r=t)),onMount(()=>{r.add(d),d.on("transformend",()=>{copyExistingKeys(a,d.getAttrs()),n(2,a)}),d.on("dragend",()=>{copyExistingKeys(a,d.getAttrs()),n(2,a)}),registerEvents(h,d),f.set(d),n(0,p=!0)}),onDestroy(()=>{d&&d.destroy()}),setContainerContext(Container.Group,f),c.$$set=t=>{"config"in t&&n(2,a=t.config),"handle"in t&&n(3,d=t.handle),"$$scope"in t&&n(4,o=t.$$scope)},c.$$.update=()=>{c.$$.dirty&12&&d&&d.setAttrs(a)},[p,s,a,d,o,i]}class Group extends SvelteComponent{constructor(e){super(),init(this,e,instance$k,create_fragment$h,safe_not_equal,{config:2,handle:3})}}function instance$j(c,e,n){let r,{config:i}=e,{handle:o=new Konva.Image(i)}=e,a=getParentContainer();component_subscribe(c,a,f=>n(3,r=f));let d=createEventDispatcher();return onMount(()=>{r.add(o),o.on("transformend",()=>{copyExistingKeys(i,o.getAttrs()),n(1,i)}),o.on("dragend",()=>{copyExistingKeys(i,o.getAttrs()),n(1,i)}),registerEvents(d,o)}),onDestroy(()=>{o.destroy()}),c.$$set=f=>{"config"in f&&n(1,i=f.config),"handle"in f&&n(2,o=f.handle)},c.$$.update=()=>{c.$$.dirty&6&&o.setAttrs(i)},[a,i,o]}let Image$1=class extends SvelteComponent{constructor(e){super(),init(this,e,instance$j,null,safe_not_equal,{config:1,handle:2})}};function create_if_block$e(c){let e;const n=c[5].default,r=create_slot(n,c,c[4],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&16)&&update_slot_base(r,n,i,i[4],e?get_slot_changes(n,i[4],o,null):get_all_dirty_from_scope(i[4]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$g(c){let e,n,r=c[0]&&create_if_block$e(c);return{c(){r&&r.c(),e=empty()},l(i){r&&r.l(i),e=empty()},m(i,o){r&&r.m(i,o),insert_hydration(i,e,o),n=!0},p(i,[o]){i[0]?r?(r.p(i,o),o&1&&transition_in(r,1)):(r=create_if_block$e(i),r.c(),transition_in(r,1),r.m(e.parentNode,e)):r&&(group_outros(),transition_out(r,1,1,()=>{r=null}),check_outros())},i(i){n||(transition_in(r),n=!0)},o(i){transition_out(r),n=!1},d(i){i&&detach(e),r&&r.d(i)}}}function instance$i(c,e,n){let r,{$$slots:i={},$$scope:o}=e,{config:a={}}=e,{handle:d=new Konva.Layer(a)}=e,f=writable(null),h=createEventDispatcher(),p=!1,s=getParentStage();return component_subscribe(c,s,t=>n(6,r=t)),onMount(()=>{r.add(d),d.on("transformend",()=>{copyExistingKeys(a,d.getAttrs()),n(2,a)}),d.on("dragend",()=>{copyExistingKeys(a,d.getAttrs()),n(2,a)}),registerEvents(h,d),f.set(d),n(0,p=!0)}),onDestroy(()=>{d&&d.destroy()}),setContainerContext(Container.Layer,f),c.$$set=t=>{"config"in t&&n(2,a=t.config),"handle"in t&&n(3,d=t.handle),"$$scope"in t&&n(4,o=t.$$scope)},c.$$.update=()=>{c.$$.dirty&12&&d&&d.setAttrs(a)},[p,s,a,d,o,i]}class Layer extends SvelteComponent{constructor(e){super(),init(this,e,instance$i,create_fragment$g,safe_not_equal,{config:2,handle:3})}}function instance$h(c,e,n){let r,{config:i}=e,{handle:o=new Konva.Path(i)}=e,a=getParentContainer();component_subscribe(c,a,f=>n(3,r=f));let d=createEventDispatcher();return onMount(()=>{r.add(o),o.on("transformend",()=>{copyExistingKeys(i,o.getAttrs()),n(1,i)}),o.on("dragend",()=>{copyExistingKeys(i,o.getAttrs()),n(1,i)}),registerEvents(d,o)}),onDestroy(()=>{o.destroy()}),c.$$set=f=>{"config"in f&&n(1,i=f.config),"handle"in f&&n(2,o=f.handle)},c.$$.update=()=>{c.$$.dirty&6&&o.setAttrs(i)},[a,i,o]}class Path extends SvelteComponent{constructor(e){super(),init(this,e,instance$h,null,safe_not_equal,{config:1,handle:2})}}function instance$g(c,e,n){let r,{config:i}=e,{handle:o=new Konva.Shape(i)}=e,a=getParentContainer();component_subscribe(c,a,f=>n(3,r=f));let d=createEventDispatcher();return onMount(()=>{r.add(o),o.on("transformend",()=>{copyExistingKeys(i,o.getAttrs()),n(1,i)}),o.on("dragend",()=>{copyExistingKeys(i,o.getAttrs()),n(1,i)}),registerEvents(d,o)}),onDestroy(()=>{o.destroy()}),c.$$set=f=>{"config"in f&&n(1,i=f.config),"handle"in f&&n(2,o=f.handle)},c.$$.update=()=>{c.$$.dirty&6&&o.setAttrs(i)},[a,i,o]}class Shape extends SvelteComponent{constructor(e){super(),init(this,e,instance$g,null,safe_not_equal,{config:1,handle:2})}}function create_if_block$d(c){let e;const n=c[6].default,r=create_slot(n,c,c[5],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),e=!0},p(i,o){r&&r.p&&(!e||o&32)&&update_slot_base(r,n,i,i[5],e?get_slot_changes(n,i[5],o,null):get_all_dirty_from_scope(i[5]),null)},i(i){e||(transition_in(r,i),e=!0)},o(i){transition_out(r,i),e=!1},d(i){r&&r.d(i)}}}function create_fragment$f(c){let e,n,r=c[1]&&create_if_block$d(c),i=[c[2]],o={};for(let a=0;a<i.length;a+=1)o=assign(o,i[a]);return{c(){e=element("div"),r&&r.c(),this.h()},l(a){e=claim_element(a,"DIV",{});var d=children(e);r&&r.l(d),d.forEach(detach),this.h()},h(){set_attributes(e,o)},m(a,d){insert_hydration(a,e,d),r&&r.m(e,null),c[7](e),n=!0},p(a,[d]){a[1]?r?(r.p(a,d),d&2&&transition_in(r,1)):(r=create_if_block$d(a),r.c(),transition_in(r,1),r.m(e,null)):r&&(group_outros(),transition_out(r,1,1,()=>{r=null}),check_outros()),set_attributes(e,o=get_spread_update(i,[d&4&&a[2]]))},i(a){n||(transition_in(r),n=!0)},o(a){transition_out(r),n=!1},d(a){a&&detach(e),r&&r.d(),c[7](null)}}}function instance$f(c,e,n){const r=["config","handle"];let i=compute_rest_props(e,r),{$$slots:o={},$$scope:a}=e,{config:d}=e,{handle:f=null}=e,h=writable(null),p,s=createEventDispatcher(),t=!1;onMount(()=>{n(4,f=new Konva.Stage({container:p,...d})),f.on("dragend",()=>{copyExistingKeys(d,f.getAttrs()),n(3,d)}),registerEvents(s,f),h.set(f),n(1,t=!0)}),onDestroy(()=>{f&&f.destroy()}),setContainerContext(Container.Stage,h);function l(u){binding_callbacks[u?"unshift":"push"](()=>{p=u,n(0,p)})}return c.$$set=u=>{e=assign(assign({},e),exclude_internal_props(u)),n(2,i=compute_rest_props(e,r)),"config"in u&&n(3,d=u.config),"handle"in u&&n(4,f=u.handle),"$$scope"in u&&n(5,a=u.$$scope)},c.$$.update=()=>{c.$$.dirty&24&&f&&f.setAttrs(d)},[p,t,i,d,f,a,o,l]}class Stage extends SvelteComponent{constructor(e){super(),init(this,e,instance$f,create_fragment$f,safe_not_equal,{config:3,handle:4})}}const INPUTPOINT_RADIUS=6,INPUTPOINT_STROKEWIDTH=3,INPUTRECT_STROKEWIDTH=1.5,BBOX_STROKEWIDTH=2,MASK_STROKEWIDTH=2,POINT_SELECTION="POINT_SELECTION";var simplify$1={exports:{}};(function(c){(function(){function e(d,f){var h=d.x-f.x,p=d.y-f.y;return h*h+p*p}function n(d,f,h){var p=f.x,s=f.y,t=h.x-p,l=h.y-s;if(t!==0||l!==0){var u=((d.x-p)*t+(d.y-s)*l)/(t*t+l*l);u>1?(p=h.x,s=h.y):u>0&&(p+=t*u,s+=l*u)}return t=d.x-p,l=d.y-s,t*t+l*l}function r(d,f){for(var h=d[0],p=[h],s,t=1,l=d.length;t<l;t++)s=d[t],e(s,h)>f&&(p.push(s),h=s);return h!==s&&p.push(s),p}function i(d,f,h,p,s){for(var t=p,l,u=f+1;u<h;u++){var g=n(d[u],d[f],d[h]);g>t&&(l=u,t=g)}t>p&&(l-f>1&&i(d,f,l,p,s),s.push(d[l]),h-l>1&&i(d,l,h,p,s))}function o(d,f){var h=d.length-1,p=[d[0]];return i(d,0,h,f,p),p.push(d[h]),p}function a(d,f,h){if(d.length<=2)return d;var p=f!==void 0?f*f:1;return d=h?d:r(d,p),d=o(d,p),d}c.exports=a,c.exports.default=a})()})(simplify$1);var simplifyExports=simplify$1.exports;const simplify=getDefaultExportFromCjs(simplifyExports),LockIcon="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='20'%20height='20'%20viewBox='0%200%2024%2024'%20fill='transparent'%20stroke='currentColor'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='lucide%20lucide-lock'%3e%3crect%20width='18'%20height='11'%20x='3'%20y='11'%20rx='2'%20ry='2'/%3e%3cpath%20d='M7%2011V7a5%205%200%200%201%2010%200v4'/%3e%3c/svg%3e",stickLabelsToRectangle=(c,e,n)=>{c.x(n.x()),c.y(n.y()),e.x(n.x()),e.y(n.y()+n.height())},toggleIsEditingBBox=(c,e,n,r)=>{const i=e.findOne(`#rect${n.id}`);i.draggable(c==="on");const o=e.findOne("#transformer"),a=o.nodes();return o.nodes(c==="on"?[i]:[...a.filter(d=>d.id()!==i.id())]),r.map(d=>(d.id===n.id&&(d.editing=c==="on"),d))},getNewRectangleDimensions=(c,e)=>{const n=c==null?void 0:c.width(),r=c==null?void 0:c.height(),i=c==null?void 0:c.scaleX(),o=c==null?void 0:c.scaleY(),a=e.width,d=e.height,f=((c==null?void 0:c.x())+(n*i-n)/2)/a,h=((c==null?void 0:c.y())+(r*o-r)/2)/d,p=n*i/a,s=r*o/d;return[f,h,p,s]},toggleBBoxIsLocked=(c,e)=>{const n=c.findOne(`#rect${e.id}`);c.findOne(`#lockTooltip${e.id}`).opacity(e.locked?1:0);const i=e.locked;return n.listening(!i),e};function addBBox(c,e,n,r,i,o,a){const d=r.x()+c.bbox[0],f=r.y()+c.bbox[1],h=c.bbox[2],p=c.bbox[3],s=new Konva.Group({id:c.id,visible:c.visible,opacity:c.opacity,listening:!1}),t=new Konva.Rect({id:`rect${c.id}`,x:d,y:f,width:h,height:p,stroke:e,draggable:!1,strokeWidth:BBOX_STROKEWIDTH/o[i]});t.on("transformend",()=>{const m=s.findOne(`#rect${c.id}`);a(m)}),s.add(t);const l=new Konva.Label({id:`tooltip${c.id}`,x:d,y:f,width:500,height:50,offsetY:12,scale:{x:1/o[i],y:1/o[i]}});l.add(new Konva.Tag({fill:e,stroke:c.tooltip?e:"transparent"})),l.add(new Konva.Text({id:`text${c.id}`,x:24,y:0,text:c.tooltip,fontSize:12,fontStyle:"100"}));const u=new Konva.Label({id:`lockTooltip${c.id}`,x:d,y:f+p,opacity:0,offsetY:24,width:24,height:24,scale:{x:1/o[i],y:1/o[i]}});u.add(new Konva.Tag({fill:e,stroke:e}));const g=new Image;g.onload=function(){const m=new Konva.Image({x:0,y:0,image:g,width:24,height:24,fill:e});u.add(m)},g.src=LockIcon,s.add(l),s.add(u),n.add(s),t.on("transform",function(){stickLabelsToRectangle(l,u,t)}),t.on("dragmove",function(){stickLabelsToRectangle(l,u,t)})}function addMask(c,e,n,r,i,o,a){if(c.isManual)return;const d=r.x(),f=r.y(),h=r.scale(),p=new Option().style;p.color=e;function s(u){const g=u.split(" "),m=g[0].slice(1);return{x:parseInt(m),y:parseInt(g[1])}}function t(u){const g=u.split(" "),m=g[2].slice(1),_=[{x:parseInt(m),y:parseInt(g[3])}];for(let b=4;b<g.length;b+=2)_.push({x:parseInt(g[b]),y:parseInt(g[b+1])});return _}const l=new Konva.Shape({id:c.id,x:d,y:f,width:o.width(),height:o.height(),fill:`rgba(${p.color.replace("rgb(","").replace(")","")}, 0.35)`,stroke:p.color,strokeWidth:MASK_STROKEWIDTH/a[i],scale:h,visible:c.visible,opacity:c.opacity,listening:!1,sceneFunc:(u,g)=>{u.beginPath();for(let m=0;m<c.svg.length;++m){const _=s(c.svg[m]);u.moveTo(_.x,_.y);const b=t(c.svg[m]);for(const y of b)u.lineTo(y.x,y.y)}u.fillStrokeShape(g)}});n.add(l)}function destroyDeletedObjects(c,e){const n=[];for(const r of e.children)c.includes(r.id())||n.push(r);for(const r of n)r.destroy()}function findOrCreateCurrentMask(c,e){const r=e.findOne(`#${c}`).findOne("#currentAnnotation");let i=r.findOne("#currentMask");return i||(i=new Konva.Group({id:"currentMask"}),r.add(i)),i}function clearCurrentAnn(c,e,n){const r=e==null?void 0:e.findOne(`#${c}`);if(r){const o=r.findOne("#currentAnnotation").findOne("#currentMask");o&&o.destroy(),n!=null&&n.postProcessor&&n.postProcessor.reset()}}function mapMaskPointsToLineCoordinates(c){const e=c==null?void 0:c.filter(r=>r).map(r=>{const i=r.coordinates||r.rle.counts;return{visible:r.visible,editing:r.editing,id:r.id,status:r!=null&&r.id?"created":"creating",svg:r==null?void 0:r.svg,viewId:r.viewId,points:i.reduce((o,a,d)=>(d%2===0&&o.push({x:a,y:i[d+1],id:d/2}),o),[])}}).map(r=>{const i=simplify(r.points,4,!1);return r.points=i,r}),n={visible:!0,status:"creating",points:[],svg:[],editing:!1,id:"creating",viewId:void 0};return e.push(n),e}const parseSvgPath=c=>{const e=/([ML]?)\s*([\d.]+)\s+([\d.]+)/g;let n,r=[];for(;(n=e.exec(c))!==null;){const[,,i,o]=n;r.push({x:parseFloat(i),y:parseFloat(o)})}return r=simplify(r,4,!0),r.map((i,o)=>({...i,id:o}))},convertPointToSvg=c=>c.reduce((e,n,r)=>r===0?`M${n.x} ${n.y}`:r===1?`${e} L${n.x} ${n.y}`:`${e} ${n.x} ${n.y}`,""),hexToRGBA=(c,e)=>{const n=parseInt(c.slice(1,3),16),r=parseInt(c.slice(3,5),16),i=parseInt(c.slice(5,7),16);return`rgba(${n},${r},${i},${e})`};function m_part(c){const e=c.split(" "),n=e[0].slice(1);return{x:parseInt(n),y:parseInt(e[1])}}function l_part(c){var i;const e=c.split(" "),n=(i=e[2])==null?void 0:i.slice(1),r=[{x:parseInt(n),y:parseInt(e[3])}];for(let o=4;o<e.length;o+=2)r.push({x:parseInt(e[o]),y:parseInt(e[o+1])});return r}const sceneFunc=(c,e,n)=>{c.beginPath();for(let r=0;r<n.length;++r){const i=m_part(n[r]);c.moveTo(i.x,i.y);const o=l_part(n[r]);for(const a of o)c.lineTo(a.x,a.y)}c.fillStrokeShape(e)};function svgPathToBitmap(c,e,n){const r=document.createElement("canvas");r.width=e,r.height=n;const i=r.getContext("2d");i.clearRect(0,0,e,n),i.fillStyle="black",i.fill(new Path2D(c));const o=i.getImageData(0,0,e,n).data,a=[];for(let d=0;d<o.length;d+=4)a.push(o[d+3]===0?0:1);return a}function rleEncode(c){const e=[];let n=1;for(let r=1;r<c.length;r++)c[r]===c[r-1]?n++:(e.push(n),n=1);return e.push(n),e}function reshapeArray(c,e,n){if(c.length!==e*n)throw new Error("Can't reshape with length != cols*rows");const r=[];for(let i=0;i<n;i++)for(let o=0;o<e;o++)r.push(c[o*n+i]);return r}function runLengthEncode(c,e,n){let r=svgPathToBitmap(c,e,n);return r=reshapeArray(r,n,e),rleEncode(r)}function get_each_context$5(c,e,n){const r=c.slice();return r[21]=e[n],r[23]=n,r}function get_each_context_1$2(c,e,n){const r=c.slice();return r[24]=e[n],r[26]=n,r}function create_else_block$4(c){let e,n;return e=new Shape({props:{config:{sceneFunc:c[20],stroke:c[1].status==="created"?c[2]:"hsl(316deg 60% 29.41%)",strokeWidth:c[1].status==="created"?1:3,closed:c[6],fill:c[1].status==="created"?hexToRGBA(c[2],.5):"rgb(0,128,0,0.5)"}}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p(r,i){const o={};i&6&&(o.config={sceneFunc:r[20],stroke:r[1].status==="created"?r[2]:"hsl(316deg 60% 29.41%)",strokeWidth:r[1].status==="created"?1:3,closed:r[6],fill:r[1].status==="created"?hexToRGBA(r[2],.5):"rgb(0,128,0,0.5)"}),e.$set(o)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_if_block$c(c){let e,n,r,i,o,a=c[1].id==="creating"&&create_if_block_1$9(c);n=new Shape({props:{config:{sceneFunc:c[15],stroke:c[1].status==="created"?c[2]:"hsl(316deg 60% 29.41%)",strokeWidth:2/c[3][c[0]],closed:c[6],fill:c[1].status==="created"?hexToRGBA(c[2],.5):"#f9f4f773"}}});let d=ensure_array_like(c[4].simplifiedPoints),f=[];for(let p=0;p<d.length;p+=1)f[p]=create_each_block$5(get_each_context$5(c,d,p));const h=p=>transition_out(f[p],1,1,()=>{f[p]=null});return{c(){a&&a.c(),e=space(),create_component(n.$$.fragment),r=space();for(let p=0;p<f.length;p+=1)f[p].c();i=empty()},l(p){a&&a.l(p),e=claim_space(p),claim_component(n.$$.fragment,p),r=claim_space(p);for(let s=0;s<f.length;s+=1)f[s].l(p);i=empty()},m(p,s){a&&a.m(p,s),insert_hydration(p,e,s),mount_component(n,p,s),insert_hydration(p,r,s);for(let t=0;t<f.length;t+=1)f[t]&&f[t].m(p,s);insert_hydration(p,i,s),o=!0},p(p,s){p[1].id==="creating"?a?(a.p(p,s),s&2&&transition_in(a,1)):(a=create_if_block_1$9(p),a.c(),transition_in(a,1),a.m(e.parentNode,e)):a&&(group_outros(),transition_out(a,1,1,()=>{a=null}),check_outros());const t={};if(s&31&&(t.config={sceneFunc:p[15],stroke:p[1].status==="created"?p[2]:"hsl(316deg 60% 29.41%)",strokeWidth:2/p[3][p[0]],closed:p[6],fill:p[1].status==="created"?hexToRGBA(p[2],.5):"#f9f4f773"}),n.$set(t),s&1947){d=ensure_array_like(p[4].simplifiedPoints);let l;for(l=0;l<d.length;l+=1){const u=get_each_context$5(p,d,l);f[l]?(f[l].p(u,s),transition_in(f[l],1)):(f[l]=create_each_block$5(u),f[l].c(),transition_in(f[l],1),f[l].m(i.parentNode,i))}for(group_outros(),l=d.length;l<f.length;l+=1)h(l);check_outros()}},i(p){if(!o){transition_in(a),transition_in(n.$$.fragment,p);for(let s=0;s<d.length;s+=1)transition_in(f[s]);o=!0}},o(p){transition_out(a),transition_out(n.$$.fragment,p),f=f.filter(Boolean);for(let s=0;s<f.length;s+=1)transition_out(f[s]);o=!1},d(p){p&&(detach(e),detach(r),detach(i)),a&&a.d(p),destroy_component(n,p),destroy_each(f,p)}}}function create_if_block_1$9(c){let e,n;return e=new Path({props:{config:{data:c[4].simplifiedSvg[0],stroke:"hsl(316deg 60% 29.41%)",strokeWidth:INPUTRECT_STROKEWIDTH/c[3][c[0]],fill:"#f9f4f773"}}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p(r,i){const o={};i&25&&(o.config={data:r[4].simplifiedSvg[0],stroke:"hsl(316deg 60% 29.41%)",strokeWidth:INPUTRECT_STROKEWIDTH/r[3][r[0]],fill:"#f9f4f773"}),e.$set(o)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_each_block_1$2(c){let e,n;function r(){return c[16](c[26])}function i(){return c[17](c[24],c[23])}function o(...d){return c[18](c[23],c[24],...d)}function a(){return c[19](c[24],c[23])}return e=new Circle({props:{config:{x:c[24].x,y:c[24].y,radius:4/c[3][c[0]],fill:"rgb(0,128,0)",stroke:"white",strokeWidth:1/c[3][c[0]],id:`dot-${c[1].id}-${c[23]}-${c[24].id}`,draggable:!0}}}),e.$on("click",r),e.$on("dragmove",i),e.$on("dragend",c[8]),e.$on("mouseover",o),e.$on("mouseleave",a),{c(){create_component(e.$$.fragment)},l(d){claim_component(e.$$.fragment,d)},m(d,f){mount_component(e,d,f),n=!0},p(d,f){c=d;const h={};f&27&&(h.config={x:c[24].x,y:c[24].y,radius:4/c[3][c[0]],fill:"rgb(0,128,0)",stroke:"white",strokeWidth:1/c[3][c[0]],id:`dot-${c[1].id}-${c[23]}-${c[24].id}`,draggable:!0}),e.$set(h)},i(d){n||(transition_in(e.$$.fragment,d),n=!0)},o(d){transition_out(e.$$.fragment,d),n=!1},d(d){destroy_component(e,d)}}}function create_each_block$5(c){let e,n,r=ensure_array_like(c[21]),i=[];for(let a=0;a<r.length;a+=1)i[a]=create_each_block_1$2(get_each_context_1$2(c,r,a));const o=a=>transition_out(i[a],1,1,()=>{i[a]=null});return{c(){for(let a=0;a<i.length;a+=1)i[a].c();e=empty()},l(a){for(let d=0;d<i.length;d+=1)i[d].l(a);e=empty()},m(a,d){for(let f=0;f<i.length;f+=1)i[f]&&i[f].m(a,d);insert_hydration(a,e,d),n=!0},p(a,d){if(d&1947){r=ensure_array_like(a[21]);let f;for(f=0;f<r.length;f+=1){const h=get_each_context_1$2(a,r,f);i[f]?(i[f].p(h,d),transition_in(i[f],1)):(i[f]=create_each_block_1$2(h),i[f].c(),transition_in(i[f],1),i[f].m(e.parentNode,e))}for(group_outros(),f=r.length;f<i.length;f+=1)o(f);check_outros()}},i(a){if(!n){for(let d=0;d<r.length;d+=1)transition_in(i[d]);n=!0}},o(a){i=i.filter(Boolean);for(let d=0;d<i.length;d+=1)transition_out(i[d]);n=!1},d(a){a&&detach(e),destroy_each(i,a)}}}function create_default_slot$8(c){let e,n,r,i;const o=[create_if_block$c,create_else_block$4],a=[];function d(f,h){return f[5]?0:1}return e=d(c),n=a[e]=o[e](c),{c(){n.c(),r=empty()},l(f){n.l(f),r=empty()},m(f,h){a[e].m(f,h),insert_hydration(f,r,h),i=!0},p(f,h){let p=e;e=d(f),e===p?a[e].p(f,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),n=a[e],n?n.p(f,h):(n=a[e]=o[e](f),n.c()),transition_in(n,1),n.m(r.parentNode,r))},i(f){i||(transition_in(n),i=!0)},o(f){transition_out(n),i=!1},d(f){f&&detach(r),a[e].d(f)}}}function create_fragment$e(c){let e,n;return e=new Group({props:{config:{id:"polygon",draggable:c[5],visible:c[1].visible},$$slots:{default:[create_default_slot$8]},$$scope:{ctx:c}}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p(r,[i]){const o={};i&34&&(o.config={id:"polygon",draggable:r[5],visible:r[1].visible}),i&134217791&&(o.$$scope={dirty:i,ctx:r}),e.$set(o)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function instance$e(c,e,n){let{viewId:r}=e,{selectedItemId:i}=e,{newShape:o}=e,{stage:a}=e,{images:d={}}=e,{polygonDetails:f}=e,{color:h}=e,{zoomFactor:p}=e,s=f.status==="created",t=!1,l={simplifiedSvg:f.svg,simplifiedPoints:f.svg.reduce((x,P)=>[...x,parseSvgPath(P)],[])};function u(x,P){const I=a.findOne(`#dot-${f.id}-${P}-${x}`).position(),N=l.simplifiedPoints.map((L,E)=>E===P?L.map(M=>M.id===x?{...M,x:I.x,y:I.y}:M):L);n(4,l.simplifiedPoints=N,l)}function g(){const x=runLengthEncode(l.simplifiedSvg,d[r].width,d[r].height);f.editing&&n(11,o={status:"editing",type:"mask",maskId:f.id,counts:x})}function m(x,P){if(x===0){n(4,l.simplifiedPoints=[[...l.simplifiedPoints[0],l.simplifiedPoints[0][0]]],l);const I=runLengthEncode(l.simplifiedSvg,d[P].width,d[P].height);n(11,o={status:"inProgress",masksImageSVG:[],rle:{counts:I,size:[d[P].height,d[P].width]},type:"mask",viewId:P,itemId:i,imageWidth:d[P].width,imageHeight:d[P].height,isManual:!0})}}function _(x,P,I){a.findOne(`#dot-${f.id}-${P}-${x}`).radius(I)}const b=(x,P)=>sceneFunc(x,P,l.simplifiedSvg),y=x=>m(x,r),v=(x,P)=>u(x.id,P),T=(x,P,I)=>{var N,L;((L=(N=I.detail.target)==null?void 0:N.attrs)==null?void 0:L.id)===`dot-${f.id}-${x}-${P.id}`&&_(P.id,x,8/p[r])},w=(x,P)=>_(x.id,P,4/p[r]),S=(x,P)=>sceneFunc(x,P,f.svg);return c.$$set=x=>{"viewId"in x&&n(0,r=x.viewId),"selectedItemId"in x&&n(12,i=x.selectedItemId),"newShape"in x&&n(11,o=x.newShape),"stage"in x&&n(13,a=x.stage),"images"in x&&n(14,d=x.images),"polygonDetails"in x&&n(1,f=x.polygonDetails),"color"in x&&n(2,h=x.color),"zoomFactor"in x&&n(3,p=x.zoomFactor)},c.$$.update=()=>{c.$$.dirty&2&&n(5,t=f.status==="creating"||f.editing),c.$$.dirty&2&&(f.id!=="creating"?n(4,l.simplifiedPoints=f.svg.reduce((x,P)=>[...x,parseSvgPath(P)],[]),l):n(4,l.simplifiedPoints=[f.points],l)),c.$$.dirty&16&&n(4,l.simplifiedSvg=l.simplifiedPoints.map(x=>convertPointToSvg(x)),l)},[r,f,h,p,l,t,s,u,g,m,_,o,i,a,d,b,y,v,T,w,S]}class PolygonGroup extends SvelteComponent{constructor(e){super(),init(this,e,instance$e,create_fragment$e,safe_not_equal,{viewId:0,selectedItemId:12,newShape:11,stage:13,images:14,polygonDetails:1,color:2,zoomFactor:3})}}function get_each_context$4(c,e,n){const r=c.slice();return r[76]=e[n],r}function get_each_context_1$1(c,e,n){const r=c.slice();return r[79]=e[n],r}function create_if_block_1$8(c){let e,n;function r(...i){return c[33](c[76],...i)}return e=new Layer({props:{config:{id:c[76].id},$$slots:{default:[create_default_slot_1$5]},$$scope:{ctx:c}}}),e.$on("wheel",r),{c(){create_component(e.$$.fragment)},l(i){claim_component(e.$$.fragment,i)},m(i,o){mount_component(e,i,o),n=!0},p(i,o){c=i;const a={};o[0]&2&&(a.config={id:c[76].id}),o[0]&1431|o[2]&1048576&&(a.$$scope={dirty:o,ctx:c}),e.$set(a)},i(i){n||(transition_in(e.$$.fragment,i),n=!0)},o(i){transition_out(e.$$.fragment,i),n=!1},d(i){destroy_component(e,i)}}}function create_if_block_2$6(c){let e,n,r;function i(a){c[32](a)}let o={viewId:c[76].id,selectedItemId:c[1].id,stage:c[2],images:c[10],polygonDetails:c[79],color:c[4](c[79].id),zoomFactor:c[7]};return c[0]!==void 0&&(o.newShape=c[0]),e=new PolygonGroup({props:o}),binding_callbacks.push(()=>bind(e,"newShape",i)),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,d){mount_component(e,a,d),r=!0},p(a,d){const f={};d[0]&2&&(f.viewId=a[76].id),d[0]&2&&(f.selectedItemId=a[1].id),d[0]&4&&(f.stage=a[2]),d[0]&1024&&(f.images=a[10]),d[0]&256&&(f.polygonDetails=a[79]),d[0]&272&&(f.color=a[4](a[79].id)),d[0]&128&&(f.zoomFactor=a[7]),!n&&d[0]&1&&(n=!0,f.newShape=a[0],add_flush_callback(()=>n=!1)),e.$set(f)},i(a){r||(transition_in(e.$$.fragment,a),r=!0)},o(a){transition_out(e.$$.fragment,a),r=!1},d(a){destroy_component(e,a)}}}function create_key_block$1(c){let e,n,r=c[79].viewId===c[76].id&&create_if_block_2$6(c);return{c(){r&&r.c(),e=empty()},l(i){r&&r.l(i),e=empty()},m(i,o){r&&r.m(i,o),insert_hydration(i,e,o),n=!0},p(i,o){i[79].viewId===i[76].id?r?(r.p(i,o),o[0]&258&&transition_in(r,1)):(r=create_if_block_2$6(i),r.c(),transition_in(r,1),r.m(e.parentNode,e)):r&&(group_outros(),transition_out(r,1,1,()=>{r=null}),check_outros())},i(i){n||(transition_in(r),n=!0)},o(i){transition_out(r),n=!1},d(i){i&&detach(e),r&&r.d(i)}}}function create_each_block_1$1(c){let e=c[79].id,n,r,i=create_key_block$1(c);return{c(){i.c(),n=empty()},l(o){i.l(o),n=empty()},m(o,a){i.m(o,a),insert_hydration(o,n,a),r=!0},p(o,a){a[0]&256&&safe_not_equal(e,e=o[79].id)?(group_outros(),transition_out(i,1,1,noop),check_outros(),i=create_key_block$1(o),i.c(),transition_in(i,1),i.m(n.parentNode,n)):i.p(o,a)},i(o){r||(transition_in(i),r=!0)},o(o){transition_out(i),r=!1},d(o){o&&detach(n),i.d(o)}}}function create_default_slot_1$5(c){let e,n,r,i,o,a,d,f,h,p,s,t;function l(...y){return c[29](c[76],...y)}function u(){return c[30](c[76])}function g(){return c[31](c[76])}e=new Image$1({props:{config:{image:c[10][c[76].id],id:`image-${c[76].id}`}}}),e.$on("pointerdown",l),e.$on("pointerup",u),e.$on("dblclick",g),r=new Group({props:{config:{id:"currentAnnotation"}}}),o=new Group({props:{config:{id:"masks"}}}),d=new Group({props:{config:{id:"bboxes"}}}),h=new Group({props:{config:{id:"input"}}});let m=ensure_array_like(c[8]),_=[];for(let y=0;y<m.length;y+=1)_[y]=create_each_block_1$1(get_each_context_1$1(c,m,y));const b=y=>transition_out(_[y],1,1,()=>{_[y]=null});return{c(){create_component(e.$$.fragment),n=space(),create_component(r.$$.fragment),i=space(),create_component(o.$$.fragment),a=space(),create_component(d.$$.fragment),f=space(),create_component(h.$$.fragment),p=space();for(let y=0;y<_.length;y+=1)_[y].c();s=empty()},l(y){claim_component(e.$$.fragment,y),n=claim_space(y),claim_component(r.$$.fragment,y),i=claim_space(y),claim_component(o.$$.fragment,y),a=claim_space(y),claim_component(d.$$.fragment,y),f=claim_space(y),claim_component(h.$$.fragment,y),p=claim_space(y);for(let v=0;v<_.length;v+=1)_[v].l(y);s=empty()},m(y,v){mount_component(e,y,v),insert_hydration(y,n,v),mount_component(r,y,v),insert_hydration(y,i,v),mount_component(o,y,v),insert_hydration(y,a,v),mount_component(d,y,v),insert_hydration(y,f,v),mount_component(h,y,v),insert_hydration(y,p,v);for(let T=0;T<_.length;T+=1)_[T]&&_[T].m(y,v);insert_hydration(y,s,v),t=!0},p(y,v){c=y;const T={};if(v[0]&1026&&(T.config={image:c[10][c[76].id],id:`image-${c[76].id}`}),e.$set(T),v[0]&1431){m=ensure_array_like(c[8]);let w;for(w=0;w<m.length;w+=1){const S=get_each_context_1$1(c,m,w);_[w]?(_[w].p(S,v),transition_in(_[w],1)):(_[w]=create_each_block_1$1(S),_[w].c(),transition_in(_[w],1),_[w].m(s.parentNode,s))}for(group_outros(),w=m.length;w<_.length;w+=1)b(w);check_outros()}},i(y){if(!t){transition_in(e.$$.fragment,y),transition_in(r.$$.fragment,y),transition_in(o.$$.fragment,y),transition_in(d.$$.fragment,y),transition_in(h.$$.fragment,y);for(let v=0;v<m.length;v+=1)transition_in(_[v]);t=!0}},o(y){transition_out(e.$$.fragment,y),transition_out(r.$$.fragment,y),transition_out(o.$$.fragment,y),transition_out(d.$$.fragment,y),transition_out(h.$$.fragment,y),_=_.filter(Boolean);for(let v=0;v<_.length;v+=1)transition_out(_[v]);t=!1},d(y){y&&(detach(n),detach(i),detach(a),detach(f),detach(p),detach(s)),destroy_component(e,y),destroy_component(r,y),destroy_component(o,y),destroy_component(d,y),destroy_component(h,y),destroy_each(_,y)}}}function create_each_block$4(c){let e,n,r=c[10][c[76].id]&&create_if_block_1$8(c);return{c(){r&&r.c(),e=empty()},l(i){r&&r.l(i),e=empty()},m(i,o){r&&r.m(i,o),insert_hydration(i,e,o),n=!0},p(i,o){i[10][i[76].id]?r?(r.p(i,o),o[0]&1026&&transition_in(r,1)):(r=create_if_block_1$8(i),r.c(),transition_in(r,1),r.m(e.parentNode,e)):r&&(group_outros(),transition_out(r,1,1,()=>{r=null}),check_outros())},i(i){n||(transition_in(r),n=!0)},o(i){transition_out(r),n=!1},d(i){i&&detach(e),r&&r.d(i)}}}function create_default_slot$7(c){let e,n,r,i,o=ensure_array_like(Object.values(c[1].views)),a=[];for(let p=0;p<o.length;p+=1)a[p]=create_each_block$4(get_each_context$4(c,o,p));const d=p=>transition_out(a[p],1,1,()=>{a[p]=null});function f(p){c[34](p)}let h={config:{name:"tools"}};return c[11]!==void 0&&(h.handle=c[11]),n=new Layer({props:h}),binding_callbacks.push(()=>bind(n,"handle",f)),{c(){for(let p=0;p<a.length;p+=1)a[p].c();e=space(),create_component(n.$$.fragment)},l(p){for(let s=0;s<a.length;s+=1)a[s].l(p);e=claim_space(p),claim_component(n.$$.fragment,p)},m(p,s){for(let t=0;t<a.length;t+=1)a[t]&&a[t].m(p,s);insert_hydration(p,e,s),mount_component(n,p,s),i=!0},p(p,s){if(s[0]&984471){o=ensure_array_like(Object.values(p[1].views));let l;for(l=0;l<o.length;l+=1){const u=get_each_context$4(p,o,l);a[l]?(a[l].p(u,s),transition_in(a[l],1)):(a[l]=create_each_block$4(u),a[l].c(),transition_in(a[l],1),a[l].m(e.parentNode,e))}for(group_outros(),l=o.length;l<a.length;l+=1)d(l);check_outros()}const t={};!r&&s[0]&2048&&(r=!0,t.handle=p[11],add_flush_callback(()=>r=!1)),n.$set(t)},i(p){if(!i){for(let s=0;s<o.length;s+=1)transition_in(a[s]);transition_in(n.$$.fragment,p),i=!0}},o(p){a=a.filter(Boolean);for(let s=0;s<a.length;s+=1)transition_out(a[s]);transition_out(n.$$.fragment,p),i=!1},d(p){p&&detach(e),destroy_each(a,p),destroy_component(n,p)}}}function create_if_block$b(c){let e,n;return e=new WarningModal({props:{message:"No embeddings found for view '"+c[6]+"'."}}),e.$on("confirm",c[38]),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p(r,i){const o={};i[0]&64&&(o.message="No embeddings found for view '"+r[6]+"'."),e.$set(o)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_fragment$d(c){let e,n,r,i,o,a,d,f,h,p;function s(g){c[35](g)}function t(g){c[36](g)}let l={$$slots:{default:[create_default_slot$7]},$$scope:{ctx:c}};c[12]!==void 0&&(l.config=c[12]),c[2]!==void 0&&(l.handle=c[2]),n=new Stage({props:l}),binding_callbacks.push(()=>bind(n,"config",s)),binding_callbacks.push(()=>bind(n,"handle",t)),n.$on("mousemove",c[13]),n.$on("mouseenter",c[14]),n.$on("mouseleave",c[15]);let u=c[5]&&create_if_block$b(c);return{c(){e=element("div"),create_component(n.$$.fragment),a=space(),u&&u.c(),d=empty(),this.h()},l(g){e=claim_element(g,"DIV",{class:!0});var m=children(e);claim_component(n.$$.fragment,m),m.forEach(detach),a=claim_space(g),u&&u.l(g),d=empty(),this.h()},h(){attr(e,"class",o=cn("flex h-full w-full bg-slate-100 transition-opacity duration-300 delay-100",{"opacity-0":!c[3]}))},m(g,m){insert_hydration(g,e,m),mount_component(n,e,null),c[37](e),insert_hydration(g,a,m),u&&u.m(g,m),insert_hydration(g,d,m),f=!0,h||(p=listen(window,"keydown",c[20]),h=!0)},p(g,m){const _={};m[0]&3479|m[2]&1048576&&(_.$$scope={dirty:m,ctx:g}),!r&&m[0]&4096&&(r=!0,_.config=g[12],add_flush_callback(()=>r=!1)),!i&&m[0]&4&&(i=!0,_.handle=g[2],add_flush_callback(()=>i=!1)),n.$set(_),(!f||m[0]&8&&o!==(o=cn("flex h-full w-full bg-slate-100 transition-opacity duration-300 delay-100",{"opacity-0":!g[3]})))&&attr(e,"class",o),g[5]?u?(u.p(g,m),m[0]&32&&transition_in(u,1)):(u=create_if_block$b(g),u.c(),transition_in(u,1),u.m(d.parentNode,d)):u&&(group_outros(),transition_out(u,1,1,()=>{u=null}),check_outros())},i(g){f||(transition_in(n.$$.fragment,g),transition_in(u),f=!0)},o(g){transition_out(n.$$.fragment,g),transition_out(u),f=!1},d(g){g&&(detach(e),detach(a),detach(d)),destroy_component(n),c[37](null),u&&u.d(g),h=!1,p()}}}function zoom(c,e,n){const i=c.findOne(`#${n}`),o=i.scaleX(),a=c.getRelativePointerPosition(),d={x:(a.x-i.x())/o,y:(a.y-i.y())/o},f=e>0?o*1.05:o/1.05,h={x:a.x-d.x*f,y:a.y-d.y*f};return i.scale({x:f,y:f}),i.position(h),f}function instance$d(c,e,n){let{selectedItem:r}=e,{colorRange:i=["0","10"]}=e,{masks:o}=e,{bboxes:a}=e,{embeddings:d={}}=e,{currentAnn:f=null}=e,{selectedTool:h}=e,{newShape:p}=e,s=!1,t,l=!1,u="",g,m,_={},b,y,v,T={},w,S,x=null,P=new Konva.Transformer({id:"transformer",rotateEnabled:!1}),I={width:1024,height:780,name:"konva",id:"stage"},N={rows:0,cols:0},L;const E=new ResizeObserver(D=>{for(const j of D)if(j.target===v){let Y,Q;if(j.contentBoxSize){const ne=j.contentBoxSize instanceof ResizeObserverSize?j.contentBoxSize:j.contentBoxSize[0];Y=ne.inlineSize,Q=ne.blockSize}else Y=j.contentRect.width,Q=j.contentRect.height;w.width(Y),w.height(Q),w.batchDraw()}});onMount(()=>{M(),E.observe(v)}),onDestroy(()=>{Ee()}),afterUpdate(()=>{L!==r.id&&M(),h?te():w.container().style.cursor="default",f&&f.validated&&X();for(const D of Object.keys(r.views)){const j=w.findOne(`#${D}`);j&&j.add(P),a&&Z(D)}});function M(){N.cols=Math.ceil(Math.sqrt(Object.keys(r.views).length)),N.rows=Math.ceil(Object.keys(r.views).length/N.cols),L&&Ee();for(const D of Object.values(r.views))n(7,_[D.id]=1,_),n(10,T[D.id]=new Image,T),n(10,T[D.id].src=`/${D.uri}`||D.url,T),n(10,T[D.id].onload=()=>{L&&w.findOne(`#${D.id}`).findOne(`#image-${D.id}`).image(T[D.id]),k(D),A(D),n(3,s=!0),n(21,o),n(22,a)},T);L=r.id}function k(D){const j=w.findOne(`#${D.id}`);if(j){const Y=w.width()/N.cols,Q=w.height()/N.rows;let ne=0;for(const Le of Object.keys(r.views)){if(Le===D.id)break;ne++}const ie={x:ne%N.cols,y:Math.floor(ne/N.cols)},ue=Q/T[D.id].height,Se=Y/T[D.id].width,B=Math.min(Se,ue);n(7,_[D.id]=B,_),j.scale({x:B,y:B});const de=(Y-T[D.id].width*B)/2+ie.x*Y,me=(Q-T[D.id].height*B)/2+ie.y*Q;j.x(de),j.y(me)}else console.log("Canvas2D.scaleView - Error: Cannot scale")}function A(D){const j=w.findOne(`#${D.id}`),Y=j.findOne("#input");for(const ue of Y.children)ue instanceof Konva.Circle&&(ue.radius(INPUTPOINT_RADIUS/_[D.id]),ue.strokeWidth(INPUTPOINT_STROKEWIDTH/_[D.id])),ue instanceof Konva.Rect&&ue.strokeWidth(INPUTRECT_STROKEWIDTH/_[D.id]);const Q=j.findOne("#bboxes");if(!Q)return;for(const ue of Q.children)if(ue instanceof Konva.Group)for(const Se of ue.children)Se instanceof Konva.Rect&&Se.strokeWidth(BBOX_STROKEWIDTH/_[D.id]),Se instanceof Konva.Label&&Se.scale({x:1/_[D.id],y:1/_[D.id]});const ne=j.findOne("#masks");for(const ue of ne.children)ue instanceof Konva.Shape&&ue.strokeWidth(MASK_STROKEWIDTH/_[D.id]);const ie=findOrCreateCurrentMask(D.id,w);for(const ue of ie.children)ue instanceof Konva.Shape&&ue.strokeWidth(MASK_STROKEWIDTH/_[D.id])}function R(D){let j;return D.getAncestors().forEach(Y=>{Y instanceof Konva.Layer&&(j=Y.id())}),j}function K(D,j,Y){const Q=getNewRectangleDimensions(D,T[Y]);n(0,p={status:"editing",type:"rectangle",rectangleId:a[j].id,coords:Q})}function Z(D){const j=w.findOne(`#${D}`);if(j){const Y=j.findOne("#bboxes"),Q=j.findOne(`#image-${r.views[D].id}`),ne=[];if(!Y)return;for(let ie=0;ie<a.length;++ie)if(a[ie].viewId===D){ne.push(a[ie].id);const ue=Y.findOne(`#${a[ie].id}`);if(!ue)addBBox(a[ie],t(a[ie].id),Y,Q,D,_,Se=>K(Se,ie,D));else{toggleIsEditingBBox(a[ie].editing?"on":"off",w,a[ie],a),toggleBBoxIsLocked(w,a[ie]),ue.visible(a[ie].visible),ue.opacity(a[ie].opacity);const Se=new Option().style;Se.color=t(a[ie].id);const B=Y.findOne(`#text${a[ie].id}`);B&&B.setAttr("text",a[ie].tooltip);for(const de of ue.children)de instanceof Konva.Rect&&de.stroke(Se.color),de instanceof Konva.Label&&(de.getTag().fill(Se.color),de.getTag().stroke())}}destroyDeletedObjects(ne,Y)}}async function J(D){const j=Re(D),Y=Ce(D),Q={image:T[D],embedding:D in d?d[D]:null,points:j,box:Y};if(h.postProcessor==null)Ee();else if(d[D]==null)n(5,l=!0),n(6,u=D),Ee();else{const ne=await h.postProcessor.segmentImage(Q);if(ne){n(0,p={masksImageSVG:ne.masksImageSVG,rle:ne.rle,type:"mask",viewId:D,itemId:r.id,imageWidth:T[D].width,imageHeight:T[D].height,status:"inProgress"});const ie=findOrCreateCurrentMask(D,w),Se=w.findOne(`#${D}`).findOne(`#image-${D}`);ie.removeChildren(),n(23,f={id:nanoid(10),viewId:D,label:"",catId:-1,output:ne,input_points:j,input_box:Y,validated:!1});const B={id:f.id,viewId:D,svg:f.output.masksImageSVG,rle:f.output.rle,catId:f.catId,visible:!0,opacity:1};addMask(B,"#008000",ie,Se,D,w,_)}}}function X(){if(f.validated){const D=findOrCreateCurrentMask(f.viewId,w);D&&D.destroyChildren(),x&&Oe(x),oe(f.viewId),n(23,f=null)}}function te(){switch(S&&S.moveToTop(),h.type){case"POINT_SELECTION":he(h);break;case"RECTANGLE":Pe(h);break;case"DELETE":Ee(),ke(h);break;case"PAN":ce(h);break;case"CLASSIFICATION":fe(h);break}}function oe(D){const j=w==null?void 0:w.findOne(`#${D}`);j&&j.findOne("#input").destroyChildren()}function ae(D){if((p==null?void 0:p.status)==="inProgress")return;const Y=w.findOne(`#${D}`).getRelativePointerPosition(),Q=Math.round(Y.x),ne=Math.round(Y.y);n(8,b=b.map(ie=>ie.status==="created"?ie:{...ie,points:[...ie.points,{x:Q,y:ne,id:ie.points.length}],viewId:D}))}function ce(D){if(S){const j=w.findOne(`#${POINT_SELECTION}`);j&&j.destroy();const Y=w.findOne("#crossline");Y&&Y.destroy(),x||(w.container().style.cursor=D.cursor),be(!1)}}function fe(D){if(S){const j=w.findOne(`#${POINT_SELECTION}`);j&&j.destroy();const Y=w.findOne("#crossline");Y&&Y.destroy(),x||(w.container().style.cursor=D.cursor),be(!1)}}function he(D){if(S){const j=S.findOne("#crossline");j&&j.destroy();const Y=we(D.type),Q=D.label===1?"green":"red";Y.stroke(Q),x||(w.container().style.cursor=D.cursor),be(!0)}}function xe(D){const j=we(h.type),Y=w.scaleX(),Q=Math.max(1,1/Y);j.scaleX(Q),j.scaleY(Q),j.x(D.x+1),j.y(D.y+1)}function we(D,j=null){let Y=w.findOne(`#${D}`);if(!Y){let Q=1;j&&(Q=_[j]),Y=new Konva.Circle({id:D,x:0,y:0,radius:INPUTPOINT_RADIUS/Q,fill:"white",strokeWidth:INPUTPOINT_STROKEWIDTH/Q,visible:!1,listening:!1,opacity:.5}),S.add(Y)}return Y}function Re(D){const j=[],Q=w.findOne(`#${D}`).findOne("#input");for(const ne of Q.children)if(ne instanceof Konva.Circle){const ie={x:ne.x(),y:ne.y(),label:parseInt(ne.name())};j.push(ie)}return j}function be(D){const j=w.find("#input");for(const Y of j)for(const Q of Y.children)Q instanceof Konva.Circle&&Q.listening(D)}function Ne(){w.container().style.cursor="grab"}function ge(D,j){w.container().style.cursor="grabbing";const ne=w.findOne(`#${j}`).findOne(`#image-${j}`).getSize();D.x()<0?D.x(0):D.x()>ne.width&&D.x(ne.width),D.y()<0?D.y(0):D.y()>ne.height&&D.y(ne.height),clearTimeout(y),y=setTimeout(()=>J(j),50)}function ye(D,j){we(h.type,j).hide(),D.radius(1.5*INPUTPOINT_RADIUS/_[j]),x=D,w.container().style.cursor="grab"}function Oe(D,j=null){we(h.type,j).show(),j||(j=R(D)),D.radius(INPUTPOINT_RADIUS/_[j]),x=null,w.container().style.cursor=h.cursor,w.batchDraw()}function Pe(D){if(S){const j=w.findOne(`#${POINT_SELECTION}`);j&&j.destroy(),x||(w.container().style.cursor=D.cursor),be(!0)}}function Ae(D){const j=w.scaleX(),Y=Math.max(1,1/j),[Q,ne]=$e(),ie=w.height();Q.scaleY(Y),Q.points([D.x,0,D.x,ie]);const ue=w.width();ne.scaleX(Y),ne.points([0,D.y,ue,D.y])}function $e(){const D=w.height(),j=w.width();let Y=S.findOne("#crossline"),Q,ne;return Y?(Q=Y.findOne("#xline"),ne=Y.findOne("#yline")):(Y=new Konva.Group({id:"crossline"}),Q=new Konva.Line({id:"xline",points:[0,0,0,D],stroke:"white",strokeWidth:1,opacity:.75,dash:[5,1]}),ne=new Konva.Line({id:"yline",points:[0,0,j,0],stroke:"white",strokeWidth:1,opacity:.75,dash:[5,1]}),Y.add(Q),Y.add(ne),S.add(Y)),[Q,ne]}function Ce(D){let j=null;const Q=w.findOne(`#${D}`).findOne("#input");for(const ne of Q.children)if(ne instanceof Konva.Rect){const ie=ne.size(),ue=ne.position();j={x:ue.x,y:ue.y,width:ie.width,height:ie.height};break}return j}function Ge(D){if((h==null?void 0:h.type)==="RECTANGLE"){n(0,p={status:"none"});const j=w.findOne(`#${D}`),Q=j.findOne("#input").findOne("#drag-rect");if(Q){const ne=j.getRelativePointerPosition();Q.width(ne.x-Q.x()),Q.size({width:ne.x-Q.x(),height:ne.y-Q.y()})}}}async function je(D){if((h==null?void 0:h.type)=="RECTANGLE"){const j=w.findOne(`#${D}`),Q=j.findOne("#input").findOne("#drag-rect");if(Q){const{width:ne,height:ie}=Q.size();ne==0||ie==0?Q.destroy():(h.isSmart||n(0,p={status:"inProgress",attrs:{x:Q.x(),y:Q.y(),width:Q.width(),height:Q.height()},type:"rectangle",viewId:D,itemId:r.id,imageWidth:T[D].width,imageHeight:T[D].height}),h.isSmart&&await J(D)),j.off("pointermove"),j.off("pointerup")}}}function ke(D){if(S){const j=w.findOne(`#${POINT_SELECTION}`);j&&j.destroy();const Y=w.findOne("#crossline");Y&&Y.destroy(),x||(w.container().style.cursor=D.cursor),be(!1)}}function Ee(){if(!w)return;n(8,b=b.map(Y=>Y.status==="created"?Y:{...Y,points:[]}));for(const Y of Object.keys(r.views))oe(Y),clearCurrentAnn(Y,w,h);h&&(w.container().style.cursor=h.cursor);const D=w.findOne(`#${POINT_SELECTION}`);D&&D.destroy();const j=S==null?void 0:S.findOne("#crossline");j&&j.destroy(),n(23,f=null)}function ze(){const D=w.getRelativePointerPosition();(h==null?void 0:h.type)==="POINT_SELECTION"&&xe(D),(h==null?void 0:h.type)==="RECTANGLE"&&Ae(D)}function et(){for(const D of S.children)D.show()}function Ve(){for(const D of S.children)D.hide()}function Ze(D){const j=w.findOne(`#${D}`);j.draggable(!1),j.off("dragend dragmove")}function He(D){const j=w.findOne(`#${D}`);if(j.draggable(!1),j.off("dragend dragmove"),(h==null?void 0:h.type)==="POLYGON"&&ae(D),x){const Y=j.getRelativePointerPosition(),Q=x.position();(Y.x!==Q.x||Y.y!==Q.y)&&Oe(x,D)}}function We(D){w.findOne(`#${D}`).moveToTop(),S.moveToTop()}async function Ye(D,j){const Y=w.findOne(`#${j}`);if((h==null?void 0:h.type)=="PAN"||D.button==1)Y.draggable(!0),Y.on("dragmove",ze),Y.on("dragend",()=>Ze(j));else if((h==null?void 0:h.type)=="POINT_SELECTION"){const Q=Y.getRelativePointerPosition(),ne=new Konva.Circle({name:`${h.label}`,x:Q.x,y:Q.y,radius:INPUTPOINT_RADIUS/_[j],stroke:"white",fill:h.label===1?"green":"red",strokeWidth:INPUTPOINT_STROKEWIDTH/_[j],visible:!0,listening:!0,opacity:.75,draggable:!0});ne.on("pointerenter",ue=>ye(ue.target,j)),ne.on("pointerout",ue=>Oe(ue.target,j)),ne.on("dragmove",ue=>void ge(ue.target,j)),ne.on("dragend",()=>Ne()),Y.findOne("#input").add(ne),ye(ne,j),await J(j)}else if((h==null?void 0:h.type)=="RECTANGLE"){const Q=Y.getRelativePointerPosition(),ne=Y.findOne("#input");let ie=ne.findOne("#drag-rect");ie?(ie.position({x:Q.x,y:Q.y}),ie.size({width:0,height:0})):(ie=new Konva.Rect({id:"drag-rect",x:Q.x+1,y:Q.y+1,width:0,height:0,stroke:"hsl(316deg 60% 29.41%)",fill:"#f9f4f773",strokeWidth:INPUTRECT_STROKEWIDTH/_[j],listening:!1}),ne.add(ie)),Y.on("pointermove",()=>Ge(j)),Y.on("pointerup",()=>void je(j))}}function qe(D,j){D.preventDefault();let Y=D.deltaY<0?1:-1;D.ctrlKey&&(Y=-Y),n(7,_[j.id]=zoom(w,Y,j.id),_),A(j),x&&ye(x,j.id)}async function Ue(D){var j,Y;if(D.key=="Delete"&&x!=null){const Q=R(x),ne=x;Oe(x,Q),ne.destroy(),w.findOne(`#${Q}`).findOne("#input").children.length>0?await J(Q):clearCurrentAnn(Q,w,h)}if(D.key=="Escape"&&Ee(),D.key=="i"){console.log("Canvas2D - Infos"),console.log("masks",o),console.log("bboxes",a),console.log("currentAnn",f),console.log("stage",w);for(const Q of Object.keys(r.views)){const ne=w.findOne(`#${Q}`),ie=ne.findOne("#masks"),ue=ne.findOne("#bboxes");console.log("masks Konva group:",ie),console.log("masks children length:",(j=ie.children)==null?void 0:j.length),console.log("bboxes Konva group:",ue),console.log("bboxes children length:",(Y=ue.children)==null?void 0:Y.length)}}}const Xe=(D,j)=>Ye(j.detail.evt,D.id),Ke=D=>He(D.id),le=D=>We(D.id);function Be(D){p=D,n(0,p)}const Je=(D,j)=>qe(j.detail.evt,D);function $(D){S=D,n(11,S)}function U(D){I=D,n(12,I)}function V(D){w=D,n(2,w)}function q(D){binding_callbacks[D?"unshift":"push"](()=>{v=D,n(9,v)})}const ee=()=>n(5,l=!1);return c.$$set=D=>{"selectedItem"in D&&n(1,r=D.selectedItem),"colorRange"in D&&n(24,i=D.colorRange),"masks"in D&&n(21,o=D.masks),"bboxes"in D&&n(22,a=D.bboxes),"embeddings"in D&&n(25,d=D.embeddings),"currentAnn"in D&&n(23,f=D.currentAnn),"selectedTool"in D&&n(26,h=D.selectedTool),"newShape"in D&&n(0,p=D.newShape)},c.$$.update=()=>{if(c.$$.dirty[0]&2097152&&n(8,b=mapMaskPointsToLineCoordinates(o)),c.$$.dirty[0]&335544320&&((!(m!=null&&m.isSmart)||!(h!=null&&h.isSmart))&&Ee(),n(28,m=h)),c.$$.dirty[0]&16777216&&n(4,t=ordinalColorScale(i)),c.$$.dirty[0]&138412036){if(w&&g!==(a==null?void 0:a.length)){const D=w==null?void 0:w.findOne("#drag-rect");D&&D.destroy()}n(27,g=a.length)}},[p,r,w,s,t,l,u,_,b,v,T,S,I,ze,et,Ve,He,We,Ye,qe,Ue,o,a,f,i,d,h,g,m,Xe,Ke,le,Be,Je,$,U,V,q,ee]}class Canvas2D extends SvelteComponent{constructor(e){super(),init(this,e,instance$d,create_fragment$d,safe_not_equal,{selectedItem:1,colorRange:24,masks:21,bboxes:22,embeddings:25,currentAnn:23,selectedTool:26,newShape:0},null,[-1,-1,-1])}}function create_else_block$3(c){let e=c[4].id,n,r,i=create_key_block(c);return{c(){i.c(),n=empty()},l(o){i.l(o),n=empty()},m(o,a){i.m(o,a),insert_hydration(o,n,a),r=!0},p(o,a){a&16&&safe_not_equal(e,e=o[4].id)?(group_outros(),transition_out(i,1,1,noop),check_outros(),i=create_key_block(o),i.c(),transition_in(i,1),i.m(n.parentNode,n)):i.p(o,a)},i(o){r||(transition_in(i),r=!0)},o(o){transition_out(i),r=!1},d(o){o&&detach(n),i.d(o)}}}function create_if_block$a(c){let e,n,r;return n=new Loader_2({props:{class:"animate-spin"}}),{c(){e=element("div"),create_component(n.$$.fragment),this.h()},l(i){e=claim_element(i,"DIV",{class:!0});var o=children(e);claim_component(n.$$.fragment,o),o.forEach(detach),this.h()},h(){attr(e,"class","h-full w-full flex justify-center items-center")},m(i,o){insert_hydration(i,e,o),mount_component(n,e,null),r=!0},p:noop,i(i){r||(transition_in(n.$$.fragment,i),r=!0)},o(i){transition_out(n.$$.fragment,i),r=!1},d(i){i&&detach(e),destroy_component(n)}}}function create_key_block(c){let e,n,r,i,o,a,d;function f(u){c[9](u)}function h(u){c[10](u)}function p(u){c[11](u)}function s(u){c[12](u)}function t(u){c[13](u)}let l={selectedItem:c[4],colorRange:c[8],embeddings:c[5]};return c[0]!==void 0&&(l.masks=c[0]),c[1]!==void 0&&(l.bboxes=c[1]),c[2]!==void 0&&(l.selectedTool=c[2]),c[3]!==void 0&&(l.currentAnn=c[3]),c[7]!==void 0&&(l.newShape=c[7]),e=new Canvas2D({props:l}),binding_callbacks.push(()=>bind(e,"masks",f)),binding_callbacks.push(()=>bind(e,"bboxes",h)),binding_callbacks.push(()=>bind(e,"selectedTool",p)),binding_callbacks.push(()=>bind(e,"currentAnn",s)),binding_callbacks.push(()=>bind(e,"newShape",t)),{c(){create_component(e.$$.fragment)},l(u){claim_component(e.$$.fragment,u)},m(u,g){mount_component(e,u,g),d=!0},p(u,g){const m={};g&16&&(m.selectedItem=u[4]),g&256&&(m.colorRange=u[8]),g&32&&(m.embeddings=u[5]),!n&&g&1&&(n=!0,m.masks=u[0],add_flush_callback(()=>n=!1)),!r&&g&2&&(r=!0,m.bboxes=u[1],add_flush_callback(()=>r=!1)),!i&&g&4&&(i=!0,m.selectedTool=u[2],add_flush_callback(()=>i=!1)),!o&&g&8&&(o=!0,m.currentAnn=u[3],add_flush_callback(()=>o=!1)),!a&&g&128&&(a=!0,m.newShape=u[7],add_flush_callback(()=>a=!1)),e.$set(m)},i(u){d||(transition_in(e.$$.fragment,u),d=!0)},o(u){transition_out(e.$$.fragment,u),d=!1},d(u){destroy_component(e,u)}}}function create_fragment$c(c){let e,n,r,i;const o=[create_if_block$a,create_else_block$3],a=[];function d(f,h){return f[6]?0:1}return n=d(c),r=a[n]=o[n](c),{c(){e=element("div"),r.c(),this.h()},l(f){e=claim_element(f,"DIV",{class:!0});var h=children(e);r.l(h),h.forEach(detach),this.h()},h(){attr(e,"class","max-w-[100%]")},m(f,h){insert_hydration(f,e,h),a[n].m(e,null),i=!0},p(f,[h]){let p=n;n=d(f),n===p?a[n].p(f,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),r=a[n],r?r.p(f,h):(r=a[n]=o[n](f),r.c()),transition_in(r,1),r.m(e,null))},i(f){i||(transition_in(r),i=!0)},o(f){transition_out(r),i=!1},d(f){f&&detach(e),a[n].d()}}}function instance$c(c,e,n){let{selectedItem:r}=e,{masks:i=[]}=e,{bboxes:o=[]}=e,{embeddings:a}=e,{selectedTool:d}=e,{currentAnn:f=null}=e,{isLoading:h}=e,p,s=[];itemObjects.subscribe(_=>{n(8,s=_.map(b=>b.id))});function t(_){i=_,n(0,i)}function l(_){o=_,n(1,o)}function u(_){d=_,n(2,d)}function g(_){f=_,n(3,f)}function m(_){p=_,n(7,p)}return c.$$set=_=>{"selectedItem"in _&&n(4,r=_.selectedItem),"masks"in _&&n(0,i=_.masks),"bboxes"in _&&n(1,o=_.bboxes),"embeddings"in _&&n(5,a=_.embeddings),"selectedTool"in _&&n(2,d=_.selectedTool),"currentAnn"in _&&n(3,f=_.currentAnn),"isLoading"in _&&n(6,h=_.isLoading)},c.$$.update=()=>{c.$$.dirty&128&&(newShape.set(p),(p==null?void 0:p.status)==="editing"&&(itemObjects.update(_=>updateExistingObject(_,p)),canSave.set(!0)))},newShape.subscribe(_=>{n(7,p=_)}),[i,o,d,f,r,a,h,p,s,t,l,u,g,m]}class ImageCanvas extends SvelteComponent{constructor(e){super(),init(this,e,instance$c,create_fragment$c,safe_not_equal,{selectedItem:4,masks:0,bboxes:1,embeddings:5,selectedTool:2,currentAnn:3,isLoading:6})}}function create_if_block_2$5(c){let e,n=c[0].value+"",r;return{c(){e=element("p"),r=text(n),this.h()},l(i){e=claim_element(i,"P",{class:!0});var o=children(e);r=claim_text(o,n),o.forEach(detach),this.h()},h(){attr(e,"class","font-light rounded-xl bg-primary-light first-letter:uppercase flex justify-center items-center h-6 py-1 px-3")},m(i,o){insert_hydration(i,e,o),append_hydration(e,r)},p(i,o){o&1&&n!==(n=i[0].value+"")&&set_data(r,n)},i:noop,o:noop,d(i){i&&detach(e)}}}function create_if_block$9(c){let e,n,r,i;e=new Input({props:{value:c[0].value,type:c[2]==="str"?"text":"number",step:c[2]==="int"?"1":"any"}}),e.$on("change",c[6]),e.$on("input",c[7]),e.$on("keyup",keyup_handler$1);let o=c[3]&&create_if_block_1$7();return{c(){create_component(e.$$.fragment),n=space(),o&&o.c(),r=empty()},l(a){claim_component(e.$$.fragment,a),n=claim_space(a),o&&o.l(a),r=empty()},m(a,d){mount_component(e,a,d),insert_hydration(a,n,d),o&&o.m(a,d),insert_hydration(a,r,d),i=!0},p(a,d){const f={};d&1&&(f.value=a[0].value),d&4&&(f.type=a[2]==="str"?"text":"number"),d&4&&(f.step=a[2]==="int"?"1":"any"),e.$set(f),a[3]?o?d&8&&transition_in(o,1):(o=create_if_block_1$7(),o.c(),transition_in(o,1),o.m(r.parentNode,r)):o&&(group_outros(),transition_out(o,1,1,()=>{o=null}),check_outros())},i(a){i||(transition_in(e.$$.fragment,a),transition_in(o),i=!0)},o(a){transition_out(e.$$.fragment,a),transition_out(o),i=!1},d(a){a&&(detach(n),detach(r)),destroy_component(e,a),o&&o.d(a)}}}function create_if_block_1$7(c){let e,n,r;return n=new Check_check({}),{c(){e=element("span"),create_component(n.$$.fragment),this.h()},l(i){e=claim_element(i,"SPAN",{class:!0});var o=children(e);claim_component(n.$$.fragment,o),o.forEach(detach),this.h()},h(){attr(e,"class","text-green-700")},m(i,o){insert_hydration(i,e,o),mount_component(n,e,null),r=!0},i(i){r||(transition_in(n.$$.fragment,i),r=!0)},o(i){transition_out(n.$$.fragment,i),r=!1},d(i){i&&detach(e),destroy_component(n)}}}function create_fragment$b(c){let e,n,r,i;const o=[create_if_block$9,create_if_block_2$5],a=[];function d(f,h){return f[1]?0:f[0].value||f[0].value===0?1:-1}return~(n=d(c))&&(r=a[n]=o[n](c)),{c(){e=element("div"),r&&r.c(),this.h()},l(f){e=claim_element(f,"DIV",{class:!0});var h=children(e);r&&r.l(h),h.forEach(detach),this.h()},h(){attr(e,"class","flex justify-start items-center gap-4")},m(f,h){insert_hydration(f,e,h),~n&&a[n].m(e,null),i=!0},p(f,[h]){let p=n;n=d(f),n===p?~n&&a[n].p(f,h):(r&&(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros()),~n?(r=a[n],r?r.p(f,h):(r=a[n]=o[n](f),r.c()),transition_in(r,1),r.m(e,null)):r=null)},i(f){i||(transition_in(r),i=!0)},o(f){transition_out(r),i=!1},d(f){f&&detach(e),~n&&a[n].d()}}}const keyup_handler$1=c=>c.stopPropagation();function instance$b(c,e,n){let{textFeature:r}=e,{isEditing:i}=e,{saveInputChange:o}=e,{inputType:a="str"}=e,d=!1;const f=(s,t)=>{let l=s;a==="int"?l=Math.round(Number(s)):a==="float"&&(l=Number(s)),o(l,t),n(3,d=!0)},h=s=>f(s.currentTarget.value,r.name),p=()=>n(3,d=!1);return c.$$set=s=>{"textFeature"in s&&n(0,r=s.textFeature),"isEditing"in s&&n(1,i=s.isEditing),"saveInputChange"in s&&n(5,o=s.saveInputChange),"inputType"in s&&n(2,a=s.inputType)},[r,i,a,d,f,o,h,p]}class TextInputFeature extends SvelteComponent{constructor(e){super(),init(this,e,instance$b,create_fragment$b,safe_not_equal,{textFeature:0,isEditing:1,saveInputChange:5,inputType:2})}}function create_if_block_1$6(c){let e,n=c[0].value+"",r;return{c(){e=element("p"),r=text(n),this.h()},l(i){e=claim_element(i,"P",{class:!0});var o=children(e);r=claim_text(o,n),o.forEach(detach),this.h()},h(){attr(e,"class","font-light rounded-xl bg-primary-light first-letter:uppercase flex justify-center items-center h-6 py-1 px-3 w-min")},m(i,o){insert_hydration(i,e,o),append_hydration(e,r)},p(i,o){o&1&&n!==(n=i[0].value+"")&&set_data(r,n)},i:noop,o:noop,d(i){i&&detach(e)}}}function create_if_block$8(c){let e,n;return e=new Combobox({props:{placeholder:`Select a ${c[0].name}`,listItems:c[0].options,saveValue:c[3],value:c[0].value}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p(r,i){const o={};i&1&&(o.placeholder=`Select a ${r[0].name}`),i&1&&(o.listItems=r[0].options),i&5&&(o.saveValue=r[3]),i&1&&(o.value=r[0].value),e.$set(o)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_fragment$a(c){let e,n,r,i;const o=[create_if_block$8,create_if_block_1$6],a=[];function d(f,h){return f[1]?0:f[0].value?1:-1}return~(e=d(c))&&(n=a[e]=o[e](c)),{c(){n&&n.c(),r=empty()},l(f){n&&n.l(f),r=empty()},m(f,h){~e&&a[e].m(f,h),insert_hydration(f,r,h),i=!0},p(f,[h]){let p=e;e=d(f),e===p?~e&&a[e].p(f,h):(n&&(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros()),~e?(n=a[e],n?n.p(f,h):(n=a[e]=o[e](f),n.c()),transition_in(n,1),n.m(r.parentNode,r)):n=null)},i(f){i||(transition_in(n),i=!0)},o(f){transition_out(n),i=!1},d(f){f&&detach(r),~e&&a[e].d(f)}}}function instance$a(c,e,n){let{listFeature:r}=e,{isEditing:i}=e,{handleInputChange:o}=e;const a=d=>o(d,r.name);return c.$$set=d=>{"listFeature"in d&&n(0,r=d.listFeature),"isEditing"in d&&n(1,i=d.isEditing),"handleInputChange"in d&&n(2,o=d.handleInputChange)},[r,i,o,a]}class ListInputFeature extends SvelteComponent{constructor(e){super(),init(this,e,instance$a,create_fragment$a,safe_not_equal,{listFeature:0,isEditing:1,handleInputChange:2})}}function get_each_context$3(c,e,n){const r=c.slice();return r[6]=e[n],r}function create_if_block_3$2(c){let e,n=c[6].label.replace("_"," ")+"",r;return{c(){e=element("p"),r=text(n),this.h()},l(i){e=claim_element(i,"P",{class:!0});var o=children(e);r=claim_text(o,n),o.forEach(detach),this.h()},h(){attr(e,"class","font-bold first-letter:uppercase pb-1")},m(i,o){insert_hydration(i,e,o),append_hydration(e,r)},p(i,o){o&1&&n!==(n=i[6].label.replace("_"," ")+"")&&set_data(r,n)},d(i){i&&detach(e)}}}function create_if_block_2$4(c){let e,n;function r(...i){return c[3](c[6],...i)}return e=new Checkbox({props:{checked:!!c[6].value,disabled:!c[1],handleClick:r}}),{c(){create_component(e.$$.fragment)},l(i){claim_component(e.$$.fragment,i)},m(i,o){mount_component(e,i,o),n=!0},p(i,o){c=i;const a={};o&1&&(a.checked=!!c[6].value),o&2&&(a.disabled=!c[1]),o&5&&(a.handleClick=r),e.$set(a)},i(i){n||(transition_in(e.$$.fragment,i),n=!0)},o(i){transition_out(e.$$.fragment,i),n=!1},d(i){destroy_component(e,i)}}}function create_if_block_1$5(c){let e,n;return e=new ListInputFeature({props:{handleInputChange:c[4],isEditing:c[1],listFeature:{value:c[6].value,name:c[6].name,options:c[6].options}}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p(r,i){const o={};i&4&&(o.handleInputChange=r[4]),i&2&&(o.isEditing=r[1]),i&1&&(o.listFeature={value:r[6].value,name:r[6].name,options:r[6].options}),e.$set(o)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_if_block$7(c){let e,n;return e=new TextInputFeature({props:{saveInputChange:c[5],textFeature:{value:c[6].value,name:c[6].name},inputType:c[6].type,isEditing:c[1]}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p(r,i){const o={};i&4&&(o.saveInputChange=r[5]),i&1&&(o.textFeature={value:r[6].value,name:r[6].name}),i&1&&(o.inputType=r[6].type),i&2&&(o.isEditing=r[1]),e.$set(o)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_each_block$3(c){let e,n,r,i,o,a,d=(c[1]||c[6].value!==void 0)&&create_if_block_3$2(c),f=c[6].type==="bool"&&(c[6].value!==void 0||c[1])&&create_if_block_2$4(c),h=c[6].type==="list"&&create_if_block_1$5(c),p=(c[6].type==="str"||c[6].type==="int"||c[6].type==="float")&&create_if_block$7(c);return{c(){e=element("div"),d&&d.c(),n=space(),f&&f.c(),r=space(),h&&h.c(),i=space(),p&&p.c(),o=space(),this.h()},l(s){e=claim_element(s,"DIV",{class:!0});var t=children(e);d&&d.l(t),n=claim_space(t),f&&f.l(t),r=claim_space(t),h&&h.l(t),i=claim_space(t),p&&p.l(t),o=claim_space(t),t.forEach(detach),this.h()},h(){attr(e,"class","mt-1")},m(s,t){insert_hydration(s,e,t),d&&d.m(e,null),append_hydration(e,n),f&&f.m(e,null),append_hydration(e,r),h&&h.m(e,null),append_hydration(e,i),p&&p.m(e,null),append_hydration(e,o),a=!0},p(s,t){s[1]||s[6].value!==void 0?d?d.p(s,t):(d=create_if_block_3$2(s),d.c(),d.m(e,n)):d&&(d.d(1),d=null),s[6].type==="bool"&&(s[6].value!==void 0||s[1])?f?(f.p(s,t),t&3&&transition_in(f,1)):(f=create_if_block_2$4(s),f.c(),transition_in(f,1),f.m(e,r)):f&&(group_outros(),transition_out(f,1,1,()=>{f=null}),check_outros()),s[6].type==="list"?h?(h.p(s,t),t&1&&transition_in(h,1)):(h=create_if_block_1$5(s),h.c(),transition_in(h,1),h.m(e,i)):h&&(group_outros(),transition_out(h,1,1,()=>{h=null}),check_outros()),s[6].type==="str"||s[6].type==="int"||s[6].type==="float"?p?(p.p(s,t),t&1&&transition_in(p,1)):(p=create_if_block$7(s),p.c(),transition_in(p,1),p.m(e,o)):p&&(group_outros(),transition_out(p,1,1,()=>{p=null}),check_outros())},i(s){a||(transition_in(f),transition_in(h),transition_in(p),a=!0)},o(s){transition_out(f),transition_out(h),transition_out(p),a=!1},d(s){s&&detach(e),d&&d.d(),f&&f.d(),h&&h.d(),p&&p.d()}}}function create_fragment$9(c){let e,n,r=ensure_array_like(c[0]),i=[];for(let a=0;a<r.length;a+=1)i[a]=create_each_block$3(get_each_context$3(c,r,a));const o=a=>transition_out(i[a],1,1,()=>{i[a]=null});return{c(){for(let a=0;a<i.length;a+=1)i[a].c();e=empty()},l(a){for(let d=0;d<i.length;d+=1)i[d].l(a);e=empty()},m(a,d){for(let f=0;f<i.length;f+=1)i[f]&&i[f].m(a,d);insert_hydration(a,e,d),n=!0},p(a,[d]){if(d&7){r=ensure_array_like(a[0]);let f;for(f=0;f<r.length;f+=1){const h=get_each_context$3(a,r,f);i[f]?(i[f].p(h,d),transition_in(i[f],1)):(i[f]=create_each_block$3(h),i[f].c(),transition_in(i[f],1),i[f].m(e.parentNode,e))}for(group_outros(),f=r.length;f<i.length;f+=1)o(f);check_outros()}},i(a){if(!n){for(let d=0;d<r.length;d+=1)transition_in(i[d]);n=!0}},o(a){i=i.filter(Boolean);for(let d=0;d<i.length;d+=1)transition_out(i[d]);n=!1},d(a){a&&detach(e),destroy_each(i,a)}}}function instance$9(c,e,n){let{features:r}=e,{isEditing:i}=e,{saveInputChange:o}=e;const a=(h,p)=>o(p,h.name),d=(h,p)=>o(h,p),f=(h,p)=>o(h,p);return c.$$set=h=>{"features"in h&&n(0,r=h.features),"isEditing"in h&&n(1,i=h.isEditing),"saveInputChange"in h&&n(2,o=h.saveInputChange)},[r,i,o,a,d,f]}class FeatureInputs extends SvelteComponent{constructor(e){super(),init(this,e,instance$9,create_fragment$9,safe_not_equal,{features:0,isEditing:1,saveInputChange:2})}}var util;(function(c){c.assertEqual=i=>i;function e(i){}c.assertIs=e;function n(i){throw new Error}c.assertNever=n,c.arrayToEnum=i=>{const o={};for(const a of i)o[a]=a;return o},c.getValidEnumValues=i=>{const o=c.objectKeys(i).filter(d=>typeof i[i[d]]!="number"),a={};for(const d of o)a[d]=i[d];return c.objectValues(a)},c.objectValues=i=>c.objectKeys(i).map(function(o){return i[o]}),c.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const o=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&o.push(a);return o},c.find=(i,o)=>{for(const a of i)if(o(a))return a},c.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function r(i,o=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}c.joinValues=r,c.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(util||(util={}));var objectUtil;(function(c){c.mergeShapes=(e,n)=>({...e,...n})})(objectUtil||(objectUtil={}));const ZodParsedType=util.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),getParsedType=c=>{switch(typeof c){case"undefined":return ZodParsedType.undefined;case"string":return ZodParsedType.string;case"number":return isNaN(c)?ZodParsedType.nan:ZodParsedType.number;case"boolean":return ZodParsedType.boolean;case"function":return ZodParsedType.function;case"bigint":return ZodParsedType.bigint;case"symbol":return ZodParsedType.symbol;case"object":return Array.isArray(c)?ZodParsedType.array:c===null?ZodParsedType.null:c.then&&typeof c.then=="function"&&c.catch&&typeof c.catch=="function"?ZodParsedType.promise:typeof Map<"u"&&c instanceof Map?ZodParsedType.map:typeof Set<"u"&&c instanceof Set?ZodParsedType.set:typeof Date<"u"&&c instanceof Date?ZodParsedType.date:ZodParsedType.object;default:return ZodParsedType.unknown}},ZodIssueCode=util.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),quotelessJson=c=>JSON.stringify(c,null,2).replace(/"([^"]+)":/g,"$1:");class ZodError extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const n=e||function(o){return o.message},r={_errors:[]},i=o=>{for(const a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let d=r,f=0;for(;f<a.path.length;){const h=a.path[f];f===a.path.length-1?(d[h]=d[h]||{_errors:[]},d[h]._errors.push(n(a))):d[h]=d[h]||{_errors:[]},d=d[h],f++}}};return i(this),r}toString(){return this.message}get message(){return JSON.stringify(this.issues,util.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},r=[];for(const i of this.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(e(i))):r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}ZodError.create=c=>new ZodError(c);const errorMap=(c,e)=>{let n;switch(c.code){case ZodIssueCode.invalid_type:c.received===ZodParsedType.undefined?n="Required":n=`Expected ${c.expected}, received ${c.received}`;break;case ZodIssueCode.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(c.expected,util.jsonStringifyReplacer)}`;break;case ZodIssueCode.unrecognized_keys:n=`Unrecognized key(s) in object: ${util.joinValues(c.keys,", ")}`;break;case ZodIssueCode.invalid_union:n="Invalid input";break;case ZodIssueCode.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${util.joinValues(c.options)}`;break;case ZodIssueCode.invalid_enum_value:n=`Invalid enum value. Expected ${util.joinValues(c.options)}, received '${c.received}'`;break;case ZodIssueCode.invalid_arguments:n="Invalid function arguments";break;case ZodIssueCode.invalid_return_type:n="Invalid function return type";break;case ZodIssueCode.invalid_date:n="Invalid date";break;case ZodIssueCode.invalid_string:typeof c.validation=="object"?"includes"in c.validation?(n=`Invalid input: must include "${c.validation.includes}"`,typeof c.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${c.validation.position}`)):"startsWith"in c.validation?n=`Invalid input: must start with "${c.validation.startsWith}"`:"endsWith"in c.validation?n=`Invalid input: must end with "${c.validation.endsWith}"`:util.assertNever(c.validation):c.validation!=="regex"?n=`Invalid ${c.validation}`:n="Invalid";break;case ZodIssueCode.too_small:c.type==="array"?n=`Array must contain ${c.exact?"exactly":c.inclusive?"at least":"more than"} ${c.minimum} element(s)`:c.type==="string"?n=`String must contain ${c.exact?"exactly":c.inclusive?"at least":"over"} ${c.minimum} character(s)`:c.type==="number"?n=`Number must be ${c.exact?"exactly equal to ":c.inclusive?"greater than or equal to ":"greater than "}${c.minimum}`:c.type==="date"?n=`Date must be ${c.exact?"exactly equal to ":c.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(c.minimum))}`:n="Invalid input";break;case ZodIssueCode.too_big:c.type==="array"?n=`Array must contain ${c.exact?"exactly":c.inclusive?"at most":"less than"} ${c.maximum} element(s)`:c.type==="string"?n=`String must contain ${c.exact?"exactly":c.inclusive?"at most":"under"} ${c.maximum} character(s)`:c.type==="number"?n=`Number must be ${c.exact?"exactly":c.inclusive?"less than or equal to":"less than"} ${c.maximum}`:c.type==="bigint"?n=`BigInt must be ${c.exact?"exactly":c.inclusive?"less than or equal to":"less than"} ${c.maximum}`:c.type==="date"?n=`Date must be ${c.exact?"exactly":c.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(c.maximum))}`:n="Invalid input";break;case ZodIssueCode.custom:n="Invalid input";break;case ZodIssueCode.invalid_intersection_types:n="Intersection results could not be merged";break;case ZodIssueCode.not_multiple_of:n=`Number must be a multiple of ${c.multipleOf}`;break;case ZodIssueCode.not_finite:n="Number must be finite";break;default:n=e.defaultError,util.assertNever(c)}return{message:n}};let overrideErrorMap=errorMap;function setErrorMap(c){overrideErrorMap=c}function getErrorMap(){return overrideErrorMap}const makeIssue=c=>{const{data:e,path:n,errorMaps:r,issueData:i}=c,o=[...n,...i.path||[]],a={...i,path:o};let d="";const f=r.filter(h=>!!h).slice().reverse();for(const h of f)d=h(a,{data:e,defaultError:d}).message;return{...i,path:o,message:i.message||d}},EMPTY_PATH=[];function addIssueToContext(c,e){const n=makeIssue({issueData:e,data:c.data,path:c.path,errorMaps:[c.common.contextualErrorMap,c.schemaErrorMap,getErrorMap(),errorMap].filter(r=>!!r)});c.common.issues.push(n)}class ParseStatus{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const i of n){if(i.status==="aborted")return INVALID;i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const i of n)r.push({key:await i.key,value:await i.value});return ParseStatus.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const i of n){const{key:o,value:a}=i;if(o.status==="aborted"||a.status==="aborted")return INVALID;o.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(r[o.value]=a.value)}return{status:e.value,value:r}}}const INVALID=Object.freeze({status:"aborted"}),DIRTY=c=>({status:"dirty",value:c}),OK=c=>({status:"valid",value:c}),isAborted=c=>c.status==="aborted",isDirty=c=>c.status==="dirty",isValid=c=>c.status==="valid",isAsync=c=>typeof Promise<"u"&&c instanceof Promise;var errorUtil;(function(c){c.errToObj=e=>typeof e=="string"?{message:e}:e||{},c.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(errorUtil||(errorUtil={}));class ParseInputLazyPath{constructor(e,n,r,i){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const handleResult=(c,e)=>{if(isValid(e))return{success:!0,data:e.value};if(!c.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new ZodError(c.common.issues);return this._error=n,this._error}}};function processCreateParams(c){if(!c)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:i}=c;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,d)=>a.code!=="invalid_type"?{message:d.defaultError}:typeof d.data>"u"?{message:r??d.defaultError}:{message:n??d.defaultError},description:i}}class ZodType{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return getParsedType(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:getParsedType(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ParseStatus,ctx:{common:e.parent.common,data:e.data,parsedType:getParsedType(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(isAsync(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){var r;const i={common:{issues:[],async:(r=n==null?void 0:n.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:getParsedType(e)},o=this._parseSync({data:e,path:i.path,parent:i});return handleResult(i,o)}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:getParsedType(e)},i=this._parse({data:e,path:r.path,parent:r}),o=await(isAsync(i)?i:Promise.resolve(i));return handleResult(r,o)}refine(e,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,o)=>{const a=e(i),d=()=>o.addIssue({code:ZodIssueCode.custom,...r(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(f=>f?!0:(d(),!1)):a?!0:(d(),!1)})}refinement(e,n){return this._refinement((r,i)=>e(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(e){return new ZodEffects({schema:this,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ZodOptional.create(this,this._def)}nullable(){return ZodNullable.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ZodArray.create(this,this._def)}promise(){return ZodPromise.create(this,this._def)}or(e){return ZodUnion.create([this,e],this._def)}and(e){return ZodIntersection.create(this,e,this._def)}transform(e){return new ZodEffects({...processCreateParams(this._def),schema:this,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new ZodDefault({...processCreateParams(this._def),innerType:this,defaultValue:n,typeName:ZodFirstPartyTypeKind.ZodDefault})}brand(){return new ZodBranded({typeName:ZodFirstPartyTypeKind.ZodBranded,type:this,...processCreateParams(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new ZodCatch({...processCreateParams(this._def),innerType:this,catchValue:n,typeName:ZodFirstPartyTypeKind.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return ZodPipeline.create(this,e)}readonly(){return ZodReadonly.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const cuidRegex=/^c[^\s-]{8,}$/i,cuid2Regex=/^[a-z][a-z0-9]*$/,ulidRegex=/^[0-9A-HJKMNP-TV-Z]{26}$/,uuidRegex=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,emailRegex=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_emojiRegex="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let emojiRegex;const ipv4Regex=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,ipv6Regex=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,datetimeRegex=c=>c.precision?c.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${c.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${c.precision}}Z$`):c.precision===0?c.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):c.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function isValidIP(c,e){return!!((e==="v4"||!e)&&ipv4Regex.test(c)||(e==="v6"||!e)&&ipv6Regex.test(c))}class ZodString extends ZodType{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ZodParsedType.string){const o=this._getOrReturnCtx(e);return addIssueToContext(o,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.string,received:o.parsedType}),INVALID}const r=new ParseStatus;let i;for(const o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{code:ZodIssueCode.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="max")e.data.length>o.value&&(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{code:ZodIssueCode.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="length"){const a=e.data.length>o.value,d=e.data.length<o.value;(a||d)&&(i=this._getOrReturnCtx(e,i),a?addIssueToContext(i,{code:ZodIssueCode.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):d&&addIssueToContext(i,{code:ZodIssueCode.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),r.dirty())}else if(o.kind==="email")emailRegex.test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"email",code:ZodIssueCode.invalid_string,message:o.message}),r.dirty());else if(o.kind==="emoji")emojiRegex||(emojiRegex=new RegExp(_emojiRegex,"u")),emojiRegex.test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"emoji",code:ZodIssueCode.invalid_string,message:o.message}),r.dirty());else if(o.kind==="uuid")uuidRegex.test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"uuid",code:ZodIssueCode.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid")cuidRegex.test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"cuid",code:ZodIssueCode.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid2")cuid2Regex.test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"cuid2",code:ZodIssueCode.invalid_string,message:o.message}),r.dirty());else if(o.kind==="ulid")ulidRegex.test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"ulid",code:ZodIssueCode.invalid_string,message:o.message}),r.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"url",code:ZodIssueCode.invalid_string,message:o.message}),r.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"regex",code:ZodIssueCode.invalid_string,message:o.message}),r.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{code:ZodIssueCode.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),r.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{code:ZodIssueCode.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{code:ZodIssueCode.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()):o.kind==="datetime"?datetimeRegex(o).test(e.data)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{code:ZodIssueCode.invalid_string,validation:"datetime",message:o.message}),r.dirty()):o.kind==="ip"?isValidIP(e.data,o.version)||(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{validation:"ip",code:ZodIssueCode.invalid_string,message:o.message}),r.dirty()):util.assertNever(o);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(i=>e.test(i),{validation:n,code:ZodIssueCode.invalid_string,...errorUtil.errToObj(r)})}_addCheck(e){return new ZodString({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...errorUtil.errToObj(e)})}url(e){return this._addCheck({kind:"url",...errorUtil.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...errorUtil.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...errorUtil.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...errorUtil.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...errorUtil.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...errorUtil.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...errorUtil.errToObj(e)})}datetime(e){var n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(n=e==null?void 0:e.offset)!==null&&n!==void 0?n:!1,...errorUtil.errToObj(e==null?void 0:e.message)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...errorUtil.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...errorUtil.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...errorUtil.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...errorUtil.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...errorUtil.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...errorUtil.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...errorUtil.errToObj(n)})}nonempty(e){return this.min(1,errorUtil.errToObj(e))}trim(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}ZodString.create=c=>{var e;return new ZodString({checks:[],typeName:ZodFirstPartyTypeKind.ZodString,coerce:(e=c==null?void 0:c.coerce)!==null&&e!==void 0?e:!1,...processCreateParams(c)})};function floatSafeRemainder(c,e){const n=(c.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,i=n>r?n:r,o=parseInt(c.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return o%a/Math.pow(10,i)}class ZodNumber extends ZodType{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==ZodParsedType.number){const o=this._getOrReturnCtx(e);return addIssueToContext(o,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.number,received:o.parsedType}),INVALID}let r;const i=new ParseStatus;for(const o of this._def.checks)o.kind==="int"?util.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?floatSafeRemainder(e.data,o.value)!==0&&(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.not_finite,message:o.message}),i.dirty()):util.assertNever(o);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,errorUtil.toString(n))}gt(e,n){return this.setLimit("min",e,!1,errorUtil.toString(n))}lte(e,n){return this.setLimit("max",e,!0,errorUtil.toString(n))}lt(e,n){return this.setLimit("max",e,!1,errorUtil.toString(n))}setLimit(e,n,r,i){return new ZodNumber({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:errorUtil.toString(i)}]})}_addCheck(e){return new ZodNumber({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:errorUtil.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:errorUtil.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:errorUtil.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:errorUtil.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:errorUtil.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:errorUtil.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&util.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}}ZodNumber.create=c=>new ZodNumber({checks:[],typeName:ZodFirstPartyTypeKind.ZodNumber,coerce:(c==null?void 0:c.coerce)||!1,...processCreateParams(c)});class ZodBigInt extends ZodType{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==ZodParsedType.bigint){const o=this._getOrReturnCtx(e);return addIssueToContext(o,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.bigint,received:o.parsedType}),INVALID}let r;const i=new ParseStatus;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):util.assertNever(o);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,errorUtil.toString(n))}gt(e,n){return this.setLimit("min",e,!1,errorUtil.toString(n))}lte(e,n){return this.setLimit("max",e,!0,errorUtil.toString(n))}lt(e,n){return this.setLimit("max",e,!1,errorUtil.toString(n))}setLimit(e,n,r,i){return new ZodBigInt({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:errorUtil.toString(i)}]})}_addCheck(e){return new ZodBigInt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:errorUtil.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:errorUtil.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}ZodBigInt.create=c=>{var e;return new ZodBigInt({checks:[],typeName:ZodFirstPartyTypeKind.ZodBigInt,coerce:(e=c==null?void 0:c.coerce)!==null&&e!==void 0?e:!1,...processCreateParams(c)})};class ZodBoolean extends ZodType{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ZodParsedType.boolean){const r=this._getOrReturnCtx(e);return addIssueToContext(r,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.boolean,received:r.parsedType}),INVALID}return OK(e.data)}}ZodBoolean.create=c=>new ZodBoolean({typeName:ZodFirstPartyTypeKind.ZodBoolean,coerce:(c==null?void 0:c.coerce)||!1,...processCreateParams(c)});class ZodDate extends ZodType{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ZodParsedType.date){const o=this._getOrReturnCtx(e);return addIssueToContext(o,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.date,received:o.parsedType}),INVALID}if(isNaN(e.data.getTime())){const o=this._getOrReturnCtx(e);return addIssueToContext(o,{code:ZodIssueCode.invalid_date}),INVALID}const r=new ParseStatus;let i;for(const o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{code:ZodIssueCode.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),r.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(i=this._getOrReturnCtx(e,i),addIssueToContext(i,{code:ZodIssueCode.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):util.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ZodDate({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:errorUtil.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:errorUtil.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}ZodDate.create=c=>new ZodDate({checks:[],coerce:(c==null?void 0:c.coerce)||!1,typeName:ZodFirstPartyTypeKind.ZodDate,...processCreateParams(c)});class ZodSymbol extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.symbol){const r=this._getOrReturnCtx(e);return addIssueToContext(r,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.symbol,received:r.parsedType}),INVALID}return OK(e.data)}}ZodSymbol.create=c=>new ZodSymbol({typeName:ZodFirstPartyTypeKind.ZodSymbol,...processCreateParams(c)});class ZodUndefined extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.undefined){const r=this._getOrReturnCtx(e);return addIssueToContext(r,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.undefined,received:r.parsedType}),INVALID}return OK(e.data)}}ZodUndefined.create=c=>new ZodUndefined({typeName:ZodFirstPartyTypeKind.ZodUndefined,...processCreateParams(c)});class ZodNull extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.null){const r=this._getOrReturnCtx(e);return addIssueToContext(r,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.null,received:r.parsedType}),INVALID}return OK(e.data)}}ZodNull.create=c=>new ZodNull({typeName:ZodFirstPartyTypeKind.ZodNull,...processCreateParams(c)});class ZodAny extends ZodType{constructor(){super(...arguments),this._any=!0}_parse(e){return OK(e.data)}}ZodAny.create=c=>new ZodAny({typeName:ZodFirstPartyTypeKind.ZodAny,...processCreateParams(c)});class ZodUnknown extends ZodType{constructor(){super(...arguments),this._unknown=!0}_parse(e){return OK(e.data)}}ZodUnknown.create=c=>new ZodUnknown({typeName:ZodFirstPartyTypeKind.ZodUnknown,...processCreateParams(c)});class ZodNever extends ZodType{_parse(e){const n=this._getOrReturnCtx(e);return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.never,received:n.parsedType}),INVALID}}ZodNever.create=c=>new ZodNever({typeName:ZodFirstPartyTypeKind.ZodNever,...processCreateParams(c)});class ZodVoid extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.undefined){const r=this._getOrReturnCtx(e);return addIssueToContext(r,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.void,received:r.parsedType}),INVALID}return OK(e.data)}}ZodVoid.create=c=>new ZodVoid({typeName:ZodFirstPartyTypeKind.ZodVoid,...processCreateParams(c)});class ZodArray extends ZodType{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),i=this._def;if(n.parsedType!==ZodParsedType.array)return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.array,received:n.parsedType}),INVALID;if(i.exactLength!==null){const a=n.data.length>i.exactLength.value,d=n.data.length<i.exactLength.value;(a||d)&&(addIssueToContext(n,{code:a?ZodIssueCode.too_big:ZodIssueCode.too_small,minimum:d?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(addIssueToContext(n,{code:ZodIssueCode.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(addIssueToContext(n,{code:ZodIssueCode.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,d)=>i.type._parseAsync(new ParseInputLazyPath(n,a,n.path,d)))).then(a=>ParseStatus.mergeArray(r,a));const o=[...n.data].map((a,d)=>i.type._parseSync(new ParseInputLazyPath(n,a,n.path,d)));return ParseStatus.mergeArray(r,o)}get element(){return this._def.type}min(e,n){return new ZodArray({...this._def,minLength:{value:e,message:errorUtil.toString(n)}})}max(e,n){return new ZodArray({...this._def,maxLength:{value:e,message:errorUtil.toString(n)}})}length(e,n){return new ZodArray({...this._def,exactLength:{value:e,message:errorUtil.toString(n)}})}nonempty(e){return this.min(1,e)}}ZodArray.create=(c,e)=>new ZodArray({type:c,minLength:null,maxLength:null,exactLength:null,typeName:ZodFirstPartyTypeKind.ZodArray,...processCreateParams(e)});function deepPartialify(c){if(c instanceof ZodObject){const e={};for(const n in c.shape){const r=c.shape[n];e[n]=ZodOptional.create(deepPartialify(r))}return new ZodObject({...c._def,shape:()=>e})}else return c instanceof ZodArray?new ZodArray({...c._def,type:deepPartialify(c.element)}):c instanceof ZodOptional?ZodOptional.create(deepPartialify(c.unwrap())):c instanceof ZodNullable?ZodNullable.create(deepPartialify(c.unwrap())):c instanceof ZodTuple?ZodTuple.create(c.items.map(e=>deepPartialify(e))):c}class ZodObject extends ZodType{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=util.objectKeys(e);return this._cached={shape:e,keys:n}}_parse(e){if(this._getType(e)!==ZodParsedType.object){const h=this._getOrReturnCtx(e);return addIssueToContext(h,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:h.parsedType}),INVALID}const{status:r,ctx:i}=this._processInputParams(e),{shape:o,keys:a}=this._getCached(),d=[];if(!(this._def.catchall instanceof ZodNever&&this._def.unknownKeys==="strip"))for(const h in i.data)a.includes(h)||d.push(h);const f=[];for(const h of a){const p=o[h],s=i.data[h];f.push({key:{status:"valid",value:h},value:p._parse(new ParseInputLazyPath(i,s,i.path,h)),alwaysSet:h in i.data})}if(this._def.catchall instanceof ZodNever){const h=this._def.unknownKeys;if(h==="passthrough")for(const p of d)f.push({key:{status:"valid",value:p},value:{status:"valid",value:i.data[p]}});else if(h==="strict")d.length>0&&(addIssueToContext(i,{code:ZodIssueCode.unrecognized_keys,keys:d}),r.dirty());else if(h!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const h=this._def.catchall;for(const p of d){const s=i.data[p];f.push({key:{status:"valid",value:p},value:h._parse(new ParseInputLazyPath(i,s,i.path,p)),alwaysSet:p in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const h=[];for(const p of f){const s=await p.key;h.push({key:s,value:await p.value,alwaysSet:p.alwaysSet})}return h}).then(h=>ParseStatus.mergeObjectSync(r,h)):ParseStatus.mergeObjectSync(r,f)}get shape(){return this._def.shape()}strict(e){return errorUtil.errToObj,new ZodObject({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{var i,o,a,d;const f=(a=(o=(i=this._def).errorMap)===null||o===void 0?void 0:o.call(i,n,r).message)!==null&&a!==void 0?a:r.defaultError;return n.code==="unrecognized_keys"?{message:(d=errorUtil.errToObj(e).message)!==null&&d!==void 0?d:f}:{message:f}}}:{}})}strip(){return new ZodObject({...this._def,unknownKeys:"strip"})}passthrough(){return new ZodObject({...this._def,unknownKeys:"passthrough"})}extend(e){return new ZodObject({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ZodObject({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ZodFirstPartyTypeKind.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new ZodObject({...this._def,catchall:e})}pick(e){const n={};return util.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new ZodObject({...this._def,shape:()=>n})}omit(e){const n={};return util.objectKeys(this.shape).forEach(r=>{e[r]||(n[r]=this.shape[r])}),new ZodObject({...this._def,shape:()=>n})}deepPartial(){return deepPartialify(this)}partial(e){const n={};return util.objectKeys(this.shape).forEach(r=>{const i=this.shape[r];e&&!e[r]?n[r]=i:n[r]=i.optional()}),new ZodObject({...this._def,shape:()=>n})}required(e){const n={};return util.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])n[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof ZodOptional;)o=o._def.innerType;n[r]=o}}),new ZodObject({...this._def,shape:()=>n})}keyof(){return createZodEnum(util.objectKeys(this.shape))}}ZodObject.create=(c,e)=>new ZodObject({shape:()=>c,unknownKeys:"strip",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(e)});ZodObject.strictCreate=(c,e)=>new ZodObject({shape:()=>c,unknownKeys:"strict",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(e)});ZodObject.lazycreate=(c,e)=>new ZodObject({shape:c,unknownKeys:"strip",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(e)});class ZodUnion extends ZodType{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function i(o){for(const d of o)if(d.result.status==="valid")return d.result;for(const d of o)if(d.result.status==="dirty")return n.common.issues.push(...d.ctx.common.issues),d.result;const a=o.map(d=>new ZodError(d.ctx.common.issues));return addIssueToContext(n,{code:ZodIssueCode.invalid_union,unionErrors:a}),INVALID}if(n.common.async)return Promise.all(r.map(async o=>{const a={...n,common:{...n.common,issues:[]},parent:null};return{result:await o._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(i);{let o;const a=[];for(const f of r){const h={...n,common:{...n.common,issues:[]},parent:null},p=f._parseSync({data:n.data,path:n.path,parent:h});if(p.status==="valid")return p;p.status==="dirty"&&!o&&(o={result:p,ctx:h}),h.common.issues.length&&a.push(h.common.issues)}if(o)return n.common.issues.push(...o.ctx.common.issues),o.result;const d=a.map(f=>new ZodError(f));return addIssueToContext(n,{code:ZodIssueCode.invalid_union,unionErrors:d}),INVALID}}get options(){return this._def.options}}ZodUnion.create=(c,e)=>new ZodUnion({options:c,typeName:ZodFirstPartyTypeKind.ZodUnion,...processCreateParams(e)});const getDiscriminator=c=>c instanceof ZodLazy?getDiscriminator(c.schema):c instanceof ZodEffects?getDiscriminator(c.innerType()):c instanceof ZodLiteral?[c.value]:c instanceof ZodEnum?c.options:c instanceof ZodNativeEnum?Object.keys(c.enum):c instanceof ZodDefault?getDiscriminator(c._def.innerType):c instanceof ZodUndefined?[void 0]:c instanceof ZodNull?[null]:null;class ZodDiscriminatedUnion extends ZodType{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==ZodParsedType.object)return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:n.parsedType}),INVALID;const r=this.discriminator,i=n.data[r],o=this.optionsMap.get(i);return o?n.common.async?o._parseAsync({data:n.data,path:n.path,parent:n}):o._parseSync({data:n.data,path:n.path,parent:n}):(addIssueToContext(n,{code:ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){const i=new Map;for(const o of n){const a=getDiscriminator(o.shape[e]);if(!a)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const d of a){if(i.has(d))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(d)}`);i.set(d,o)}}return new ZodDiscriminatedUnion({typeName:ZodFirstPartyTypeKind.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:i,...processCreateParams(r)})}}function mergeValues(c,e){const n=getParsedType(c),r=getParsedType(e);if(c===e)return{valid:!0,data:c};if(n===ZodParsedType.object&&r===ZodParsedType.object){const i=util.objectKeys(e),o=util.objectKeys(c).filter(d=>i.indexOf(d)!==-1),a={...c,...e};for(const d of o){const f=mergeValues(c[d],e[d]);if(!f.valid)return{valid:!1};a[d]=f.data}return{valid:!0,data:a}}else if(n===ZodParsedType.array&&r===ZodParsedType.array){if(c.length!==e.length)return{valid:!1};const i=[];for(let o=0;o<c.length;o++){const a=c[o],d=e[o],f=mergeValues(a,d);if(!f.valid)return{valid:!1};i.push(f.data)}return{valid:!0,data:i}}else return n===ZodParsedType.date&&r===ZodParsedType.date&&+c==+e?{valid:!0,data:c}:{valid:!1}}class ZodIntersection extends ZodType{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),i=(o,a)=>{if(isAborted(o)||isAborted(a))return INVALID;const d=mergeValues(o.value,a.value);return d.valid?((isDirty(o)||isDirty(a))&&n.dirty(),{status:n.value,value:d.data}):(addIssueToContext(r,{code:ZodIssueCode.invalid_intersection_types}),INVALID)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,a])=>i(o,a)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}ZodIntersection.create=(c,e,n)=>new ZodIntersection({left:c,right:e,typeName:ZodFirstPartyTypeKind.ZodIntersection,...processCreateParams(n)});class ZodTuple extends ZodType{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==ZodParsedType.array)return addIssueToContext(r,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.array,received:r.parsedType}),INVALID;if(r.data.length<this._def.items.length)return addIssueToContext(r,{code:ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),INVALID;!this._def.rest&&r.data.length>this._def.items.length&&(addIssueToContext(r,{code:ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const o=[...r.data].map((a,d)=>{const f=this._def.items[d]||this._def.rest;return f?f._parse(new ParseInputLazyPath(r,a,r.path,d)):null}).filter(a=>!!a);return r.common.async?Promise.all(o).then(a=>ParseStatus.mergeArray(n,a)):ParseStatus.mergeArray(n,o)}get items(){return this._def.items}rest(e){return new ZodTuple({...this._def,rest:e})}}ZodTuple.create=(c,e)=>{if(!Array.isArray(c))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ZodTuple({items:c,typeName:ZodFirstPartyTypeKind.ZodTuple,rest:null,...processCreateParams(e)})};class ZodRecord extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==ZodParsedType.object)return addIssueToContext(r,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:r.parsedType}),INVALID;const i=[],o=this._def.keyType,a=this._def.valueType;for(const d in r.data)i.push({key:o._parse(new ParseInputLazyPath(r,d,r.path,d)),value:a._parse(new ParseInputLazyPath(r,r.data[d],r.path,d))});return r.common.async?ParseStatus.mergeObjectAsync(n,i):ParseStatus.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof ZodType?new ZodRecord({keyType:e,valueType:n,typeName:ZodFirstPartyTypeKind.ZodRecord,...processCreateParams(r)}):new ZodRecord({keyType:ZodString.create(),valueType:e,typeName:ZodFirstPartyTypeKind.ZodRecord,...processCreateParams(n)})}}class ZodMap extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==ZodParsedType.map)return addIssueToContext(r,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.map,received:r.parsedType}),INVALID;const i=this._def.keyType,o=this._def.valueType,a=[...r.data.entries()].map(([d,f],h)=>({key:i._parse(new ParseInputLazyPath(r,d,r.path,[h,"key"])),value:o._parse(new ParseInputLazyPath(r,f,r.path,[h,"value"]))}));if(r.common.async){const d=new Map;return Promise.resolve().then(async()=>{for(const f of a){const h=await f.key,p=await f.value;if(h.status==="aborted"||p.status==="aborted")return INVALID;(h.status==="dirty"||p.status==="dirty")&&n.dirty(),d.set(h.value,p.value)}return{status:n.value,value:d}})}else{const d=new Map;for(const f of a){const h=f.key,p=f.value;if(h.status==="aborted"||p.status==="aborted")return INVALID;(h.status==="dirty"||p.status==="dirty")&&n.dirty(),d.set(h.value,p.value)}return{status:n.value,value:d}}}}ZodMap.create=(c,e,n)=>new ZodMap({valueType:e,keyType:c,typeName:ZodFirstPartyTypeKind.ZodMap,...processCreateParams(n)});class ZodSet extends ZodType{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==ZodParsedType.set)return addIssueToContext(r,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.set,received:r.parsedType}),INVALID;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(addIssueToContext(r,{code:ZodIssueCode.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(addIssueToContext(r,{code:ZodIssueCode.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const o=this._def.valueType;function a(f){const h=new Set;for(const p of f){if(p.status==="aborted")return INVALID;p.status==="dirty"&&n.dirty(),h.add(p.value)}return{status:n.value,value:h}}const d=[...r.data.values()].map((f,h)=>o._parse(new ParseInputLazyPath(r,f,r.path,h)));return r.common.async?Promise.all(d).then(f=>a(f)):a(d)}min(e,n){return new ZodSet({...this._def,minSize:{value:e,message:errorUtil.toString(n)}})}max(e,n){return new ZodSet({...this._def,maxSize:{value:e,message:errorUtil.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}ZodSet.create=(c,e)=>new ZodSet({valueType:c,minSize:null,maxSize:null,typeName:ZodFirstPartyTypeKind.ZodSet,...processCreateParams(e)});class ZodFunction extends ZodType{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==ZodParsedType.function)return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.function,received:n.parsedType}),INVALID;function r(d,f){return makeIssue({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,getErrorMap(),errorMap].filter(h=>!!h),issueData:{code:ZodIssueCode.invalid_arguments,argumentsError:f}})}function i(d,f){return makeIssue({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,getErrorMap(),errorMap].filter(h=>!!h),issueData:{code:ZodIssueCode.invalid_return_type,returnTypeError:f}})}const o={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof ZodPromise){const d=this;return OK(async function(...f){const h=new ZodError([]),p=await d._def.args.parseAsync(f,o).catch(l=>{throw h.addIssue(r(f,l)),h}),s=await Reflect.apply(a,this,p);return await d._def.returns._def.type.parseAsync(s,o).catch(l=>{throw h.addIssue(i(s,l)),h})})}else{const d=this;return OK(function(...f){const h=d._def.args.safeParse(f,o);if(!h.success)throw new ZodError([r(f,h.error)]);const p=Reflect.apply(a,this,h.data),s=d._def.returns.safeParse(p,o);if(!s.success)throw new ZodError([i(p,s.error)]);return s.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ZodFunction({...this._def,args:ZodTuple.create(e).rest(ZodUnknown.create())})}returns(e){return new ZodFunction({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new ZodFunction({args:e||ZodTuple.create([]).rest(ZodUnknown.create()),returns:n||ZodUnknown.create(),typeName:ZodFirstPartyTypeKind.ZodFunction,...processCreateParams(r)})}}class ZodLazy extends ZodType{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}ZodLazy.create=(c,e)=>new ZodLazy({getter:c,typeName:ZodFirstPartyTypeKind.ZodLazy,...processCreateParams(e)});class ZodLiteral extends ZodType{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return addIssueToContext(n,{received:n.data,code:ZodIssueCode.invalid_literal,expected:this._def.value}),INVALID}return{status:"valid",value:e.data}}get value(){return this._def.value}}ZodLiteral.create=(c,e)=>new ZodLiteral({value:c,typeName:ZodFirstPartyTypeKind.ZodLiteral,...processCreateParams(e)});function createZodEnum(c,e){return new ZodEnum({values:c,typeName:ZodFirstPartyTypeKind.ZodEnum,...processCreateParams(e)})}class ZodEnum extends ZodType{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return addIssueToContext(n,{expected:util.joinValues(r),received:n.parsedType,code:ZodIssueCode.invalid_type}),INVALID}if(this._def.values.indexOf(e.data)===-1){const n=this._getOrReturnCtx(e),r=this._def.values;return addIssueToContext(n,{received:n.data,code:ZodIssueCode.invalid_enum_value,options:r}),INVALID}return OK(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e){return ZodEnum.create(e)}exclude(e){return ZodEnum.create(this.options.filter(n=>!e.includes(n)))}}ZodEnum.create=createZodEnum;class ZodNativeEnum extends ZodType{_parse(e){const n=util.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==ZodParsedType.string&&r.parsedType!==ZodParsedType.number){const i=util.objectValues(n);return addIssueToContext(r,{expected:util.joinValues(i),received:r.parsedType,code:ZodIssueCode.invalid_type}),INVALID}if(n.indexOf(e.data)===-1){const i=util.objectValues(n);return addIssueToContext(r,{received:r.data,code:ZodIssueCode.invalid_enum_value,options:i}),INVALID}return OK(e.data)}get enum(){return this._def.values}}ZodNativeEnum.create=(c,e)=>new ZodNativeEnum({values:c,typeName:ZodFirstPartyTypeKind.ZodNativeEnum,...processCreateParams(e)});class ZodPromise extends ZodType{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==ZodParsedType.promise&&n.common.async===!1)return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.promise,received:n.parsedType}),INVALID;const r=n.parsedType===ZodParsedType.promise?n.data:Promise.resolve(n.data);return OK(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}ZodPromise.create=(c,e)=>new ZodPromise({type:c,typeName:ZodFirstPartyTypeKind.ZodPromise,...processCreateParams(e)});class ZodEffects extends ZodType{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ZodFirstPartyTypeKind.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),i=this._def.effect||null,o={addIssue:a=>{addIssueToContext(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){const a=i.transform(r.data,o);return r.common.issues.length?{status:"dirty",value:r.data}:r.common.async?Promise.resolve(a).then(d=>this._def.schema._parseAsync({data:d,path:r.path,parent:r})):this._def.schema._parseSync({data:a,path:r.path,parent:r})}if(i.type==="refinement"){const a=d=>{const f=i.refinement(d,o);if(r.common.async)return Promise.resolve(f);if(f instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return d};if(r.common.async===!1){const d=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return d.status==="aborted"?INVALID:(d.status==="dirty"&&n.dirty(),a(d.value),{status:n.value,value:d.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(d=>d.status==="aborted"?INVALID:(d.status==="dirty"&&n.dirty(),a(d.value).then(()=>({status:n.value,value:d.value}))))}if(i.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!isValid(a))return a;const d=i.transform(a.value,o);if(d instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:d}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>isValid(a)?Promise.resolve(i.transform(a.value,o)).then(d=>({status:n.value,value:d})):a);util.assertNever(i)}}ZodEffects.create=(c,e,n)=>new ZodEffects({schema:c,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:e,...processCreateParams(n)});ZodEffects.createWithPreprocess=(c,e,n)=>new ZodEffects({schema:e,effect:{type:"preprocess",transform:c},typeName:ZodFirstPartyTypeKind.ZodEffects,...processCreateParams(n)});class ZodOptional extends ZodType{_parse(e){return this._getType(e)===ZodParsedType.undefined?OK(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ZodOptional.create=(c,e)=>new ZodOptional({innerType:c,typeName:ZodFirstPartyTypeKind.ZodOptional,...processCreateParams(e)});class ZodNullable extends ZodType{_parse(e){return this._getType(e)===ZodParsedType.null?OK(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ZodNullable.create=(c,e)=>new ZodNullable({innerType:c,typeName:ZodFirstPartyTypeKind.ZodNullable,...processCreateParams(e)});class ZodDefault extends ZodType{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===ZodParsedType.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}ZodDefault.create=(c,e)=>new ZodDefault({innerType:c,typeName:ZodFirstPartyTypeKind.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...processCreateParams(e)});class ZodCatch extends ZodType{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return isAsync(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new ZodError(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ZodError(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}ZodCatch.create=(c,e)=>new ZodCatch({innerType:c,typeName:ZodFirstPartyTypeKind.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...processCreateParams(e)});class ZodNaN extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.nan){const r=this._getOrReturnCtx(e);return addIssueToContext(r,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.nan,received:r.parsedType}),INVALID}return{status:"valid",value:e.data}}}ZodNaN.create=c=>new ZodNaN({typeName:ZodFirstPartyTypeKind.ZodNaN,...processCreateParams(c)});const BRAND=Symbol("zod_brand");class ZodBranded extends ZodType{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class ZodPipeline extends ZodType{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?INVALID:o.status==="dirty"?(n.dirty(),DIRTY(o.value)):this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?INVALID:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(e,n){return new ZodPipeline({in:e,out:n,typeName:ZodFirstPartyTypeKind.ZodPipeline})}}class ZodReadonly extends ZodType{_parse(e){const n=this._def.innerType._parse(e);return isValid(n)&&(n.value=Object.freeze(n.value)),n}}ZodReadonly.create=(c,e)=>new ZodReadonly({innerType:c,typeName:ZodFirstPartyTypeKind.ZodReadonly,...processCreateParams(e)});const custom=(c,e={},n)=>c?ZodAny.create().superRefine((r,i)=>{var o,a;if(!c(r)){const d=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,f=(a=(o=d.fatal)!==null&&o!==void 0?o:n)!==null&&a!==void 0?a:!0,h=typeof d=="string"?{message:d}:d;i.addIssue({code:"custom",...h,fatal:f})}}):ZodAny.create(),late={object:ZodObject.lazycreate};var ZodFirstPartyTypeKind;(function(c){c.ZodString="ZodString",c.ZodNumber="ZodNumber",c.ZodNaN="ZodNaN",c.ZodBigInt="ZodBigInt",c.ZodBoolean="ZodBoolean",c.ZodDate="ZodDate",c.ZodSymbol="ZodSymbol",c.ZodUndefined="ZodUndefined",c.ZodNull="ZodNull",c.ZodAny="ZodAny",c.ZodUnknown="ZodUnknown",c.ZodNever="ZodNever",c.ZodVoid="ZodVoid",c.ZodArray="ZodArray",c.ZodObject="ZodObject",c.ZodUnion="ZodUnion",c.ZodDiscriminatedUnion="ZodDiscriminatedUnion",c.ZodIntersection="ZodIntersection",c.ZodTuple="ZodTuple",c.ZodRecord="ZodRecord",c.ZodMap="ZodMap",c.ZodSet="ZodSet",c.ZodFunction="ZodFunction",c.ZodLazy="ZodLazy",c.ZodLiteral="ZodLiteral",c.ZodEnum="ZodEnum",c.ZodEffects="ZodEffects",c.ZodNativeEnum="ZodNativeEnum",c.ZodOptional="ZodOptional",c.ZodNullable="ZodNullable",c.ZodDefault="ZodDefault",c.ZodCatch="ZodCatch",c.ZodPromise="ZodPromise",c.ZodBranded="ZodBranded",c.ZodPipeline="ZodPipeline",c.ZodReadonly="ZodReadonly"})(ZodFirstPartyTypeKind||(ZodFirstPartyTypeKind={}));const instanceOfType=(c,e={message:`Input not instance of ${c.name}`})=>custom(n=>n instanceof c,e),stringType=ZodString.create,numberType=ZodNumber.create,nanType=ZodNaN.create,bigIntType=ZodBigInt.create,booleanType=ZodBoolean.create,dateType=ZodDate.create,symbolType=ZodSymbol.create,undefinedType=ZodUndefined.create,nullType=ZodNull.create,anyType=ZodAny.create,unknownType=ZodUnknown.create,neverType=ZodNever.create,voidType=ZodVoid.create,arrayType=ZodArray.create,objectType=ZodObject.create,strictObjectType=ZodObject.strictCreate,unionType=ZodUnion.create,discriminatedUnionType=ZodDiscriminatedUnion.create,intersectionType=ZodIntersection.create,tupleType=ZodTuple.create,recordType=ZodRecord.create,mapType=ZodMap.create,setType=ZodSet.create,functionType=ZodFunction.create,lazyType=ZodLazy.create,literalType=ZodLiteral.create,enumType=ZodEnum.create,nativeEnumType=ZodNativeEnum.create,promiseType=ZodPromise.create,effectsType=ZodEffects.create,optionalType=ZodOptional.create,nullableType=ZodNullable.create,preprocessType=ZodEffects.createWithPreprocess,pipelineType=ZodPipeline.create,ostring=()=>stringType().optional(),onumber=()=>numberType().optional(),oboolean=()=>booleanType().optional(),coerce={string:c=>ZodString.create({...c,coerce:!0}),number:c=>ZodNumber.create({...c,coerce:!0}),boolean:c=>ZodBoolean.create({...c,coerce:!0}),bigint:c=>ZodBigInt.create({...c,coerce:!0}),date:c=>ZodDate.create({...c,coerce:!0})},NEVER=INVALID;var z=Object.freeze({__proto__:null,defaultErrorMap:errorMap,setErrorMap,getErrorMap,makeIssue,EMPTY_PATH,addIssueToContext,ParseStatus,INVALID,DIRTY,OK,isAborted,isDirty,isValid,isAsync,get util(){return util},get objectUtil(){return objectUtil},ZodParsedType,getParsedType,ZodType,ZodString,ZodNumber,ZodBigInt,ZodBoolean,ZodDate,ZodSymbol,ZodUndefined,ZodNull,ZodAny,ZodUnknown,ZodNever,ZodVoid,ZodArray,ZodObject,ZodUnion,ZodDiscriminatedUnion,ZodIntersection,ZodTuple,ZodRecord,ZodMap,ZodSet,ZodFunction,ZodLazy,ZodLiteral,ZodEnum,ZodNativeEnum,ZodPromise,ZodEffects,ZodTransformer:ZodEffects,ZodOptional,ZodNullable,ZodDefault,ZodCatch,ZodNaN,BRAND,ZodBranded,ZodPipeline,ZodReadonly,custom,Schema:ZodType,ZodSchema:ZodType,late,get ZodFirstPartyTypeKind(){return ZodFirstPartyTypeKind},coerce,any:anyType,array:arrayType,bigint:bigIntType,boolean:booleanType,date:dateType,discriminatedUnion:discriminatedUnionType,effect:effectsType,enum:enumType,function:functionType,instanceof:instanceOfType,intersection:intersectionType,lazy:lazyType,literal:literalType,map:mapType,nan:nanType,nativeEnum:nativeEnumType,never:neverType,null:nullType,nullable:nullableType,number:numberType,object:objectType,oboolean,onumber,optional:optionalType,ostring,pipeline:pipelineType,preprocess:preprocessType,promise:promiseType,record:recordType,set:setType,strictObject:strictObjectType,string:stringType,symbol:symbolType,transformer:effectsType,tuple:tupleType,undefined:undefinedType,union:unionType,unknown:unknownType,void:voidType,NEVER,ZodIssueCode,quotelessJson,ZodError});const listInputSchema=z.object({name:z.string(),label:z.string(),type:z.literal("list"),required:z.boolean().optional(),options:z.array(z.object({value:z.string(),label:z.string()}))}),otherInputSchema=z.object({name:z.string(),label:z.string(),type:z.enum(["int","float","bool","str"]),required:z.boolean().optional()}),createObjectInputsSchema=z.array(z.union([listInputSchema,otherInputSchema])),mapInputsToValueType=c=>c.reduce((e,n)=>{var r;return n.dtype==="str"||n.dtype==="list"?e[n.name]=z.string():n.dtype==="int"||n.dtype==="float"?e[n.name]=z.number():e[n.name]=z.boolean(),n.required||(e[n.name]=(r=e[n.name])==null?void 0:r.optional()),e},{}),createSchemaFromFeatures=c=>z.object(mapInputsToValueType(c)),createFeature=c=>createObjectInputsSchema.parse(Object.values(c).map(n=>({...n,type:n.dtype,required:!1,label:n.name}))).map(n=>{var i;const r=(i=c[n.name])==null?void 0:i.value;return n.type==="list"?{...n,options:n.options,value:r}:{...n,value:r}}),mapShapeInputsToFeatures=(c,e)=>Object.entries(c).reduce((n,[r,i])=>{var o;return n[r]={name:r,dtype:(o=e.find(a=>a.name===r))==null?void 0:o.type,value:i},n},{});function get_each_context$2(c,e,n){const r=c.slice();return r[5]=e[n],r}function create_default_slot$6(c){let e,n;return e=new Pencil({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p:noop,i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_each_block$2(c){let e,n,r,i=c[5].id+"",o,a,d,f,h,p="Width",s,t,l=c[5].width+"",u,g,m,_,b="Height",y,v,T=c[5].height+"",w,S,x,P,I="Format",N,L,E=c[5].format+"",M,k;return{c(){e=element("div"),n=element("h3"),r=text("File "),o=text(i),a=space(),d=element("div"),f=element("div"),h=element("p"),h.textContent=p,s=space(),t=element("p"),u=text(l),g=space(),m=element("div"),_=element("p"),_.textContent=b,y=space(),v=element("p"),w=text(T),S=space(),x=element("div"),P=element("p"),P.textContent=I,N=space(),L=element("p"),M=text(E),k=space(),this.h()},l(A){e=claim_element(A,"DIV",{class:!0});var R=children(e);n=claim_element(R,"H3",{class:!0});var K=children(n);r=claim_text(K,"File "),o=claim_text(K,i),K.forEach(detach),a=claim_space(R),d=claim_element(R,"DIV",{class:!0});var Z=children(d);f=claim_element(Z,"DIV",{class:!0});var J=children(f);h=claim_element(J,"P",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(h)!=="svelte-eqvuf3"&&(h.textContent=p),s=claim_space(J),t=claim_element(J,"P",{});var X=children(t);u=claim_text(X,l),X.forEach(detach),J.forEach(detach),g=claim_space(Z),m=claim_element(Z,"DIV",{class:!0});var te=children(m);_=claim_element(te,"P",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(_)!=="svelte-4rbq2c"&&(_.textContent=b),y=claim_space(te),v=claim_element(te,"P",{});var oe=children(v);w=claim_text(oe,T),oe.forEach(detach),te.forEach(detach),S=claim_space(Z),x=claim_element(Z,"DIV",{class:!0});var ae=children(x);P=claim_element(ae,"P",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(P)!=="svelte-6y21a4"&&(P.textContent=I),N=claim_space(ae),L=claim_element(ae,"P",{});var ce=children(L);M=claim_text(ce,E),ce.forEach(detach),ae.forEach(detach),Z.forEach(detach),k=claim_space(R),R.forEach(detach),this.h()},h(){attr(n,"class","uppercase font-light"),attr(h,"class","font-bold first-letter:uppercase"),attr(f,"class","grid gap-4 grid-cols-[100px_auto] mt-2"),attr(_,"class","font-bold first-letter:uppercase"),attr(m,"class","grid gap-4 grid-cols-[100px_auto] mt-2"),attr(P,"class","font-bold first-letter:uppercase"),attr(x,"class","grid gap-4 grid-cols-[100px_auto] mt-2"),attr(d,"class","mt-4 pb-4"),attr(e,"class","p-4 text-slate-800")},m(A,R){insert_hydration(A,e,R),append_hydration(e,n),append_hydration(n,r),append_hydration(n,o),append_hydration(e,a),append_hydration(e,d),append_hydration(d,f),append_hydration(f,h),append_hydration(f,s),append_hydration(f,t),append_hydration(t,u),append_hydration(d,g),append_hydration(d,m),append_hydration(m,_),append_hydration(m,y),append_hydration(m,v),append_hydration(v,w),append_hydration(d,S),append_hydration(d,x),append_hydration(x,P),append_hydration(x,N),append_hydration(x,L),append_hydration(L,M),append_hydration(e,k)},p(A,R){R&2&&i!==(i=A[5].id+"")&&set_data(o,i),R&2&&l!==(l=A[5].width+"")&&set_data(u,l),R&2&&T!==(T=A[5].height+"")&&set_data(w,T),R&2&&E!==(E=A[5].format+"")&&set_data(M,E)},d(A){A&&detach(e)}}}function create_fragment$8(c){let e,n,r,i="Features",o,a,d,f,h,p,s;a=new TooltipIconButton({props:{selected:c[2],$$slots:{default:[create_default_slot$6]},$$scope:{ctx:c}}}),a.$on("click",c[3]),f=new FeatureInputs({props:{features:c[0],isEditing:c[2],saveInputChange:c[4]}});let t=ensure_array_like(c[1]),l=[];for(let u=0;u<t.length;u+=1)l[u]=create_each_block$2(get_each_context$2(c,t,u));return{c(){e=element("div"),n=element("h3"),r=element("span"),r.textContent=i,o=space(),create_component(a.$$.fragment),d=space(),create_component(f.$$.fragment),h=space();for(let u=0;u<l.length;u+=1)l[u].c();p=empty(),this.h()},l(u){e=claim_element(u,"DIV",{class:!0});var g=children(e);n=claim_element(g,"H3",{class:!0});var m=children(n);r=claim_element(m,"SPAN",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(r)!=="svelte-1urgs7u"&&(r.textContent=i),o=claim_space(m),claim_component(a.$$.fragment,m),m.forEach(detach),d=claim_space(g),claim_component(f.$$.fragment,g),g.forEach(detach),h=claim_space(u);for(let _=0;_<l.length;_+=1)l[_].l(u);p=empty(),this.h()},h(){attr(r,"class","mr-4"),attr(n,"class","uppercase font-light"),attr(e,"class","border-b-2 border-b-gray-500 p-4 mb-4 text-slate-800")},m(u,g){insert_hydration(u,e,g),append_hydration(e,n),append_hydration(n,r),append_hydration(n,o),mount_component(a,n,null),append_hydration(e,d),mount_component(f,e,null),insert_hydration(u,h,g);for(let m=0;m<l.length;m+=1)l[m]&&l[m].m(u,g);insert_hydration(u,p,g),s=!0},p(u,[g]){const m={};g&4&&(m.selected=u[2]),g&256&&(m.$$scope={dirty:g,ctx:u}),a.$set(m);const _={};if(g&1&&(_.features=u[0]),g&4&&(_.isEditing=u[2]),f.$set(_),g&2){t=ensure_array_like(u[1]);let b;for(b=0;b<t.length;b+=1){const y=get_each_context$2(u,t,b);l[b]?l[b].p(y,g):(l[b]=create_each_block$2(y),l[b].c(),l[b].m(p.parentNode,p))}for(;b<l.length;b+=1)l[b].d(1);l.length=t.length}},i(u){s||(transition_in(a.$$.fragment,u),transition_in(f.$$.fragment,u),s=!0)},o(u){transition_out(a.$$.fragment,u),transition_out(f.$$.fragment,u),s=!1},d(u){u&&(detach(e),detach(h),detach(p)),destroy_component(a),destroy_component(f),destroy_each(l,u)}}}function instance$8(c,e,n){let r,i=[],o=!1;return itemMetas.subscribe(f=>{n(1,i=Object.values(f.views||{}).map(p=>({width:p.features.width.value,height:p.features.height.value,format:p.uri.split(".").at(-1),id:p.id})));const h=Object.values(f.features).length?f.features:defaultSceneFeatures;n(0,r=createFeature(h))}),[r,i,o,()=>{n(2,o=!o)},(f,h)=>{itemMetas.update(p=>{var t;const s={...p};return s.features={...s.features,[h]:{...((t=s.features)==null?void 0:t[h])||defaultSceneFeatures[h],value:f}},s}),canSave.set(!0)}]}class SceneTabContent extends SvelteComponent{constructor(e){super(),init(this,e,instance$8,create_fragment$8,safe_not_equal,{})}}function create_else_block$2(c){let e,n;return e=new Eye_off({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_if_block_3$1(c){let e,n;return e=new Eye({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_default_slot_4$1(c){let e,n,r,i;const o=[create_if_block_3$1,create_else_block$2],a=[];function d(f,h){return f[5]?0:1}return e=d(c),n=a[e]=o[e](c),{c(){n.c(),r=empty()},l(f){n.l(f),r=empty()},m(f,h){a[e].m(f,h),insert_hydration(f,r,h),i=!0},p(f,h){let p=e;e=d(f),e!==p&&(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),n=a[e],n||(n=a[e]=o[e](f),n.c()),transition_in(n,1),n.m(r.parentNode,r))},i(f){i||(transition_in(n),i=!0)},o(f){transition_out(n),i=!1},d(f){f&&detach(r),a[e].d(f)}}}function create_default_slot_3$1(c){let e,n;return e=new Pencil({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p:noop,i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_default_slot_2$2(c){let e,n;return e=new Lock({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p:noop,i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_default_slot_1$4(c){let e,n;return e=new Trash_2({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p:noop,i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_default_slot$5(c){let e,n;return e=new ChevronRight({props:{class:cn("transition",{"rotate-90":c[2]})}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p(r,i){const o={};i&4&&(o.class=cn("transition",{"rotate-90":r[2]})),e.$set(o)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_if_block$6(c){let e,n,r,i,o="Display",a,d,f,h,p,s,t,l=c[0].bbox&&create_if_block_2$3(c),u=c[0].mask&&create_if_block_1$4(c);return s=new FeatureInputs({props:{features:c[8],isEditing:c[6],saveInputChange:c[11]}}),{c(){e=element("div"),n=element("div"),r=element("div"),i=element("p"),i.textContent=o,a=space(),d=element("div"),l&&l.c(),f=space(),u&&u.c(),h=space(),p=element("div"),create_component(s.$$.fragment),this.h()},l(g){e=claim_element(g,"DIV",{class:!0});var m=children(e);n=claim_element(m,"DIV",{class:!0,style:!0});var _=children(n);r=claim_element(_,"DIV",{});var b=children(r);i=claim_element(b,"P",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(i)!=="svelte-1efzuf6"&&(i.textContent=o),a=claim_space(b),d=claim_element(b,"DIV",{class:!0});var y=children(d);l&&l.l(y),f=claim_space(y),u&&u.l(y),y.forEach(detach),b.forEach(detach),h=claim_space(_),p=claim_element(_,"DIV",{});var v=children(p);claim_component(s.$$.fragment,v),v.forEach(detach),_.forEach(detach),m.forEach(detach),this.h()},h(){attr(i,"class","font-medium pb-1"),attr(d,"class","flex flex-col gap-2"),attr(n,"class","border-l-4 border-dashed border-red-400 pl-4 pb-4 pt-4 flex flex-col gap-4"),set_style(n,"border-color",c[1]),attr(e,"class","pl-5 border-b border-b-gray-600 text-slate-800")},m(g,m){insert_hydration(g,e,m),append_hydration(e,n),append_hydration(n,r),append_hydration(r,i),append_hydration(r,a),append_hydration(r,d),l&&l.m(d,null),append_hydration(d,f),u&&u.m(d,null),append_hydration(n,h),append_hydration(n,p),mount_component(s,p,null),t=!0},p(g,m){g[0].bbox?l?(l.p(g,m),m&1&&transition_in(l,1)):(l=create_if_block_2$3(g),l.c(),transition_in(l,1),l.m(d,f)):l&&(group_outros(),transition_out(l,1,1,()=>{l=null}),check_outros()),g[0].mask?u?(u.p(g,m),m&1&&transition_in(u,1)):(u=create_if_block_1$4(g),u.c(),transition_in(u,1),u.m(d,null)):u&&(group_outros(),transition_out(u,1,1,()=>{u=null}),check_outros());const _={};m&256&&(_.features=g[8]),m&64&&(_.isEditing=g[6]),s.$set(_),(!t||m&2)&&set_style(n,"border-color",g[1])},i(g){t||(transition_in(l),transition_in(u),transition_in(s.$$.fragment,g),t=!0)},o(g){transition_out(l),transition_out(u),transition_out(s.$$.fragment,g),t=!1},d(g){g&&detach(e),l&&l.d(),u&&u.d(),destroy_component(s)}}}function create_if_block_2$3(c){let e,n,r,i,o,a="Bounding box",d;function f(p){c[18](p)}let h={handleClick:c[17]};return c[4]!==void 0&&(h.checked=c[4]),n=new Checkbox({props:h}),binding_callbacks.push(()=>bind(n,"checked",f)),{c(){e=element("div"),create_component(n.$$.fragment),i=space(),o=element("span"),o.textContent=a,this.h()},l(p){e=claim_element(p,"DIV",{});var s=children(e);claim_component(n.$$.fragment,s),i=claim_space(s),o=claim_element(s,"SPAN",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(o)!=="svelte-6mx2p3"&&(o.textContent=a),s.forEach(detach),this.h()},h(){attr(o,"class","font-medium")},m(p,s){insert_hydration(p,e,s),mount_component(n,e,null),append_hydration(e,i),append_hydration(e,o),d=!0},p(p,s){const t={};s&16&&(t.handleClick=p[17]),!r&&s&16&&(r=!0,t.checked=p[4],add_flush_callback(()=>r=!1)),n.$set(t)},i(p){d||(transition_in(n.$$.fragment,p),d=!0)},o(p){transition_out(n.$$.fragment,p),d=!1},d(p){p&&detach(e),destroy_component(n)}}}function create_if_block_1$4(c){let e,n,r,i,o,a="Mask",d;function f(p){c[20](p)}let h={handleClick:c[19]};return c[3]!==void 0&&(h.checked=c[3]),n=new Checkbox({props:h}),binding_callbacks.push(()=>bind(n,"checked",f)),{c(){e=element("div"),create_component(n.$$.fragment),i=space(),o=element("span"),o.textContent=a,this.h()},l(p){e=claim_element(p,"DIV",{});var s=children(e);claim_component(n.$$.fragment,s),i=claim_space(s),o=claim_element(s,"SPAN",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(o)!=="svelte-be129e"&&(o.textContent=a),s.forEach(detach),this.h()},h(){attr(o,"class","font-medium")},m(p,s){insert_hydration(p,e,s),mount_component(n,e,null),append_hydration(e,i),append_hydration(e,o),d=!0},p(p,s){const t={};s&8&&(t.handleClick=p[19]),!r&&s&8&&(r=!0,t.checked=p[3],add_flush_callback(()=>r=!1)),n.$set(t)},i(p){d||(transition_in(n.$$.fragment,p),d=!0)},o(p){transition_out(n.$$.fragment,p),d=!1},d(p){p&&detach(e),destroy_component(n)}}}function create_fragment$7(c){let e,n,r,i,o,a,d,f=c[0].id+"",h,p,s,t,l,u,g,m,_,b,y,v,T,w;r=new TooltipIconButton({props:{$$slots:{default:[create_default_slot_4$1]},$$scope:{ctx:c}}}),r.$on("click",c[13]),t=new TooltipIconButton({props:{selected:c[6],$$slots:{default:[create_default_slot_3$1]},$$scope:{ctx:c}}}),t.$on("click",c[14]),u=new TooltipIconButton({props:{selected:c[7],$$slots:{default:[create_default_slot_2$2]},$$scope:{ctx:c}}}),u.$on("click",c[15]),m=new TooltipIconButton({props:{$$slots:{default:[create_default_slot_1$4]},$$scope:{ctx:c}}}),m.$on("click",c[10]),b=new TooltipIconButton({props:{$$slots:{default:[create_default_slot$5]},$$scope:{ctx:c}}}),b.$on("click",c[16]);let S=c[2]&&create_if_block$6(c);return{c(){e=element("div"),n=element("div"),create_component(r.$$.fragment),i=space(),o=element("div"),a=space(),d=element("span"),h=text(f),p=space(),s=element("div"),create_component(t.$$.fragment),l=space(),create_component(u.$$.fragment),g=space(),create_component(m.$$.fragment),_=space(),create_component(b.$$.fragment),v=space(),S&&S.c(),T=empty(),this.h()},l(x){e=claim_element(x,"DIV",{class:!0});var P=children(e);n=claim_element(P,"DIV",{class:!0});var I=children(n);claim_component(r.$$.fragment,I),i=claim_space(I),o=claim_element(I,"DIV",{class:!0,style:!0}),children(o).forEach(detach),a=claim_space(I),d=claim_element(I,"SPAN",{class:!0});var N=children(d);h=claim_text(N,f),N.forEach(detach),I.forEach(detach),p=claim_space(P),s=claim_element(P,"DIV",{class:!0});var L=children(s);claim_component(t.$$.fragment,L),l=claim_space(L),claim_component(u.$$.fragment,L),g=claim_space(L),claim_component(m.$$.fragment,L),_=claim_space(L),claim_component(b.$$.fragment,L),L.forEach(detach),P.forEach(detach),v=claim_space(x),S&&S.l(x),T=empty(),this.h()},h(){attr(o,"class","rounded-full border w-3 h-3 mr-2 flex-[0_0_0.75rem]"),set_style(o,"background",c[1]),attr(d,"class","truncate w-max flex-auto"),attr(n,"class","flex items-center flex-auto max-w-[50%]"),attr(s,"class","flex items-center"),attr(e,"class",y=cn("flex items-center mt-2 hover:bg-gray-100 rounded justify-between text-slate-800",{"bg-gray-100":c[2]}))},m(x,P){insert_hydration(x,e,P),append_hydration(e,n),mount_component(r,n,null),append_hydration(n,i),append_hydration(n,o),append_hydration(n,a),append_hydration(n,d),append_hydration(d,h),append_hydration(e,p),append_hydration(e,s),mount_component(t,s,null),append_hydration(s,l),mount_component(u,s,null),append_hydration(s,g),mount_component(m,s,null),append_hydration(s,_),mount_component(b,s,null),insert_hydration(x,v,P),S&&S.m(x,P),insert_hydration(x,T,P),w=!0},p(x,[P]){const I={};P&2097184&&(I.$$scope={dirty:P,ctx:x}),r.$set(I),(!w||P&2)&&set_style(o,"background",x[1]),(!w||P&1)&&f!==(f=x[0].id+"")&&set_data(h,f);const N={};P&64&&(N.selected=x[6]),P&2097152&&(N.$$scope={dirty:P,ctx:x}),t.$set(N);const L={};P&128&&(L.selected=x[7]),P&2097152&&(L.$$scope={dirty:P,ctx:x}),u.$set(L);const E={};P&2097152&&(E.$$scope={dirty:P,ctx:x}),m.$set(E);const M={};P&2097156&&(M.$$scope={dirty:P,ctx:x}),b.$set(M),(!w||P&4&&y!==(y=cn("flex items-center mt-2 hover:bg-gray-100 rounded justify-between text-slate-800",{"bg-gray-100":x[2]})))&&attr(e,"class",y),x[2]?S?(S.p(x,P),P&4&&transition_in(S,1)):(S=create_if_block$6(x),S.c(),transition_in(S,1),S.m(T.parentNode,T)):S&&(group_outros(),transition_out(S,1,1,()=>{S=null}),check_outros())},i(x){w||(transition_in(r.$$.fragment,x),transition_in(t.$$.fragment,x),transition_in(u.$$.fragment,x),transition_in(m.$$.fragment,x),transition_in(b.$$.fragment,x),transition_in(S),w=!0)},o(x){transition_out(r.$$.fragment,x),transition_out(t.$$.fragment,x),transition_out(u.$$.fragment,x),transition_out(m.$$.fragment,x),transition_out(b.$$.fragment,x),transition_out(S),w=!1},d(x){x&&(detach(e),detach(v),detach(T)),destroy_component(r),destroy_component(t),destroy_component(u),destroy_component(m),destroy_component(b),S&&S.d(x)}}}function instance$7(c,e,n){let r,i,o,a,d,f,{itemObject:h}=e,{colorScale:p}=e,s,t=!0;const l=(x,P,I=["bbox","mask"])=>{itemObjects.update(N=>N.map(L=>(x==="editing"&&(L.displayControl={...L.displayControl,editing:!1}),L.id===h.id?toggleObjectDisplayControl(L,x,I,P):L)))},u=()=>{itemObjects.update(x=>x.filter(P=>P.id!==h.id)),canSave.set(!0)},g=(x,P)=>{itemObjects.update(I=>I.map(N=>(N.id===h.id&&(N.features={...N.features,[P]:{...N.features[P],value:x}}),N))),canSave.set(!0)},m=()=>l("hidden",a),_=()=>l("editing",!o),b=()=>l("locked",!i),y=()=>n(2,t=!t),v=()=>l("hidden",d,["bbox"]);function T(x){d=x,n(4,d),n(0,h)}const w=()=>l("hidden",f,["mask"]);function S(x){f=x,n(3,f),n(0,h)}return c.$$set=x=>{"itemObject"in x&&n(0,h=x.itemObject),"colorScale"in x&&n(12,p=x.colorScale)},c.$$.update=()=>{var x,P,I,N,L,E,M;c.$$.dirty&1&&n(8,r=createFeature(h.features)),c.$$.dirty&4097&&n(1,s=p(h.id)),c.$$.dirty&1&&n(7,i=((x=h.displayControl)==null?void 0:x.locked)||!1),c.$$.dirty&1&&n(6,o=((P=h.displayControl)==null?void 0:P.editing)||!1),c.$$.dirty&1&&n(5,a=!((I=h.displayControl)!=null&&I.hidden)),c.$$.dirty&1&&n(4,d=!((L=(N=h.bbox)==null?void 0:N.displayControl)!=null&&L.hidden)),c.$$.dirty&1&&n(3,f=!((M=(E=h.mask)==null?void 0:E.displayControl)!=null&&M.hidden))},[h,s,t,f,d,a,o,i,r,l,u,g,p,m,_,b,y,v,T,w,S]}class ObjectTabFlatItem extends SvelteComponent{constructor(e){super(),init(this,e,instance$7,create_fragment$7,safe_not_equal,{itemObject:0,colorScale:12})}}function create_else_block$1(c){let e,n;return e=new Eye({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_if_block$5(c){let e,n;return e=new Eye_off({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_default_slot_1$3(c){let e,n,r,i;const o=[create_if_block$5,create_else_block$1],a=[];function d(f,h){return f[1]==="hidden"?0:1}return e=d(c),n=a[e]=o[e](c),{c(){n.c(),r=empty()},l(f){n.l(f),r=empty()},m(f,h){a[e].m(f,h),insert_hydration(f,r,h),i=!0},p(f,h){let p=e;e=d(f),e!==p&&(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),n=a[e],n||(n=a[e]=o[e](f),n.c()),transition_in(n,1),n.m(r.parentNode,r))},i(f){i||(transition_in(n),i=!0)},o(f){transition_out(n),i=!1},d(f){f&&detach(r),a[e].d(f)}}}function create_default_slot$4(c){let e,n;return e=new ChevronRight({props:{class:cn("transition",{"rotate-90":c[2]})}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p(r,i){const o={};i&4&&(o.class=cn("transition",{"rotate-90":r[2]})),e.$set(o)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_fragment$6(c){let e,n,r,i,o,a,d,f,h,p,s,t;r=new TooltipIconButton({props:{tooltipContent:c[3],$$slots:{default:[create_default_slot_1$3]},$$scope:{ctx:c}}}),r.$on("click",c[4]),f=new TooltipIconButton({props:{$$slots:{default:[create_default_slot$4]},$$scope:{ctx:c}}}),f.$on("click",c[7]);const l=c[6].default,u=create_slot(l,c,c[8],null);return{c(){e=element("div"),n=element("div"),create_component(r.$$.fragment),i=space(),o=element("h3"),a=text(c[0]),d=space(),create_component(f.$$.fragment),h=space(),p=element("div"),u&&u.c(),this.h()},l(g){e=claim_element(g,"DIV",{class:!0});var m=children(e);n=claim_element(m,"DIV",{class:!0});var _=children(n);claim_component(r.$$.fragment,_),i=claim_space(_),o=claim_element(_,"H3",{class:!0});var b=children(o);a=claim_text(b,c[0]),b.forEach(detach),_.forEach(detach),d=claim_space(m),claim_component(f.$$.fragment,m),m.forEach(detach),h=claim_space(g),p=claim_element(g,"DIV",{class:!0});var y=children(p);u&&u.l(y),y.forEach(detach),this.h()},h(){attr(o,"class","uppercase font-light"),attr(n,"class","flex items-center gap-3"),attr(e,"class","flex items-center gap-3 justify-between text-slate-800"),attr(p,"class",s=cn("p-2",{hidden:!c[2]}))},m(g,m){insert_hydration(g,e,m),append_hydration(e,n),mount_component(r,n,null),append_hydration(n,i),append_hydration(n,o),append_hydration(o,a),append_hydration(e,d),mount_component(f,e,null),insert_hydration(g,h,m),insert_hydration(g,p,m),u&&u.m(p,null),t=!0},p(g,[m]){const _={};m&8&&(_.tooltipContent=g[3]),m&258&&(_.$$scope={dirty:m,ctx:g}),r.$set(_),(!t||m&1)&&set_data(a,g[0]);const b={};m&260&&(b.$$scope={dirty:m,ctx:g}),f.$set(b),u&&u.p&&(!t||m&256)&&update_slot_base(u,l,g,g[8],t?get_slot_changes(l,g[8],m,null):get_all_dirty_from_scope(g[8]),null),(!t||m&4&&s!==(s=cn("p-2",{hidden:!g[2]})))&&attr(p,"class",s)},i(g){t||(transition_in(r.$$.fragment,g),transition_in(f.$$.fragment,g),transition_in(u,g),t=!0)},o(g){transition_out(r.$$.fragment,g),transition_out(f.$$.fragment,g),transition_out(u,g),t=!1},d(g){g&&(detach(e),detach(h),detach(p)),destroy_component(r),destroy_component(f),u&&u.d(g)}}}function instance$6(c,e,n){let r,{$$slots:i={},$$scope:o}=e,{sectionTitle:a}=e,{modelName:d}=e,f="shown",h=!0;itemObjects.subscribe(t=>{const l=t.filter(m=>d===MODEL_RUN?m.source_id!==GROUND_TRUTH:m.source_id===d);l.every(m=>{var _;return(_=m.displayControl)==null?void 0:_.hidden})&&n(1,f="hidden"),l.every(m=>{var _;return!((_=m.displayControl)!=null&&_.hidden)})&&n(1,f="shown")});const p=()=>{f==="hidden"?n(1,f="shown"):n(1,f="hidden")},s=()=>n(2,h=!h);return c.$$set=t=>{"sectionTitle"in t&&n(0,a=t.sectionTitle),"modelName"in t&&n(5,d=t.modelName),"$$scope"in t&&n(8,o=t.$$scope)},c.$$.update=()=>{c.$$.dirty&2&&n(3,r=f==="hidden"?"show all":"hide all"),c.$$.dirty&34&&itemObjects.update(t=>t.map(l=>l.source_id===d?f==="mixed"?l:toggleObjectDisplayControl(l,"hidden",["bbox","mask"],f==="hidden"):d===MODEL_RUN&&l.source_id!==GROUND_TRUTH?f==="mixed"?l:toggleObjectDisplayControl(l,"hidden",["bbox","mask"],f==="hidden"):l))},[a,f,h,r,p,d,i,s,o]}class ObjectTabModelContent extends SvelteComponent{constructor(e){super(),init(this,e,instance$6,create_fragment$6,safe_not_equal,{sectionTitle:0,modelName:5})}}function get_each_context$1(c,e,n){const r=c.slice();return r[5]=e[n],r}function get_each_context_1(c,e,n){const r=c.slice();return r[8]=e[n],r[9]=e,r[10]=n,r}function get_each_context_2(c,e,n){const r=c.slice();return r[8]=e[n],r[11]=e,r[12]=n,r}function create_each_block_2(c){let e,n,r;function i(a){c[2](a,c[8],c[11],c[12])}let o={colorScale:c[1]};return c[8]!==void 0&&(o.itemObject=c[8]),e=new ObjectTabFlatItem({props:o}),binding_callbacks.push(()=>bind(e,"itemObject",i)),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,d){mount_component(e,a,d),r=!0},p(a,d){c=a;const f={};!n&&d&1&&(n=!0,f.itemObject=c[8],add_flush_callback(()=>n=!1)),e.$set(f)},i(a){r||(transition_in(e.$$.fragment,a),r=!0)},o(a){transition_out(e.$$.fragment,a),r=!1},d(a){destroy_component(e,a)}}}function create_default_slot_2$1(c){let e,n,r=ensure_array_like(c[0][GROUND_TRUTH]),i=[];for(let a=0;a<r.length;a+=1)i[a]=create_each_block_2(get_each_context_2(c,r,a));const o=a=>transition_out(i[a],1,1,()=>{i[a]=null});return{c(){for(let a=0;a<i.length;a+=1)i[a].c();e=empty()},l(a){for(let d=0;d<i.length;d+=1)i[d].l(a);e=empty()},m(a,d){for(let f=0;f<i.length;f+=1)i[f]&&i[f].m(a,d);insert_hydration(a,e,d),n=!0},p(a,d){if(d&3){r=ensure_array_like(a[0][GROUND_TRUTH]);let f;for(f=0;f<r.length;f+=1){const h=get_each_context_2(a,r,f);i[f]?(i[f].p(h,d),transition_in(i[f],1)):(i[f]=create_each_block_2(h),i[f].c(),transition_in(i[f],1),i[f].m(e.parentNode,e))}for(group_outros(),f=r.length;f<i.length;f+=1)o(f);check_outros()}},i(a){if(!n){for(let d=0;d<r.length;d+=1)transition_in(i[d]);n=!0}},o(a){i=i.filter(Boolean);for(let d=0;d<i.length;d+=1)transition_out(i[d]);n=!1},d(a){a&&detach(e),destroy_each(i,a)}}}function create_each_block_1(c){let e,n,r;function i(a){c[3](a,c[8],c[9],c[10])}let o={colorScale:c[1]};return c[8]!==void 0&&(o.itemObject=c[8]),e=new ObjectTabFlatItem({props:o}),binding_callbacks.push(()=>bind(e,"itemObject",i)),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,d){mount_component(e,a,d),r=!0},p(a,d){c=a;const f={};!n&&d&1&&(n=!0,f.itemObject=c[8],add_flush_callback(()=>n=!1)),e.$set(f)},i(a){r||(transition_in(e.$$.fragment,a),r=!0)},o(a){transition_out(e.$$.fragment,a),r=!1},d(a){destroy_component(e,a)}}}function create_default_slot_1$2(c){let e,n,r=ensure_array_like(c[5].objects),i=[];for(let a=0;a<r.length;a+=1)i[a]=create_each_block_1(get_each_context_1(c,r,a));const o=a=>transition_out(i[a],1,1,()=>{i[a]=null});return{c(){for(let a=0;a<i.length;a+=1)i[a].c();e=space()},l(a){for(let d=0;d<i.length;d+=1)i[d].l(a);e=claim_space(a)},m(a,d){for(let f=0;f<i.length;f+=1)i[f]&&i[f].m(a,d);insert_hydration(a,e,d),n=!0},p(a,d){if(d&3){r=ensure_array_like(a[5].objects);let f;for(f=0;f<r.length;f+=1){const h=get_each_context_1(a,r,f);i[f]?(i[f].p(h,d),transition_in(i[f],1)):(i[f]=create_each_block_1(h),i[f].c(),transition_in(i[f],1),i[f].m(e.parentNode,e))}for(group_outros(),f=r.length;f<i.length;f+=1)o(f);check_outros()}},i(a){if(!n){for(let d=0;d<r.length;d+=1)transition_in(i[d]);n=!0}},o(a){i=i.filter(Boolean);for(let d=0;d<i.length;d+=1)transition_out(i[d]);n=!1},d(a){a&&detach(e),destroy_each(i,a)}}}function create_each_block$1(c){let e,n;return e=new ObjectTabModelContent({props:{sectionTitle:c[5].modelName,modelName:c[5].modelName,$$slots:{default:[create_default_slot_1$2]},$$scope:{ctx:c}}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p(r,i){const o={};i&1&&(o.sectionTitle=r[5].modelName),i&1&&(o.modelName=r[5].modelName),i&8193&&(o.$$scope={dirty:i,ctx:r}),e.$set(o)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_default_slot$3(c){let e,n,r=ensure_array_like(c[0][MODEL_RUN]),i=[];for(let a=0;a<r.length;a+=1)i[a]=create_each_block$1(get_each_context$1(c,r,a));const o=a=>transition_out(i[a],1,1,()=>{i[a]=null});return{c(){for(let a=0;a<i.length;a+=1)i[a].c();e=empty()},l(a){for(let d=0;d<i.length;d+=1)i[d].l(a);e=empty()},m(a,d){for(let f=0;f<i.length;f+=1)i[f]&&i[f].m(a,d);insert_hydration(a,e,d),n=!0},p(a,d){if(d&3){r=ensure_array_like(a[0][MODEL_RUN]);let f;for(f=0;f<r.length;f+=1){const h=get_each_context$1(a,r,f);i[f]?(i[f].p(h,d),transition_in(i[f],1)):(i[f]=create_each_block$1(h),i[f].c(),transition_in(i[f],1),i[f].m(e.parentNode,e))}for(group_outros(),f=r.length;f<i.length;f+=1)o(f);check_outros()}},i(a){if(!n){for(let d=0;d<r.length;d+=1)transition_in(i[d]);n=!0}},o(a){i=i.filter(Boolean);for(let d=0;d<i.length;d+=1)transition_out(i[d]);n=!1},d(a){a&&detach(e),destroy_each(i,a)}}}function create_fragment$5(c){let e,n,r,i,o,a;return r=new ObjectTabModelContent({props:{sectionTitle:"Ground truth",modelName:GROUND_TRUTH,$$slots:{default:[create_default_slot_2$1]},$$scope:{ctx:c}}}),o=new ObjectTabModelContent({props:{sectionTitle:"Model run",modelName:MODEL_RUN,$$slots:{default:[create_default_slot$3]},$$scope:{ctx:c}}}),{c(){e=element("div"),n=element("div"),create_component(r.$$.fragment),i=space(),create_component(o.$$.fragment),this.h()},l(d){e=claim_element(d,"DIV",{class:!0});var f=children(e);n=claim_element(f,"DIV",{});var h=children(n);claim_component(r.$$.fragment,h),h.forEach(detach),i=claim_space(f),claim_component(o.$$.fragment,f),f.forEach(detach),this.h()},h(){attr(e,"class","p-2")},m(d,f){insert_hydration(d,e,f),append_hydration(e,n),mount_component(r,n,null),append_hydration(e,i),mount_component(o,e,null),a=!0},p(d,[f]){const h={};f&8193&&(h.$$scope={dirty:f,ctx:d}),r.$set(h);const p={};f&8193&&(p.$$scope={dirty:f,ctx:d}),o.$set(p)},i(d){a||(transition_in(r.$$.fragment,d),transition_in(o.$$.fragment,d),a=!0)},o(d){transition_out(r.$$.fragment,d),transition_out(o.$$.fragment,d),a=!1},d(d){d&&detach(e),destroy_component(r),destroy_component(o)}}}function instance$5(c,e,n){let r={[GROUND_TRUTH]:[],[MODEL_RUN]:[]},i=[];itemObjects.subscribe(f=>{i=f.map(h=>h.id),n(0,r=sortObjectsByModel(f))});let o=ordinalColorScale(i);function a(f,h,p,s){p[s]=f,n(0,r)}function d(f,h,p,s){p[s]=f,n(0,r)}return[r,o,a,d]}class ObjectTabContent extends SvelteComponent{constructor(e){super(),init(this,e,instance$5,create_fragment$5,safe_not_equal,{})}}function get_each_context(c,e,n){const r=c.slice();return r[11]=e[n],r[13]=n,r}function create_if_block$4(c){let e,n,r,i=c[0].type+"",o,a,d,f,h,p,s,t,l,u,g=ensure_array_like(c[2]),m=[];for(let b=0;b<g.length;b+=1)m[b]=create_each_block(get_each_context(c,g,b));const _=b=>transition_out(m[b],1,1,()=>{m[b]=null});return h=new Button({props:{class:"text-white",$$slots:{default:[create_default_slot_1$1]},$$scope:{ctx:c}}}),h.$on("click",c[10]),s=new Button({props:{class:"text-white",type:"submit",disabled:!c[1],$$slots:{default:[create_default_slot$2]},$$scope:{ctx:c}}}),{c(){e=element("form"),n=element("p"),r=text("Sauvegarde "),o=text(i),a=space();for(let b=0;b<m.length;b+=1)m[b].c();d=space(),f=element("div"),create_component(h.$$.fragment),p=space(),create_component(s.$$.fragment),this.h()},l(b){e=claim_element(b,"FORM",{class:!0});var y=children(e);n=claim_element(y,"P",{});var v=children(n);r=claim_text(v,"Sauvegarde "),o=claim_text(v,i),v.forEach(detach),a=claim_space(y);for(let w=0;w<m.length;w+=1)m[w].l(y);d=claim_space(y),f=claim_element(y,"DIV",{class:!0});var T=children(f);claim_component(h.$$.fragment,T),p=claim_space(T),claim_component(s.$$.fragment,T),T.forEach(detach),y.forEach(detach),this.h()},h(){attr(f,"class","flex gap-4"),attr(e,"class","flex flex-col gap-4 p-4")},m(b,y){insert_hydration(b,e,y),append_hydration(e,n),append_hydration(n,r),append_hydration(n,o),append_hydration(e,a);for(let v=0;v<m.length;v+=1)m[v]&&m[v].m(e,null);append_hydration(e,d),append_hydration(e,f),mount_component(h,f,null),append_hydration(f,p),mount_component(s,f,null),t=!0,l||(u=listen(e,"submit",prevent_default(c[3])),l=!0)},p(b,y){if((!t||y&1)&&i!==(i=b[0].type+"")&&set_data(o,i),y&20){g=ensure_array_like(b[2]);let w;for(w=0;w<g.length;w+=1){const S=get_each_context(b,g,w);m[w]?(m[w].p(S,y),transition_in(m[w],1)):(m[w]=create_each_block(S),m[w].c(),transition_in(m[w],1),m[w].m(e,d))}for(group_outros(),w=g.length;w<m.length;w+=1)_(w);check_outros()}const v={};y&16384&&(v.$$scope={dirty:y,ctx:b}),h.$set(v);const T={};y&2&&(T.disabled=!b[1]),y&16384&&(T.$$scope={dirty:y,ctx:b}),s.$set(T)},i(b){if(!t){for(let y=0;y<g.length;y+=1)transition_in(m[y]);transition_in(h.$$.fragment,b),transition_in(s.$$.fragment,b),t=!0}},o(b){m=m.filter(Boolean);for(let y=0;y<m.length;y+=1)transition_out(m[y]);transition_out(h.$$.fragment,b),transition_out(s.$$.fragment,b),t=!1},d(b){b&&detach(e),destroy_each(m,b),destroy_component(h),destroy_component(s),l=!1,u()}}}function create_if_block_4(c){let e,n,r,i,o=c[11].label+"",a,d,f;function h(...s){return c[7](c[11],...s)}n=new Checkbox({props:{handleClick:h}});let p=c[11].required&&create_if_block_5();return{c(){e=element("div"),create_component(n.$$.fragment),r=space(),i=element("span"),a=text(o),d=space(),p&&p.c(),this.h()},l(s){e=claim_element(s,"DIV",{class:!0});var t=children(e);claim_component(n.$$.fragment,t),r=claim_space(t),i=claim_element(t,"SPAN",{});var l=children(i);a=claim_text(l,o),d=claim_space(l),p&&p.l(l),l.forEach(detach),t.forEach(detach),this.h()},h(){attr(e,"class","flex gap-4 items-center")},m(s,t){insert_hydration(s,e,t),mount_component(n,e,null),append_hydration(e,r),append_hydration(e,i),append_hydration(i,a),append_hydration(i,d),p&&p.m(i,null),f=!0},p(s,t){c=s;const l={};t&4&&(l.handleClick=h),n.$set(l),(!f||t&4)&&o!==(o=c[11].label+"")&&set_data(a,o),c[11].required?p||(p=create_if_block_5(),p.c(),p.m(i,null)):p&&(p.d(1),p=null)},i(s){f||(transition_in(n.$$.fragment,s),f=!0)},o(s){transition_out(n.$$.fragment,s),f=!1},d(s){s&&detach(e),destroy_component(n),p&&p.d()}}}function create_if_block_5(c){let e,n="*";return{c(){e=element("span"),e.textContent=n},l(r){e=claim_element(r,"SPAN",{"data-svelte-h":!0}),get_svelte_dataset(e)!=="svelte-140b0co"&&(e.textContent=n)},m(r,i){insert_hydration(r,e,i)},d(r){r&&detach(e)}}}function create_if_block_3(c){let e,n;function r(...i){return c[8](c[11],...i)}return e=new Combobox({props:{placeholder:`Select a ${c[11].label}`,listItems:c[11].options,saveValue:r}}),{c(){create_component(e.$$.fragment)},l(i){claim_component(e.$$.fragment,i)},m(i,o){mount_component(e,i,o),n=!0},p(i,o){c=i;const a={};o&4&&(a.placeholder=`Select a ${c[11].label}`),o&4&&(a.listItems=c[11].options),o&4&&(a.saveValue=r),e.$set(a)},i(i){n||(transition_in(e.$$.fragment,i),n=!0)},o(i){transition_out(e.$$.fragment,i),n=!1},d(i){destroy_component(e,i)}}}function create_if_block_1$3(c){let e,n,r=c[11].label+"",i,o,a,d,f,h=c[11].required&&create_if_block_2$2();function p(...s){return c[9](c[11],...s)}return d=new Input({props:{type:c[11].type==="str"?"text":"number",step:c[11].type==="int"?"1":"any",autofocus:c[13]===0}}),d.$on("keyup",keyup_handler),d.$on("change",p),{c(){e=element("div"),n=element("span"),i=text(r),o=space(),h&&h.c(),a=space(),create_component(d.$$.fragment)},l(s){e=claim_element(s,"DIV",{});var t=children(e);n=claim_element(t,"SPAN",{});var l=children(n);i=claim_text(l,r),o=claim_space(l),h&&h.l(l),l.forEach(detach),a=claim_space(t),claim_component(d.$$.fragment,t),t.forEach(detach)},m(s,t){insert_hydration(s,e,t),append_hydration(e,n),append_hydration(n,i),append_hydration(n,o),h&&h.m(n,null),append_hydration(e,a),mount_component(d,e,null),f=!0},p(s,t){c=s,(!f||t&4)&&r!==(r=c[11].label+"")&&set_data(i,r),c[11].required?h||(h=create_if_block_2$2(),h.c(),h.m(n,null)):h&&(h.d(1),h=null);const l={};t&4&&(l.type=c[11].type==="str"?"text":"number"),t&4&&(l.step=c[11].type==="int"?"1":"any"),d.$set(l)},i(s){f||(transition_in(d.$$.fragment,s),f=!0)},o(s){transition_out(d.$$.fragment,s),f=!1},d(s){s&&detach(e),h&&h.d(),destroy_component(d)}}}function create_if_block_2$2(c){let e,n="*";return{c(){e=element("span"),e.textContent=n},l(r){e=claim_element(r,"SPAN",{"data-svelte-h":!0}),get_svelte_dataset(e)!=="svelte-140b0co"&&(e.textContent=n)},m(r,i){insert_hydration(r,e,i)},d(r){r&&detach(e)}}}function create_each_block(c){let e,n,r=["int","float","str"].includes(c[11].type),i,o,a=c[11].type==="bool"&&create_if_block_4(c),d=c[11].type==="list"&&create_if_block_3(c),f=r&&create_if_block_1$3(c);return{c(){a&&a.c(),e=space(),d&&d.c(),n=space(),f&&f.c(),i=empty()},l(h){a&&a.l(h),e=claim_space(h),d&&d.l(h),n=claim_space(h),f&&f.l(h),i=empty()},m(h,p){a&&a.m(h,p),insert_hydration(h,e,p),d&&d.m(h,p),insert_hydration(h,n,p),f&&f.m(h,p),insert_hydration(h,i,p),o=!0},p(h,p){h[11].type==="bool"?a?(a.p(h,p),p&4&&transition_in(a,1)):(a=create_if_block_4(h),a.c(),transition_in(a,1),a.m(e.parentNode,e)):a&&(group_outros(),transition_out(a,1,1,()=>{a=null}),check_outros()),h[11].type==="list"?d?(d.p(h,p),p&4&&transition_in(d,1)):(d=create_if_block_3(h),d.c(),transition_in(d,1),d.m(n.parentNode,n)):d&&(group_outros(),transition_out(d,1,1,()=>{d=null}),check_outros()),p&4&&(r=["int","float","str"].includes(h[11].type)),r?f?(f.p(h,p),p&4&&transition_in(f,1)):(f=create_if_block_1$3(h),f.c(),transition_in(f,1),f.m(i.parentNode,i)):f&&(group_outros(),transition_out(f,1,1,()=>{f=null}),check_outros())},i(h){o||(transition_in(a),transition_in(d),transition_in(f),o=!0)},o(h){transition_out(a),transition_out(d),transition_out(f),o=!1},d(h){h&&(detach(e),detach(n),detach(i)),a&&a.d(h),d&&d.d(h),f&&f.d(h)}}}function create_default_slot_1$1(c){let e;return{c(){e=text("cancel")},l(n){e=claim_text(n,"cancel")},m(n,r){insert_hydration(n,e,r)},d(n){n&&detach(e)}}}function create_default_slot$2(c){let e;return{c(){e=text("confirm")},l(n){e=claim_text(n,"confirm")},m(n,r){insert_hydration(n,e,r)},d(n){n&&detach(e)}}}function create_fragment$4(c){let e,n,r=c[0].status==="inProgress"&&create_if_block$4(c);return{c(){r&&r.c(),e=empty()},l(i){r&&r.l(i),e=empty()},m(i,o){r&&r.m(i,o),insert_hydration(i,e,o),n=!0},p(i,[o]){i[0].status==="inProgress"?r?(r.p(i,o),o&1&&transition_in(r,1)):(r=create_if_block$4(i),r.c(),transition_in(r,1),r.m(e.parentNode,e)):r&&(group_outros(),transition_out(r,1,1,()=>{r=null}),check_outros())},i(i){n||(transition_in(r),n=!0)},o(i){transition_out(r),n=!1},d(i){i&&detach(e),r&&r.d(i)}}}const keyup_handler=c=>c.stopPropagation();function instance$4(c,e,n){let r,i=!1,o={},a=[],d;itemMetas.subscribe(u=>{const g=Object.values(u.itemFeatures||defaultObjectFeatures).map(m=>({...m,label:m.name,required:!0,type:m.dtype}));n(6,d=createSchemaFromFeatures(g)),n(2,a=createObjectInputsSchema.parse(g))}),newShape.subscribe(u=>{u&&n(0,r=u)});const f=()=>{const u=mapShapeInputsToFeatures(o,a);itemObjects.update(g=>{if(r.status!=="inProgress")return g;let m=null;const _={id:`object${g.length+1}`,item_id:r.itemId,source_id:GROUND_TRUTH,view_id:r.viewId,features:u};return r.type==="rectangle"&&(m={..._,bbox:{coords:[r.attrs.x/r.imageWidth,r.attrs.y/r.imageHeight,r.attrs.width/r.imageWidth,r.attrs.height/r.imageHeight],format:"xywh",is_normalized:!0,confidence:1}}),r.type==="mask"&&(m={..._,isManual:!!r.isManual,mask:{counts:r.rle.counts,size:r.rle.size}}),[...g,...m?[m]:[]]}),newShape.set({status:"none"}),canSave.set(!0)},h=(u,g)=>{n(5,o[g]=u,o)},p=(u,g)=>h(g,u.name),s=(u,g)=>h(g,u.name),t=(u,g)=>h(u.type==="str"?g.currentTarget.value:Number(g.currentTarget.value),u.name),l=()=>newShape.update(u=>({...u,status:"none"}));return c.$$.update=()=>{if(c.$$.dirty&96){const u=d.safeParse(o);n(1,i=u.success)}},[r,i,a,f,h,o,d,p,s,t,l]}class SaveShapeForm extends SvelteComponent{constructor(e){super(),init(this,e,instance$4,create_fragment$4,safe_not_equal,{})}}function create_else_block(c){let e,n,r;function i(a){c[5](a)}let o={class:"h-full",$$slots:{default:[create_default_slot$1]},$$scope:{ctx:c}};return c[2]!==void 0&&(o.value=c[2]),e=new Root$1({props:o}),binding_callbacks.push(()=>bind(e,"value",i)),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,d){mount_component(e,a,d),r=!0},p(a,d){const f={};d&73&&(f.$$scope={dirty:d,ctx:a}),!n&&d&4&&(n=!0,f.value=a[2],add_flush_callback(()=>n=!1)),e.$set(f)},i(a){r||(transition_in(e.$$.fragment,a),r=!0)},o(a){transition_out(e.$$.fragment,a),r=!1},d(a){destroy_component(e,a)}}}function create_if_block$3(c){let e,n;return e=new SaveShapeForm({}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p:noop,i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_default_slot_5(c){let e;return{c(){e=text("Scene")},l(n){e=claim_text(n,"Scene")},m(n,r){insert_hydration(n,e,r)},d(n){n&&detach(e)}}}function create_default_slot_4(c){let e;return{c(){e=text("Objects")},l(n){e=claim_text(n,"Objects")},m(n,r){insert_hydration(n,e,r)},d(n){n&&detach(e)}}}function create_default_slot_3(c){let e,n,r,i;return e=new Tabs_trigger({props:{value:"scene",$$slots:{default:[create_default_slot_5]},$$scope:{ctx:c}}}),r=new Tabs_trigger({props:{value:"objects",$$slots:{default:[create_default_slot_4]},$$scope:{ctx:c}}}),{c(){create_component(e.$$.fragment),n=space(),create_component(r.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(r.$$.fragment,o)},m(o,a){mount_component(e,o,a),insert_hydration(o,n,a),mount_component(r,o,a),i=!0},p(o,a){const d={};a&64&&(d.$$scope={dirty:a,ctx:o}),e.$set(d);const f={};a&64&&(f.$$scope={dirty:a,ctx:o}),r.$set(f)},i(o){i||(transition_in(e.$$.fragment,o),transition_in(r.$$.fragment,o),i=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(r.$$.fragment,o),i=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(r,o)}}}function create_else_block_2(c){let e,n;return e=new SceneTabContent({}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_if_block_2$1(c){let e,n,r,i,o,a,d;return n=new Skeleton({props:{class:"h-8 w-full"}}),i=new Skeleton({props:{class:"h-8 w-full"}}),a=new Skeleton({props:{class:"h-8 w-full"}}),{c(){e=element("div"),create_component(n.$$.fragment),r=space(),create_component(i.$$.fragment),o=space(),create_component(a.$$.fragment),this.h()},l(f){e=claim_element(f,"DIV",{class:!0});var h=children(e);claim_component(n.$$.fragment,h),r=claim_space(h),claim_component(i.$$.fragment,h),o=claim_space(h),claim_component(a.$$.fragment,h),h.forEach(detach),this.h()},h(){attr(e,"class","p-4 flex flex-col gap-4")},m(f,h){insert_hydration(f,e,h),mount_component(n,e,null),append_hydration(e,r),mount_component(i,e,null),append_hydration(e,o),mount_component(a,e,null),d=!0},i(f){d||(transition_in(n.$$.fragment,f),transition_in(i.$$.fragment,f),transition_in(a.$$.fragment,f),d=!0)},o(f){transition_out(n.$$.fragment,f),transition_out(i.$$.fragment,f),transition_out(a.$$.fragment,f),d=!1},d(f){f&&detach(e),destroy_component(n),destroy_component(i),destroy_component(a)}}}function create_default_slot_2(c){let e,n,r,i;const o=[create_if_block_2$1,create_else_block_2],a=[];function d(f,h){return f[0]?0:1}return e=d(c),n=a[e]=o[e](c),{c(){n.c(),r=empty()},l(f){n.l(f),r=empty()},m(f,h){a[e].m(f,h),insert_hydration(f,r,h),i=!0},p(f,h){let p=e;e=d(f),e!==p&&(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),n=a[e],n||(n=a[e]=o[e](f),n.c()),transition_in(n,1),n.m(r.parentNode,r))},i(f){i||(transition_in(n),i=!0)},o(f){transition_out(n),i=!1},d(f){f&&detach(r),a[e].d(f)}}}function create_else_block_1(c){let e,n;return e=new ObjectTabContent({}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_if_block_1$2(c){let e,n,r,i,o,a,d;return n=new Skeleton({props:{class:"h-8 w-full"}}),i=new Skeleton({props:{class:"h-8 w-full"}}),a=new Skeleton({props:{class:"h-8 w-full"}}),{c(){e=element("div"),create_component(n.$$.fragment),r=space(),create_component(i.$$.fragment),o=space(),create_component(a.$$.fragment),this.h()},l(f){e=claim_element(f,"DIV",{class:!0});var h=children(e);claim_component(n.$$.fragment,h),r=claim_space(h),claim_component(i.$$.fragment,h),o=claim_space(h),claim_component(a.$$.fragment,h),h.forEach(detach),this.h()},h(){attr(e,"class","p-4 flex flex-col gap-4")},m(f,h){insert_hydration(f,e,h),mount_component(n,e,null),append_hydration(e,r),mount_component(i,e,null),append_hydration(e,o),mount_component(a,e,null),d=!0},i(f){d||(transition_in(n.$$.fragment,f),transition_in(i.$$.fragment,f),transition_in(a.$$.fragment,f),d=!0)},o(f){transition_out(n.$$.fragment,f),transition_out(i.$$.fragment,f),transition_out(a.$$.fragment,f),d=!1},d(f){f&&detach(e),destroy_component(n),destroy_component(i),destroy_component(a)}}}function create_default_slot_1(c){let e,n,r,i;const o=[create_if_block_1$2,create_else_block_1],a=[];function d(f,h){return f[0]?0:1}return e=d(c),n=a[e]=o[e](c),{c(){n.c(),r=empty()},l(f){n.l(f),r=empty()},m(f,h){a[e].m(f,h),insert_hydration(f,r,h),i=!0},p(f,h){let p=e;e=d(f),e!==p&&(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),n=a[e],n||(n=a[e]=o[e](f),n.c()),transition_in(n,1),n.m(r.parentNode,r))},i(f){i||(transition_in(n),i=!0)},o(f){transition_out(n),i=!1},d(f){f&&detach(r),a[e].d(f)}}}function create_default_slot$1(c){let e,n,r,i,o,a,d,f,h,p,s,t,l,u;return e=new Tabs_list({props:{class:"h-[48px]",$$slots:{default:[create_default_slot_3]},$$scope:{ctx:c}}}),i=new Tabs_content({props:{value:"scene",class:"bg-red max-h-[calc(100vh-200px)] overflow-y-auto",$$slots:{default:[create_default_slot_2]},$$scope:{ctx:c}}}),a=new Tabs_content({props:{value:"objects",class:"bg-red max-h-[calc(100vh-200px)] overflow-y-auto",$$slots:{default:[create_default_slot_1]},$$scope:{ctx:c}}}),{c(){create_component(e.$$.fragment),n=space(),r=element("div"),create_component(i.$$.fragment),o=space(),create_component(a.$$.fragment),d=space(),f=element("button"),h=text("SAVE CHANGES"),this.h()},l(g){claim_component(e.$$.fragment,g),n=claim_space(g),r=claim_element(g,"DIV",{class:!0});var m=children(r);claim_component(i.$$.fragment,m),o=claim_space(m),claim_component(a.$$.fragment,m),d=claim_space(m),f=claim_element(m,"BUTTON",{class:!0});var _=children(f);h=claim_text(_,"SAVE CHANGES"),_.forEach(detach),m.forEach(detach),this.h()},h(){f.disabled=p=!c[3],attr(f,"class",s=cn("h-[48px] w-full border-t border-t-primary-light hover:bg-primary-light hover:cursor-pointer",{"bg-slate-100 hover:bg-slate-100 pointer-events-none cursor-not-allowed text-slate-500":!c[3]})),attr(r,"class","h-[calc(100%-48px)] flex flex-col justify-between")},m(g,m){mount_component(e,g,m),insert_hydration(g,n,m),insert_hydration(g,r,m),mount_component(i,r,null),append_hydration(r,o),mount_component(a,r,null),append_hydration(r,d),append_hydration(r,f),append_hydration(f,h),t=!0,l||(u=listen(f,"click",c[4]),l=!0)},p(g,m){const _={};m&64&&(_.$$scope={dirty:m,ctx:g}),e.$set(_);const b={};m&65&&(b.$$scope={dirty:m,ctx:g}),i.$set(b);const y={};m&65&&(y.$$scope={dirty:m,ctx:g}),a.$set(y),(!t||m&8&&p!==(p=!g[3]))&&(f.disabled=p),(!t||m&8&&s!==(s=cn("h-[48px] w-full border-t border-t-primary-light hover:bg-primary-light hover:cursor-pointer",{"bg-slate-100 hover:bg-slate-100 pointer-events-none cursor-not-allowed text-slate-500":!g[3]})))&&attr(f,"class",s)},i(g){t||(transition_in(e.$$.fragment,g),transition_in(i.$$.fragment,g),transition_in(a.$$.fragment,g),t=!0)},o(g){transition_out(e.$$.fragment,g),transition_out(i.$$.fragment,g),transition_out(a.$$.fragment,g),t=!1},d(g){g&&(detach(n),detach(r)),destroy_component(e,g),destroy_component(i),destroy_component(a),l=!1,u()}}}function create_fragment$3(c){let e,n,r,i;const o=[create_if_block$3,create_else_block],a=[];function d(f,h){var p;return((p=f[1])==null?void 0:p.status)==="inProgress"?0:1}return n=d(c),r=a[n]=o[n](c),{c(){e=element("div"),r.c(),this.h()},l(f){e=claim_element(f,"DIV",{class:!0});var h=children(e);r.l(h),h.forEach(detach),this.h()},h(){attr(e,"class","h-full max-h-screen shadow-sm border-l border-slate-200 bg-popover")},m(f,h){insert_hydration(f,e,h),a[n].m(e,null),i=!0},p(f,[h]){let p=n;n=d(f),n===p?a[n].p(f,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),r=a[n],r?r.p(f,h):(r=a[n]=o[n](f),r.c()),transition_in(r,1),r.m(e,null))},i(f){i||(transition_in(r),i=!0)},o(f){transition_out(r),i=!1},d(f){f&&detach(e),a[n].d()}}}function instance$3(c,e,n){let{isLoading:r}=e,i,o="scene",a=!1;canSave.subscribe(h=>{n(3,a=h)}),newShape.subscribe(h=>{n(1,i=h)});function d(h){bubble.call(this,c,h)}function f(h){o=h,n(2,o)}return c.$$set=h=>{"isLoading"in h&&n(0,r=h.isLoading)},[r,i,o,a,d,f]}class ActionsTabs extends SvelteComponent{constructor(e){super(),init(this,e,instance$3,create_fragment$3,safe_not_equal,{isLoading:0})}}async function loadEmbeddings(c,e,n){const r={};if(e){const i=await getItemEmbeddings(n,c,e);if(i.embeddings)for(const[o,a]of Object.entries(i.embeddings))try{const d=parse(b64ToBuffer(a.data));r[o]=new ort_minExports.Tensor("float32",d.data,d.shape)}catch(d){console.warn("AnnotationWorkspace.loadModel - Error loading embeddings",d)}}return r}function create_if_block_2(c){let e,n,r;function i(a){c[8](a)}let o={message:"Please select your model for interactive segmentation.",choices:c[0],ifNoChoices:""};return c[1]!==void 0&&(o.selected=c[1]),e=new SelectModal({props:o}),binding_callbacks.push(()=>bind(e,"selected",i)),e.$on("confirm",c[3]),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,d){mount_component(e,a,d),r=!0},p(a,d){const f={};d&1&&(f.choices=a[0]),!n&&d&2&&(n=!0,f.selected=a[1],add_flush_callback(()=>n=!1)),e.$set(f)},i(a){r||(transition_in(e.$$.fragment,a),r=!0)},o(a){transition_out(e.$$.fragment,a),r=!1},d(a){destroy_component(e,a)}}}function create_if_block_1$1(c){let e,n;return e=new WarningModal({props:{message:"It looks like there is no model for interactive segmentation in your dataset library.",details:"Please refer to our interactive annotation notebook for information on how to export your model to ONNX."}}),e.$on("confirm",c[9]),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p:noop,i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_if_block$2(c){let e,n;return e=new WarningModal({props:{message:"No embeddings found for model "+c[1]+".",details:"Please refer to our interactive annotation notebook for information on how to compute embeddings on your dataset."}}),e.$on("confirm",c[10]),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,i){mount_component(e,r,i),n=!0},p(r,i){const o={};i&2&&(o.message="No embeddings found for model "+r[1]+"."),e.$set(o)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_fragment$2(c){let e,n,r,i,o=c[2]==="selectModel"&&create_if_block_2(c),a=c[2]==="noModel"&&create_if_block_1$1(c),d=c[2]==="noEmbeddings"&&create_if_block$2(c);return{c(){o&&o.c(),e=space(),a&&a.c(),n=space(),d&&d.c(),r=empty()},l(f){o&&o.l(f),e=claim_space(f),a&&a.l(f),n=claim_space(f),d&&d.l(f),r=empty()},m(f,h){o&&o.m(f,h),insert_hydration(f,e,h),a&&a.m(f,h),insert_hydration(f,n,h),d&&d.m(f,h),insert_hydration(f,r,h),i=!0},p(f,[h]){f[2]==="selectModel"?o?(o.p(f,h),h&4&&transition_in(o,1)):(o=create_if_block_2(f),o.c(),transition_in(o,1),o.m(e.parentNode,e)):o&&(group_outros(),transition_out(o,1,1,()=>{o=null}),check_outros()),f[2]==="noModel"?a?(a.p(f,h),h&4&&transition_in(a,1)):(a=create_if_block_1$1(f),a.c(),transition_in(a,1),a.m(n.parentNode,n)):a&&(group_outros(),transition_out(a,1,1,()=>{a=null}),check_outros()),f[2]==="noEmbeddings"?d?(d.p(f,h),h&4&&transition_in(d,1)):(d=create_if_block$2(f),d.c(),transition_in(d,1),d.m(r.parentNode,r)):d&&(group_outros(),transition_out(d,1,1,()=>{d=null}),check_outros())},i(f){i||(transition_in(o),transition_in(a),transition_in(d),i=!0)},o(f){transition_out(o),transition_out(a),transition_out(d),i=!1},d(f){f&&(detach(e),detach(n),detach(r)),o&&o.d(f),a&&a.d(f),d&&d.d(f)}}}function instance$2(c,e,n){let{models:r}=e,{currentDatasetId:i}=e,{selectedItemId:o}=e,{embeddings:a}=e,{selectedTool:d}=e,f="none",h;modelsStore.subscribe(g=>{n(2,f=g.currentModalOpen),n(1,h=g.selectedModelName)});const p=new SAM;async function s(){modelsStore.update(g=>({...g,currentModalOpen:"none"})),await p.init("/data/models/"+h),interactiveSegmenterModel.set(p)}onMount(async()=>{if(r.length>0){let g=r.filter(m=>m.includes("sam"));g.length==1&&(modelsStore.update(m=>({...m,selectedModelName:g[0]})),await s())}});function t(g){h=g,n(1,h)}const l=()=>n(2,f="none"),u=()=>n(2,f="selectModel");return c.$$set=g=>{"models"in g&&n(0,r=g.models),"currentDatasetId"in g&&n(5,i=g.currentDatasetId),"selectedItemId"in g&&n(6,o=g.selectedItemId),"embeddings"in g&&n(4,a=g.embeddings),"selectedTool"in g&&n(7,d=g.selectedTool)},c.$$.update=()=>{c.$$.dirty&98&&o&&h&&loadEmbeddings(o,h,i).then(g=>{n(4,a=g)}).catch(g=>{modelsStore.update(m=>({...m,currentModalOpen:"noEmbeddings"})),console.error("cannot load Embeddings",g)}),c.$$.dirty&131&&(d!=null&&d.isSmart&&r.length>1&&!h&&modelsStore.update(g=>({...g,currentModalOpen:"selectModel"})),d!=null&&d.isSmart&&r.length==0&&modelsStore.update(g=>({...g,currentModalOpen:"noModel"}))),c.$$.dirty&2&&h&&modelsStore.update(g=>({...g,selectedModelName:h,currentModalOpen:g.selectedModelName?"none":"selectModel"}))},[r,h,f,s,a,i,o,d,t,l,u]}class LoadModelModal extends SvelteComponent{constructor(e){super(),init(this,e,instance$2,create_fragment$2,safe_not_equal,{models:0,currentDatasetId:5,selectedItemId:6,embeddings:4,selectedTool:7})}}function create_if_block$1(c){let e,n,r;return n=new Loader_2({props:{class:"animate-spin"}}),{c(){e=element("div"),create_component(n.$$.fragment),this.h()},l(i){e=claim_element(i,"DIV",{class:!0});var o=children(e);claim_component(n.$$.fragment,o),o.forEach(detach),this.h()},h(){attr(e,"class","h-full w-full flex justify-center items-center absolute top-0 left-0 bg-gray-300 z-50 opacity-30")},m(i,o){insert_hydration(i,e,o),mount_component(n,e,null),r=!0},i(i){r||(transition_in(n.$$.fragment,i),r=!0)},o(i){transition_out(n.$$.fragment,i),r=!1},d(i){i&&detach(e),destroy_component(n)}}}function create_fragment$1(c){let e,n,r,i,o,a,d,f,h,p,s,t,l,u,g=c[4]&&create_if_block$1();function m(S){c[13](S)}let _={};c[5]!==void 0&&(_.selectedTool=c[5]),r=new Toolbar({props:_}),binding_callbacks.push(()=>bind(r,"selectedTool",m));function b(S){c[14](S)}function y(S){c[15](S)}let v={selectedTool:c[5],selectedItem:c[1],embeddings:c[8],isLoading:c[3]};c[6]!==void 0&&(v.bboxes=c[6]),c[7]!==void 0&&(v.masks=c[7]),a=new ImageCanvas({props:v}),binding_callbacks.push(()=>bind(a,"bboxes",b)),binding_callbacks.push(()=>bind(a,"masks",y)),p=new ActionsTabs({props:{isLoading:c[3]}}),p.$on("click",c[9]);function T(S){c[16](S)}let w={models:c[2],currentDatasetId:c[0],selectedItemId:c[1].id,selectedTool:c[5]};return c[8]!==void 0&&(w.embeddings=c[8]),t=new LoadModelModal({props:w}),binding_callbacks.push(()=>bind(t,"embeddings",T)),{c(){e=element("div"),g&&g.c(),n=space(),create_component(r.$$.fragment),o=space(),create_component(a.$$.fragment),h=space(),create_component(p.$$.fragment),s=space(),create_component(t.$$.fragment),this.h()},l(S){e=claim_element(S,"DIV",{class:!0});var x=children(e);g&&g.l(x),n=claim_space(x),claim_component(r.$$.fragment,x),o=claim_space(x),claim_component(a.$$.fragment,x),h=claim_space(x),claim_component(p.$$.fragment,x),s=claim_space(x),claim_component(t.$$.fragment,x),x.forEach(detach),this.h()},h(){attr(e,"class","w-full h-full grid grid-cols-[48px_calc(100%-380px-48px)_380px]")},m(S,x){insert_hydration(S,e,x),g&&g.m(e,null),append_hydration(e,n),mount_component(r,e,null),append_hydration(e,o),mount_component(a,e,null),append_hydration(e,h),mount_component(p,e,null),append_hydration(e,s),mount_component(t,e,null),u=!0},p(S,[x]){S[4]?g?x&16&&transition_in(g,1):(g=create_if_block$1(),g.c(),transition_in(g,1),g.m(e,n)):g&&(group_outros(),transition_out(g,1,1,()=>{g=null}),check_outros());const P={};!i&&x&32&&(i=!0,P.selectedTool=S[5],add_flush_callback(()=>i=!1)),r.$set(P);const I={};x&32&&(I.selectedTool=S[5]),x&2&&(I.selectedItem=S[1]),x&256&&(I.embeddings=S[8]),x&8&&(I.isLoading=S[3]),!d&&x&64&&(d=!0,I.bboxes=S[6],add_flush_callback(()=>d=!1)),!f&&x&128&&(f=!0,I.masks=S[7],add_flush_callback(()=>f=!1)),a.$set(I);const N={};x&8&&(N.isLoading=S[3]),p.$set(N);const L={};x&4&&(L.models=S[2]),x&1&&(L.currentDatasetId=S[0]),x&2&&(L.selectedItemId=S[1].id),x&32&&(L.selectedTool=S[5]),!l&&x&256&&(l=!0,L.embeddings=S[8],add_flush_callback(()=>l=!1)),t.$set(L)},i(S){u||(transition_in(g),transition_in(r.$$.fragment,S),transition_in(a.$$.fragment,S),transition_in(p.$$.fragment,S),transition_in(t.$$.fragment,S),u=!0)},o(S){transition_out(g),transition_out(r.$$.fragment,S),transition_out(a.$$.fragment,S),transition_out(p.$$.fragment,S),transition_out(t.$$.fragment,S),u=!1},d(S){S&&detach(e),g&&g.d(),destroy_component(r),destroy_component(a),destroy_component(p),destroy_component(t)}}}function instance$1(c,e,n){let{currentDatasetId:r}=e,{selectedItem:i}=e,{models:o=[]}=e,{handleSaveItem:a}=e,{isLoading:d}=e,{canSaveCurrentItem:f}=e,{shouldSaveCurrentItem:h}=e,p=!1,s,t=[],l=[],u={};canSave.subscribe(v=>n(10,f=v));const g=async()=>{n(4,p=!0);let v={...i};itemObjects.subscribe(T=>{v.objects=T.reduce((w,S)=>(w[S.id]=S,w),{})}),itemMetas.subscribe(T=>{v.features=T.features}),await a(v),canSave.set(!1),n(4,p=!1)};function m(v){s=v,n(5,s)}function _(v){t=v,n(6,t)}function b(v){l=v,n(7,l)}function y(v){u=v,n(8,u)}return c.$$set=v=>{"currentDatasetId"in v&&n(0,r=v.currentDatasetId),"selectedItem"in v&&n(1,i=v.selectedItem),"models"in v&&n(2,o=v.models),"handleSaveItem"in v&&n(11,a=v.handleSaveItem),"isLoading"in v&&n(3,d=v.isLoading),"canSaveCurrentItem"in v&&n(10,f=v.canSaveCurrentItem),"shouldSaveCurrentItem"in v&&n(12,h=v.shouldSaveCurrentItem)},c.$$.update=()=>{var v;c.$$.dirty&2&&itemObjects.set(Object.values(i.objects||{}).flat().map(T=>({...T,displayControl:{hidden:!1}}))),c.$$.dirty&2&&itemMetas.set({features:i.features,itemFeatures:(v=Object.values(i.objects||{})[0])==null?void 0:v.features,views:i.views,id:i.id}),c.$$.dirty&2&&i&&(newShape.update(T=>({...T,status:"none"})),canSave.set(!1)),c.$$.dirty&4096&&h&&g().catch(T=>console.error(T))},itemBboxes.subscribe(v=>n(6,t=v)),itemMasks.subscribe(v=>n(7,l=v)),[r,i,o,d,p,s,t,l,u,g,f,a,h,m,_,b,y]}class ImageWorkspace extends SvelteComponent{constructor(e){super(),init(this,e,instance$1,create_fragment$1,safe_not_equal,{currentDatasetId:0,selectedItem:1,models:2,handleSaveItem:11,isLoading:3,canSaveCurrentItem:10,shouldSaveCurrentItem:12})}}function create_if_block_1(c){let e,n,r,i;function o(d){c[10](d)}let a={selectedItem:c[3],models:c[4],currentDatasetId:c[0].id,handleSaveItem:c[8],isLoading:c[5],shouldSaveCurrentItem:c[6]};return c[2]!==void 0&&(a.canSaveCurrentItem=c[2]),n=new ImageWorkspace({props:a}),binding_callbacks.push(()=>bind(n,"canSaveCurrentItem",o)),{c(){e=element("div"),create_component(n.$$.fragment),this.h()},l(d){e=claim_element(d,"DIV",{class:!0});var f=children(e);claim_component(n.$$.fragment,f),f.forEach(detach),this.h()},h(){attr(e,"class","pt-20 h-1 min-h-screen")},m(d,f){insert_hydration(d,e,f),mount_component(n,e,null),i=!0},p(d,f){const h={};f&8&&(h.selectedItem=d[3]),f&16&&(h.models=d[4]),f&1&&(h.currentDatasetId=d[0].id),f&32&&(h.isLoading=d[5]),f&64&&(h.shouldSaveCurrentItem=d[6]),!r&&f&4&&(r=!0,h.canSaveCurrentItem=d[2],add_flush_callback(()=>r=!1)),n.$set(h)},i(d){i||(transition_in(n.$$.fragment,d),i=!0)},o(d){transition_out(n.$$.fragment,d),i=!1},d(d){d&&detach(e),destroy_component(n)}}}function create_if_block(c){let e,n,r="Current item could not be loaded",i,o,a;return o=new PrimaryButton({props:{$$slots:{default:[create_default_slot]},$$scope:{ctx:c}}}),o.$on("click",c[11]),{c(){e=element("div"),n=element("p"),n.textContent=r,i=space(),create_component(o.$$.fragment),this.h()},l(d){e=claim_element(d,"DIV",{class:!0});var f=children(e);n=claim_element(f,"P",{"data-svelte-h":!0}),get_svelte_dataset(n)!=="svelte-7sd7em"&&(n.textContent=r),i=claim_space(f),claim_component(o.$$.fragment,f),f.forEach(detach),this.h()},h(){attr(e,"class","w-full pt-40 text-center flex flex-col gap-5 items-center")},m(d,f){insert_hydration(d,e,f),append_hydration(e,n),append_hydration(e,i),mount_component(o,e,null),a=!0},p(d,f){const h={};f&8192&&(h.$$scope={dirty:f,ctx:d}),o.$set(h)},i(d){a||(transition_in(o.$$.fragment,d),a=!0)},o(d){transition_out(o.$$.fragment,d),a=!1},d(d){d&&detach(e),destroy_component(o)}}}function create_default_slot(c){let e;return{c(){e=text("Back to dataset")},l(n){e=claim_text(n,"Back to dataset")},m(n,r){insert_hydration(n,e,r)},d(n){n&&detach(e)}}}function create_fragment(c){let e,n,r,i=c[3]&&c[0]&&create_if_block_1(c),o=!c[3]&&c[7]&&create_if_block(c);return{c(){i&&i.c(),e=space(),o&&o.c(),n=empty()},l(a){i&&i.l(a),e=claim_space(a),o&&o.l(a),n=empty()},m(a,d){i&&i.m(a,d),insert_hydration(a,e,d),o&&o.m(a,d),insert_hydration(a,n,d),r=!0},p(a,[d]){a[3]&&a[0]?i?(i.p(a,d),d&9&&transition_in(i,1)):(i=create_if_block_1(a),i.c(),transition_in(i,1),i.m(e.parentNode,e)):i&&(group_outros(),transition_out(i,1,1,()=>{i=null}),check_outros()),!a[3]&&a[7]?o?(o.p(a,d),d&136&&transition_in(o,1)):(o=create_if_block(a),o.c(),transition_in(o,1),o.m(n.parentNode,n)):o&&(group_outros(),transition_out(o,1,1,()=>{o=null}),check_outros())},i(a){r||(transition_in(i),transition_in(o),r=!0)},o(a){transition_out(i),transition_out(o),r=!1},d(a){a&&(detach(e),detach(n)),i&&i.d(a),o&&o.d(a)}}}function instance(c,e,n){let r,i,o,a,d,f=!1,h=!1,p=!1,s=!1;modelsStore$1.subscribe(m=>{n(4,o=m)}),saveCurrentItemStore.subscribe(m=>{n(2,h=m.canSave),n(6,p=m.shouldSave)});const t=(m,_)=>{getDatasetItem(m.id,encodeURIComponent(_)).then(b=>{(r==null?void 0:r.id)!==b.id&&n(3,r=b),Object.keys(b).length===0?n(7,s=!0):n(7,s=!1)}).then(()=>isLoadingNewItemStore.set(!1)).catch(b=>console.error(b))};page.subscribe(m=>{n(1,a=m.params.dataset),n(9,d=m.params.itemId)});async function l(m){await postDatasetItem(i.id,m),t(i,d),saveCurrentItemStore.update(_=>({..._,shouldSave:!1}))}function u(m){h=m,n(2,h)}const g=()=>goto(`/${a}/dataset`);return c.$$.update=()=>{c.$$.dirty&4&&saveCurrentItemStore.update(m=>({...m,canSave:h})),c.$$.dirty&515&&datasetsStore.subscribe(m=>{const _=m==null?void 0:m.find(b=>b.name===a);_&&d&&(n(0,i=_),isLoadingNewItemStore.set(!0),t(i,d))})},isLoadingNewItemStore.subscribe(m=>{n(5,f=m)}),[i,a,h,r,o,f,p,s,l,d,u,g]}class Page extends SvelteComponent{constructor(e){super(),init(this,e,instance,create_fragment,safe_not_equal,{})}}export{Page as component,_page as universal};
