var Yt=Object.defineProperty;var Xt=(s,e,t)=>e in s?Yt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var nt=(s,e,t)=>(Xt(s,typeof e!="symbol"?e+"":e,t),t);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,o as attr,i as insert_hydration,h as append_hydration,p as listen,j as set_data,n as noop,q as createEventDispatcher,ae as select_value,T as add_render_callback,af as select_option,w as destroy_each,aa as set_input_value,x as create_slot,A as update_slot_base,B as get_all_dirty_from_scope,C as get_slot_changes,k as component_subscribe,v as empty,D as compute_rest_props,y as assign,E as exclude_internal_props,R as set_attributes,P as action_destroyer,M as run_all,N as bubble,a9 as set_store_value,ag as set_data_maybe_contenteditable,G as onMount,I as binding_callbacks,S as add_flush_callback,K as tick,l as svg_element,m as claim_svg_element,H as set_style,ah as prevent_default,ac as setContext,ad as getContext,a7 as onDestroy,F as afterUpdate}from"../chunks/scheduler.Cq5UBZ1T.js";import{S as SvelteComponent,i as init,a as transition_in,t as transition_out,g as group_outros,c as check_outros,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.D__UofN6.js";import{p as page}from"../chunks/stores.BGtnTpCr.js";import{d as getItemEmbeddings,e as getDatasetItem,p as postDatasetItem}from"../chunks/api.BxNj-TAm.js";import{j as setCtx,k as getCtx,l as getAttrs,m as setCtx$1,n as getAttrs$1,o as getCtx$1,p as getCtx$2,r as setCtx$2,t as getAttrs$2,v as setCtx$3,w as getAttrs$3,x as getCtx$3,c as cn,y as createCommand,z as createGroup,A as getCtx$4,B as getState,C as generateId,V as VALUE_ATTR,D as isBrowser,I as ITEM_SELECTOR,E as isHTMLInputElement,F as getGroup,G as isUndefined,J as isHTMLElement,h as flyAndScale,K as commonjsGlobal,L as getDefaultExportFromCjs}from"../chunks/command.DPKxOpRB.js";import{c as createDispatcher,B as Button,P as PrimaryButton}from"../chunks/PrimaryButton.DzaTruCc.js";import{T as TooltipIconButton,R as Root$2,a as Trigger$1,b as Tooltip_content,C as ConfirmModal}from"../chunks/TooltipIconButton.LM-vI1aw.js";import{d as derived,w as writable,g as goto}from"../chunks/entry.CXPbVlpU.js";import{e as ensure_array_like,g as get_spread_update,a as get_spread_object,m as modelsStore$1,s as saveCurrentItemStore,d as datasetsStore,i as isLoadingNewItemStore}from"../chunks/datasetStores.BRxFwTQ-.js";import{I as Icon,L as Loader_2}from"../chunks/loader-2.BAms9Q12.js";import{a as Check,C as Checkbox,W as WarningModal}from"../chunks/checkbox.Beu8E6I9.js";class InternMap extends Map{constructor(e,t=keyof){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(const[n,r]of e)this.set(n,r)}get(e){return super.get(intern_get(this,e))}has(e){return super.has(intern_get(this,e))}set(e,t){return super.set(intern_set(this,e),t)}delete(e){return super.delete(intern_delete(this,e))}}function intern_get({_intern:s,_key:e},t){const n=e(t);return s.has(n)?s.get(n):t}function intern_set({_intern:s,_key:e},t){const n=e(t);return s.has(n)?s.get(n):(s.set(n,t),t)}function intern_delete({_intern:s,_key:e},t){const n=e(t);return s.has(n)&&(t=s.get(n),s.delete(n)),t}function keyof(s){return s!==null&&typeof s=="object"?s.valueOf():s}function initRange(s,e){switch(arguments.length){case 0:break;case 1:this.range(s);break;default:this.range(e).domain(s);break}return this}const implicit=Symbol("implicit");function ordinal(){var s=new InternMap,e=[],t=[],n=implicit;function r(o){let a=s.get(o);if(a===void 0){if(n!==implicit)return n;s.set(o,a=e.push(o)-1)}return t[a%t.length]}return r.domain=function(o){if(!arguments.length)return e.slice();e=[],s=new InternMap;for(const a of o)s.has(a)||s.set(a,e.push(a)-1);return r},r.range=function(o){return arguments.length?(t=Array.from(o),r):t.slice()},r.unknown=function(o){return arguments.length?(n=o,r):n},r.copy=function(){return ordinal(e,t).unknown(n)},initRange.apply(r,arguments),r}function colors(s){for(var e=s.length/6|0,t=new Array(e),n=0;n<e;)t[n]="#"+s.slice(n*6,++n*6);return t}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(s){return ordinal(schemeSet3).domain(s)}function isValidURL(s){try{return!!new URL(s)}catch{return!1}}function get_each_context$8(s,e,t){const n=s.slice();return n[7]=e[t],n}function create_else_block$k(s){let e,t;return{c(){e=element("p"),t=text(s[2]),this.h()},l(n){e=claim_element(n,"P",{class:!0});var r=children(e);t=claim_text(r,s[2]),r.forEach(detach),this.h()},h(){attr(e,"class","pb-1 italic")},m(n,r){insert_hydration(n,e,r),append_hydration(e,t)},p(n,r){r&4&&set_data(t,n[2])},d(n){n&&detach(e)}}}function create_if_block$E(s){let e,t,n,r=ensure_array_like(s[3]),o=[];for(let a=0;a<r.length;a+=1)o[a]=create_each_block$8(get_each_context$8(s,r,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 u=children(e);for(let d=0;d<o.length;d+=1)o[d].l(u);u.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"),s[0]===void 0&&add_render_callback(()=>s[5].call(e))},m(a,u){insert_hydration(a,e,u);for(let d=0;d<o.length;d+=1)o[d]&&o[d].m(e,null);select_option(e,s[0],!0),t||(n=listen(e,"change",s[5]),t=!0)},p(a,u){if(u&8){r=ensure_array_like(a[3]);let d;for(d=0;d<r.length;d+=1){const h=get_each_context$8(a,r,d);o[d]?o[d].p(h,u):(o[d]=create_each_block$8(h),o[d].c(),o[d].m(e,null))}for(;d<o.length;d+=1)o[d].d(1);o.length=r.length}u&9&&select_option(e,a[0])},d(a){a&&detach(e),destroy_each(o,a),t=!1,n()}}}function create_each_block$8(s){let e,t=s[7]+"",n,r,o;return{c(){e=element("option"),n=text(t),r=space(),this.h()},l(a){e=claim_element(a,"OPTION",{});var u=children(e);n=claim_text(u,t),r=claim_space(u),u.forEach(detach),this.h()},h(){e.__value=o=s[7],set_input_value(e,e.__value)},m(a,u){insert_hydration(a,e,u),append_hydration(e,n),append_hydration(e,r)},p(a,u){u&8&&t!==(t=a[7]+"")&&set_data(n,t),u&8&&o!==(o=a[7])&&(e.__value=o,set_input_value(e,e.__value))},d(a){a&&detach(e)}}}function create_fragment$1g(s){let e,t,n,r,o,a,u,d,h,p,l="Ok",i,c;function f(_,b){return _[3]?create_if_block$E:create_else_block$k}let g=f(s),m=g(s);return{c(){e=element("div"),t=element("div"),n=space(),r=element("div"),o=element("div"),a=element("p"),u=text(s[1]),d=space(),m.c(),h=space(),p=element("button"),p.textContent=l,this.h()},l(_){e=claim_element(_,"DIV",{class:!0});var b=children(e);t=claim_element(b,"DIV",{class:!0}),children(t).forEach(detach),n=claim_space(b),r=claim_element(b,"DIV",{class:!0});var v=children(r);o=claim_element(v,"DIV",{class:!0});var T=children(o);a=claim_element(T,"P",{class:!0});var y=children(a);u=claim_text(y,s[1]),y.forEach(detach),d=claim_space(T),m.l(T),h=claim_space(T),p=claim_element(T,"BUTTON",{type:!0,class:!0,"data-svelte-h":!0}),get_svelte_dataset(p)!=="svelte-fnm6uk"&&(p.textContent=l),T.forEach(detach),v.forEach(detach),b.forEach(detach),this.h()},h(){attr(t,"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(r,"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,t),append_hydration(e,n),append_hydration(e,r),append_hydration(r,o),append_hydration(o,a),append_hydration(a,u),append_hydration(o,d),m.m(o,null),append_hydration(o,h),append_hydration(o,p),i||(c=listen(p,"click",s[4]),i=!0)},p(_,[b]){b&2&&set_data(u,_[1]),g===(g=f(_))&&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(),i=!1,c()}}}function instance$1j(s,e,t){let{message:n}=e,{ifNoChoices:r}=e,{choices:o}=e,{selected:a}=e;const u=createEventDispatcher();function d(){u("confirm")}function h(){a=select_value(this),t(0,a),t(3,o)}return s.$$set=p=>{"message"in p&&t(1,n=p.message),"ifNoChoices"in p&&t(2,r=p.ifNoChoices),"choices"in p&&t(3,o=p.choices),"selected"in p&&t(0,a=p.selected)},[a,n,r,o,d,h]}class SelectModal extends SvelteComponent{constructor(e){super(),init(this,e,instance$1j,create_fragment$1g,safe_not_equal,{message:1,ifNoChoices:2,choices:3,selected:0})}}const get_default_slot_changes$f=s=>({ids:s&1}),get_default_slot_context$f=s=>({ids:s[0]});function create_fragment$1f(s){let e;const t=s[14].default,n=create_slot(t,s,s[13],get_default_slot_context$f);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,[o]){n&&n.p&&(!e||o&8193)&&update_slot_base(n,t,r,r[13],e?get_slot_changes(t,r[13],o,get_default_slot_changes$f):get_all_dirty_from_scope(r[13]),get_default_slot_context$f)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function instance$1i(s,e,t){let n,{$$slots:r={},$$scope:o}=e,{positioning:a=void 0}=e,{arrowSize:u=void 0}=e,{disableFocusTrap:d=void 0}=e,{closeOnEscape:h=void 0}=e,{closeOnOutsideClick:p=void 0}=e,{preventScroll:l=void 0}=e,{portal:i=void 0}=e,{open:c=void 0}=e,{onOpenChange:f=void 0}=e,{openFocus:g=void 0}=e,{closeFocus:m=void 0}=e;const{updateOption:_,states:{open:b},ids:v}=setCtx({positioning:a,arrowSize:u,disableFocusTrap:d,closeOnEscape:h,closeOnOutsideClick:p,preventScroll:l,portal:i,defaultOpen:c,openFocus:g,closeFocus:m,onOpenChange:({next:y})=>(c!==y&&(f==null||f(y),t(2,c=y)),y)}),T=derived([v.content,v.trigger],([y,S])=>({content:y,trigger:S}));return component_subscribe(s,T,y=>t(0,n=y)),s.$$set=y=>{"positioning"in y&&t(3,a=y.positioning),"arrowSize"in y&&t(4,u=y.arrowSize),"disableFocusTrap"in y&&t(5,d=y.disableFocusTrap),"closeOnEscape"in y&&t(6,h=y.closeOnEscape),"closeOnOutsideClick"in y&&t(7,p=y.closeOnOutsideClick),"preventScroll"in y&&t(8,l=y.preventScroll),"portal"in y&&t(9,i=y.portal),"open"in y&&t(2,c=y.open),"onOpenChange"in y&&t(10,f=y.onOpenChange),"openFocus"in y&&t(11,g=y.openFocus),"closeFocus"in y&&t(12,m=y.closeFocus),"$$scope"in y&&t(13,o=y.$$scope)},s.$$.update=()=>{s.$$.dirty&4&&c!==void 0&&b.set(c),s.$$.dirty&8&&_("positioning",a),s.$$.dirty&16&&_("arrowSize",u),s.$$.dirty&32&&_("disableFocusTrap",d),s.$$.dirty&64&&_("closeOnEscape",h),s.$$.dirty&128&&_("closeOnOutsideClick",p),s.$$.dirty&256&&_("preventScroll",l),s.$$.dirty&512&&_("portal",i),s.$$.dirty&2048&&_("openFocus",g),s.$$.dirty&4096&&_("closeFocus",m)},[n,T,c,a,u,d,h,p,l,i,f,g,m,o,r]}class Popover extends SvelteComponent{constructor(e){super(),init(this,e,instance$1i,create_fragment$1f,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=s=>({builder:s&128}),get_default_slot_context_5=s=>({builder:s[7],attrs:s[11]}),get_default_slot_changes_4=s=>({builder:s&128}),get_default_slot_context_4=s=>({builder:s[7],attrs:s[11]}),get_default_slot_changes_3=s=>({builder:s&128}),get_default_slot_context_3=s=>({builder:s[7],attrs:s[11]}),get_default_slot_changes_2=s=>({builder:s&128}),get_default_slot_context_2=s=>({builder:s[7],attrs:s[11]}),get_default_slot_changes_1$a=s=>({builder:s&128}),get_default_slot_context_1$a=s=>({builder:s[7],attrs:s[11]}),get_default_slot_changes$e=s=>({builder:s&128}),get_default_slot_context$e=s=>({builder:s[7],attrs:s[11]});function create_if_block_5$1(s){let e,t,n,r;const o=s[16].default,a=create_slot(o,s,s[15],get_default_slot_context_5);let u=[s[7],s[12],s[11]],d={};for(let h=0;h<u.length;h+=1)d=assign(d,u[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,d)},m(h,p){insert_hydration(h,e,p),a&&a.m(e,null),t=!0,n||(r=action_destroyer(s[7].action(e)),n=!0)},p(h,p){a&&a.p&&(!t||p&32896)&&update_slot_base(a,o,h,h[15],t?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,d=get_spread_update(u,[p&128&&h[7],p&4096&&h[12],h[11]]))},i(h){t||(transition_in(a,h),t=!0)},o(h){transition_out(a,h),t=!1},d(h){h&&detach(e),a&&a.d(h),n=!1,r()}}}function create_if_block_4$4(s){let e,t,n,r,o;const a=s[16].default,u=create_slot(a,s,s[15],get_default_slot_context_4);let d=[s[7],s[12],s[11]],h={};for(let p=0;p<d.length;p+=1)h=assign(h,d[p]);return{c(){e=element("div"),u&&u.c(),this.h()},l(p){e=claim_element(p,"DIV",{});var l=children(e);u&&u.l(l),l.forEach(detach),this.h()},h(){set_attributes(e,h)},m(p,l){insert_hydration(p,e,l),u&&u.m(e,null),n=!0,r||(o=action_destroyer(s[7].action(e)),r=!0)},p(p,l){s=p,u&&u.p&&(!n||l&32896)&&update_slot_base(u,a,s,s[15],n?get_slot_changes(a,s[15],l,get_default_slot_changes_4):get_all_dirty_from_scope(s[15]),get_default_slot_context_4),set_attributes(e,h=get_spread_update(d,[l&128&&s[7],l&4096&&s[12],s[11]]))},i(p){n||(transition_in(u,p),t&&t.end(1),n=!0)},o(p){transition_out(u,p),p&&(t=create_out_transition(e,s[4],s[5])),n=!1},d(p){p&&detach(e),u&&u.d(p),p&&t&&t.end(),r=!1,o()}}}function create_if_block_3$7(s){let e,t,n,r,o;const a=s[16].default,u=create_slot(a,s,s[15],get_default_slot_context_3);let d=[s[7],s[12],s[11]],h={};for(let p=0;p<d.length;p+=1)h=assign(h,d[p]);return{c(){e=element("div"),u&&u.c(),this.h()},l(p){e=claim_element(p,"DIV",{});var l=children(e);u&&u.l(l),l.forEach(detach),this.h()},h(){set_attributes(e,h)},m(p,l){insert_hydration(p,e,l),u&&u.m(e,null),n=!0,r||(o=action_destroyer(s[7].action(e)),r=!0)},p(p,l){s=p,u&&u.p&&(!n||l&32896)&&update_slot_base(u,a,s,s[15],n?get_slot_changes(a,s[15],l,get_default_slot_changes_3):get_all_dirty_from_scope(s[15]),get_default_slot_context_3),set_attributes(e,h=get_spread_update(d,[l&128&&s[7],l&4096&&s[12],s[11]]))},i(p){n||(transition_in(u,p),p&&(t||add_render_callback(()=>{t=create_in_transition(e,s[2],s[3]),t.start()})),n=!0)},o(p){transition_out(u,p),n=!1},d(p){p&&detach(e),u&&u.d(p),r=!1,o()}}}function create_if_block_2$9(s){let e,t,n,r,o,a;const u=s[16].default,d=create_slot(u,s,s[15],get_default_slot_context_2);let h=[s[7],s[12],s[11]],p={};for(let l=0;l<h.length;l+=1)p=assign(p,h[l]);return{c(){e=element("div"),d&&d.c(),this.h()},l(l){e=claim_element(l,"DIV",{});var i=children(e);d&&d.l(i),i.forEach(detach),this.h()},h(){set_attributes(e,p)},m(l,i){insert_hydration(l,e,i),d&&d.m(e,null),r=!0,o||(a=action_destroyer(s[7].action(e)),o=!0)},p(l,i){s=l,d&&d.p&&(!r||i&32896)&&update_slot_base(d,u,s,s[15],r?get_slot_changes(u,s[15],i,get_default_slot_changes_2):get_all_dirty_from_scope(s[15]),get_default_slot_context_2),set_attributes(e,p=get_spread_update(h,[i&128&&s[7],i&4096&&s[12],s[11]]))},i(l){r||(transition_in(d,l),l&&add_render_callback(()=>{r&&(n&&n.end(1),t=create_in_transition(e,s[2],s[3]),t.start())}),r=!0)},o(l){transition_out(d,l),t&&t.invalidate(),l&&(n=create_out_transition(e,s[4],s[5])),r=!1},d(l){l&&detach(e),d&&d.d(l),l&&n&&n.end(),o=!1,a()}}}function create_if_block_1$g(s){let e,t,n,r,o;const a=s[16].default,u=create_slot(a,s,s[15],get_default_slot_context_1$a);let d=[s[7],s[12],s[11]],h={};for(let p=0;p<d.length;p+=1)h=assign(h,d[p]);return{c(){e=element("div"),u&&u.c(),this.h()},l(p){e=claim_element(p,"DIV",{});var l=children(e);u&&u.l(l),l.forEach(detach),this.h()},h(){set_attributes(e,h)},m(p,l){insert_hydration(p,e,l),u&&u.m(e,null),n=!0,r||(o=action_destroyer(s[7].action(e)),r=!0)},p(p,l){s=p,u&&u.p&&(!n||l&32896)&&update_slot_base(u,a,s,s[15],n?get_slot_changes(a,s[15],l,get_default_slot_changes_1$a):get_all_dirty_from_scope(s[15]),get_default_slot_context_1$a),set_attributes(e,h=get_spread_update(d,[l&128&&s[7],l&4096&&s[12],s[11]]))},i(p){n||(transition_in(u,p),p&&add_render_callback(()=>{n&&(t||(t=create_bidirectional_transition(e,s[0],s[1],!0)),t.run(1))}),n=!0)},o(p){transition_out(u,p),p&&(t||(t=create_bidirectional_transition(e,s[0],s[1],!1)),t.run(0)),n=!1},d(p){p&&detach(e),u&&u.d(p),p&&t&&t.end(),r=!1,o()}}}function create_if_block$D(s){let e;const t=s[16].default,n=create_slot(t,s,s[15],get_default_slot_context$e);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&32896)&&update_slot_base(n,t,r,r[15],e?get_slot_changes(t,r[15],o,get_default_slot_changes$e):get_all_dirty_from_scope(r[15]),get_default_slot_context$e)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$1e(s){let e,t,n,r;const o=[create_if_block$D,create_if_block_1$g,create_if_block_2$9,create_if_block_3$7,create_if_block_4$4,create_if_block_5$1],a=[];function u(d,h){return d[6]&&d[8]?0:d[0]&&d[8]?1:d[2]&&d[4]&&d[8]?2:d[2]&&d[8]?3:d[4]&&d[8]?4:d[8]?5:-1}return~(e=u(s))&&(t=a[e]=o[e](s)),{c(){t&&t.c(),n=empty()},l(d){t&&t.l(d),n=empty()},m(d,h){~e&&a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,[h]){let p=e;e=u(d),e===p?~e&&a[e].p(d,h):(t&&(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros()),~e?(t=a[e],t?t.p(d,h):(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n)):t=null)},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),~e&&a[e].d(d)}}}function instance$1h(s,e,t){let n;const r=["transition","transitionConfig","inTransition","inTransitionConfig","outTransition","outTransitionConfig","asChild","id"];let o=compute_rest_props(e,r),a,u,{$$slots:d={},$$scope:h}=e,{transition:p=void 0}=e,{transitionConfig:l=void 0}=e,{inTransition:i=void 0}=e,{inTransitionConfig:c=void 0}=e,{outTransition:f=void 0}=e,{outTransitionConfig:g=void 0}=e,{asChild:m=!1}=e,{id:_=void 0}=e;const{elements:{content:b},states:{open:v},ids:T}=getCtx();component_subscribe(s,b,S=>t(14,a=S)),component_subscribe(s,v,S=>t(8,u=S));const y=getAttrs("content");return s.$$set=S=>{e=assign(assign({},e),exclude_internal_props(S)),t(12,o=compute_rest_props(e,r)),"transition"in S&&t(0,p=S.transition),"transitionConfig"in S&&t(1,l=S.transitionConfig),"inTransition"in S&&t(2,i=S.inTransition),"inTransitionConfig"in S&&t(3,c=S.inTransitionConfig),"outTransition"in S&&t(4,f=S.outTransition),"outTransitionConfig"in S&&t(5,g=S.outTransitionConfig),"asChild"in S&&t(6,m=S.asChild),"id"in S&&t(13,_=S.id),"$$scope"in S&&t(15,h=S.$$scope)},s.$$.update=()=>{s.$$.dirty&8192&&_&&T.content.set(_),s.$$.dirty&16384&&t(7,n=a)},[p,l,i,c,f,g,m,n,u,b,v,y,o,_,a,h,d]}class PopoverContent extends SvelteComponent{constructor(e){super(),init(this,e,instance$1h,create_fragment$1e,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$9=s=>({builder:s&2}),get_default_slot_context_1$9=s=>({builder:s[1],attrs:s[4]}),get_default_slot_changes$d=s=>({builder:s&2}),get_default_slot_context$d=s=>({builder:s[1],attrs:s[4]});function create_else_block$j(s){let e,t,n,r;const o=s[9].default,a=create_slot(o,s,s[8],get_default_slot_context_1$9);let u=[s[1],{type:"button"},s[5],s[4]],d={};for(let h=0;h<u.length;h+=1)d=assign(d,u[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,d)},m(h,p){insert_hydration(h,e,p),a&&a.m(e,null),e.autofocus&&e.focus(),t=!0,n||(r=[action_destroyer(s[1].action(e)),listen(e,"m-click",s[3]),listen(e,"m-keydown",s[3])],n=!0)},p(h,p){a&&a.p&&(!t||p&258)&&update_slot_base(a,o,h,h[8],t?get_slot_changes(o,h[8],p,get_default_slot_changes_1$9):get_all_dirty_from_scope(h[8]),get_default_slot_context_1$9),set_attributes(e,d=get_spread_update(u,[p&2&&h[1],{type:"button"},p&32&&h[5],h[4]]))},i(h){t||(transition_in(a,h),t=!0)},o(h){transition_out(a,h),t=!1},d(h){h&&detach(e),a&&a.d(h),n=!1,run_all(r)}}}function create_if_block$C(s){let e;const t=s[9].default,n=create_slot(t,s,s[8],get_default_slot_context$d);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&258)&&update_slot_base(n,t,r,r[8],e?get_slot_changes(t,r[8],o,get_default_slot_changes$d):get_all_dirty_from_scope(r[8]),get_default_slot_context$d)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$1d(s){let e,t,n,r;const o=[create_if_block$C,create_else_block$j],a=[];function u(d,h){return d[0]?0:1}return e=u(s),t=a[e]=o[e](s),{c(){t.c(),n=empty()},l(d){t.l(d),n=empty()},m(d,h){a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,[h]){let p=e;e=u(d),e===p?a[e].p(d,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),t=a[e],t?t.p(d,h):(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n))},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),a[e].d(d)}}}function instance$1g(s,e,t){let n;const r=["asChild","id"];let o=compute_rest_props(e,r),a,{$$slots:u={},$$scope:d}=e,{asChild:h=!1}=e,{id:p=void 0}=e;const{elements:{trigger:l},ids:i}=getCtx();component_subscribe(s,l,g=>t(7,a=g));const c=createDispatcher(),f=getAttrs("trigger");return s.$$set=g=>{e=assign(assign({},e),exclude_internal_props(g)),t(5,o=compute_rest_props(e,r)),"asChild"in g&&t(0,h=g.asChild),"id"in g&&t(6,p=g.id),"$$scope"in g&&t(8,d=g.$$scope)},s.$$.update=()=>{s.$$.dirty&64&&p&&i.trigger.set(p),s.$$.dirty&128&&t(1,n=a)},[h,n,l,c,f,o,p,a,d,u]}class PopoverTrigger extends SvelteComponent{constructor(e){super(),init(this,e,instance$1g,create_fragment$1d,safe_not_equal,{asChild:0,id:6})}}const get_default_slot_changes_1$8=s=>({builder:s&2,ticks:s&4}),get_default_slot_context_1$8=s=>({builder:s[1],attrs:s[5],ticks:s[2]}),get_default_slot_changes$c=s=>({builder:s&2,ticks:s&4}),get_default_slot_context$c=s=>({builder:s[1],attrs:s[5],ticks:s[2]});function create_else_block$i(s){let e,t,n,r;const o=s[16].default,a=create_slot(o,s,s[15],get_default_slot_context_1$8);let u=[s[1],s[6],s[5]],d={};for(let h=0;h<u.length;h+=1)d=assign(d,u[h]);return{c(){e=element("span"),a&&a.c(),this.h()},l(h){e=claim_element(h,"SPAN",{});var p=children(e);a&&a.l(p),p.forEach(detach),this.h()},h(){set_attributes(e,d)},m(h,p){insert_hydration(h,e,p),a&&a.m(e,null),t=!0,n||(r=action_destroyer(s[1].action(e)),n=!0)},p(h,p){a&&a.p&&(!t||p&32774)&&update_slot_base(a,o,h,h[15],t?get_slot_changes(o,h[15],p,get_default_slot_changes_1$8):get_all_dirty_from_scope(h[15]),get_default_slot_context_1$8),set_attributes(e,d=get_spread_update(u,[p&2&&h[1],p&64&&h[6],h[5]]))},i(h){t||(transition_in(a,h),t=!0)},o(h){transition_out(a,h),t=!1},d(h){h&&detach(e),a&&a.d(h),n=!1,r()}}}function create_if_block$B(s){let e;const t=s[16].default,n=create_slot(t,s,s[15],get_default_slot_context$c);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&32774)&&update_slot_base(n,t,r,r[15],e?get_slot_changes(t,r[15],o,get_default_slot_changes$c):get_all_dirty_from_scope(r[15]),get_default_slot_context$c)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$1c(s){let e,t,n,r;const o=[create_if_block$B,create_else_block$i],a=[];function u(d,h){return d[0]?0:1}return e=u(s),t=a[e]=o[e](s),{c(){t.c(),n=empty()},l(d){t.l(d),n=empty()},m(d,h){a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,[h]){let p=e;e=u(d),e===p?a[e].p(d,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),t=a[e],t?t.p(d,h):(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n))},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),a[e].d(d)}}}function instance$1f(s,e,t){let n;const r=["disabled","min","max","step","orientation","value","onValueChange","asChild"];let o=compute_rest_props(e,r),a,u,{$$slots:d={},$$scope:h}=e,{disabled:p=void 0}=e,{min:l=void 0}=e,{max:i=void 0}=e,{step:c=void 0}=e,{orientation:f=void 0}=e,{value:g=void 0}=e,{onValueChange:m=void 0}=e,{asChild:_=!1}=e;const{elements:{root:b},states:{value:v,ticks:T},updateOption:y}=setCtx$1({disabled:p,min:l,max:i,step:c,orientation:f,defaultValue:g,onValueChange:({next:w})=>(g!==w&&(m==null||m(w),t(7,g=w)),w)});component_subscribe(s,b,w=>t(14,a=w)),component_subscribe(s,T,w=>t(2,u=w));const S=getAttrs$1("root");return s.$$set=w=>{e=assign(assign({},e),exclude_internal_props(w)),t(6,o=compute_rest_props(e,r)),"disabled"in w&&t(8,p=w.disabled),"min"in w&&t(9,l=w.min),"max"in w&&t(10,i=w.max),"step"in w&&t(11,c=w.step),"orientation"in w&&t(12,f=w.orientation),"value"in w&&t(7,g=w.value),"onValueChange"in w&&t(13,m=w.onValueChange),"asChild"in w&&t(0,_=w.asChild),"$$scope"in w&&t(15,h=w.$$scope)},s.$$.update=()=>{s.$$.dirty&128&&g!==void 0&&v.set(g),s.$$.dirty&256&&y("disabled",p),s.$$.dirty&512&&y("min",l),s.$$.dirty&1024&&y("max",i),s.$$.dirty&2048&&y("step",c),s.$$.dirty&4096&&y("orientation",f),s.$$.dirty&16384&&t(1,n=a)},[_,n,u,b,T,S,o,g,p,l,i,c,f,m,a,h,d]}class Slider extends SvelteComponent{constructor(e){super(),init(this,e,instance$1f,create_fragment$1c,safe_not_equal,{disabled:8,min:9,max:10,step:11,orientation:12,value:7,onValueChange:13,asChild:0})}}const get_default_slot_changes$b=s=>({builder:s&2}),get_default_slot_context$b=s=>({builder:s[1],attrs:s[3]});function create_else_block$h(s){let e,t,n,r=[s[1],s[4],s[3]],o={};for(let a=0;a<r.length;a+=1)o=assign(o,r[a]);return{c(){e=element("span"),this.h()},l(a){e=claim_element(a,"SPAN",{}),children(e).forEach(detach),this.h()},h(){set_attributes(e,o)},m(a,u){insert_hydration(a,e,u),t||(n=action_destroyer(s[1].action(e)),t=!0)},p(a,u){set_attributes(e,o=get_spread_update(r,[u&2&&a[1],u&16&&a[4],a[3]]))},i:noop,o:noop,d(a){a&&detach(e),t=!1,n()}}}function create_if_block$A(s){let e;const t=s[7].default,n=create_slot(t,s,s[6],get_default_slot_context$b);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&66)&&update_slot_base(n,t,r,r[6],e?get_slot_changes(t,r[6],o,get_default_slot_changes$b):get_all_dirty_from_scope(r[6]),get_default_slot_context$b)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$1b(s){let e,t,n,r;const o=[create_if_block$A,create_else_block$h],a=[];function u(d,h){return d[0]?0:1}return e=u(s),t=a[e]=o[e](s),{c(){t.c(),n=empty()},l(d){t.l(d),n=empty()},m(d,h){a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,[h]){let p=e;e=u(d),e===p?a[e].p(d,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),t=a[e],t?t.p(d,h):(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n))},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),a[e].d(d)}}}function instance$1e(s,e,t){let n;const r=["asChild"];let o=compute_rest_props(e,r),a,{$$slots:u={},$$scope:d}=e,{asChild:h=!1}=e;const{elements:{range:p}}=getCtx$1();component_subscribe(s,p,i=>t(5,a=i));const l=getAttrs$1("range");return s.$$set=i=>{e=assign(assign({},e),exclude_internal_props(i)),t(4,o=compute_rest_props(e,r)),"asChild"in i&&t(0,h=i.asChild),"$$scope"in i&&t(6,d=i.$$scope)},s.$$.update=()=>{s.$$.dirty&32&&t(1,n=a)},[h,n,p,l,o,a,d,u]}class SliderRange extends SvelteComponent{constructor(e){super(),init(this,e,instance$1e,create_fragment$1b,safe_not_equal,{asChild:0})}}function create_fragment$1a(s){let e,t,n,r=[s[1],{name:s[2]},{disabled:s[3]},{required:s[4]},{value:s[0]},s[10]],o={};for(let a=0;a<r.length;a+=1)o=assign(o,r[a]);return{c(){e=element("input"),this.h()},l(a){e=claim_element(a,"INPUT",{name:!0}),this.h()},h(){set_attributes(e,o)},m(a,u){insert_hydration(a,e,u),"value"in o&&(e.value=o.value),e.autofocus&&e.focus(),t||(n=action_destroyer(s[1].action(e)),t=!0)},p(a,[u]){set_attributes(e,o=get_spread_update(r,[u&2&&a[1],u&4&&{name:a[2]},u&8&&{disabled:a[3]},u&16&&{required:a[4]},u&1&&e.value!==a[0]&&{value:a[0]},u&1024&&a[10]])),"value"in o&&(e.value=o.value)},i:noop,o:noop,d(a){a&&detach(e),t=!1,n()}}}function instance$1d(s,e,t){let n;const r=[];let o=compute_rest_props(e,r),a,u,d,h,p;const{elements:{input:l},options:{value:i,name:c,disabled:f,required:g}}=getCtx$2();return component_subscribe(s,l,m=>t(1,u=m)),component_subscribe(s,i,m=>t(11,a=m)),component_subscribe(s,c,m=>t(2,d=m)),component_subscribe(s,f,m=>t(3,h=m)),component_subscribe(s,g,m=>t(4,p=m)),s.$$set=m=>{e=assign(assign({},e),exclude_internal_props(m)),t(10,o=compute_rest_props(e,r))},s.$$.update=()=>{s.$$.dirty&2048&&t(0,n=a===void 0||a===""?"on":a)},[n,u,d,h,p,l,i,c,f,g,o,a]}class SwitchInput extends SvelteComponent{constructor(e){super(),init(this,e,instance$1d,create_fragment$1a,safe_not_equal,{})}}const get_default_slot_changes_1$7=s=>({builder:s&16,attrs:s&8}),get_default_slot_context_1$7=s=>({builder:s[4],attrs:s[3]}),get_default_slot_changes$a=s=>({builder:s&16,attrs:s&8}),get_default_slot_context$a=s=>({builder:s[4],attrs:s[3]});function create_else_block$g(s){let e,t,n,r;const o=s[16].default,a=create_slot(o,s,s[15],get_default_slot_context_1$7);let u=[s[4],{type:"button"},s[7],s[3]],d={};for(let h=0;h<u.length;h+=1)d=assign(d,u[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,d)},m(h,p){insert_hydration(h,e,p),a&&a.m(e,null),e.autofocus&&e.focus(),t=!0,n||(r=[action_destroyer(s[4].action(e)),listen(e,"m-click",s[6]),listen(e,"m-keydown",s[6])],n=!0)},p(h,p){a&&a.p&&(!t||p&32792)&&update_slot_base(a,o,h,h[15],t?get_slot_changes(o,h[15],p,get_default_slot_changes_1$7):get_all_dirty_from_scope(h[15]),get_default_slot_context_1$7),set_attributes(e,d=get_spread_update(u,[p&16&&h[4],{type:"button"},p&128&&h[7],p&8&&h[3]]))},i(h){t||(transition_in(a,h),t=!0)},o(h){transition_out(a,h),t=!1},d(h){h&&detach(e),a&&a.d(h),n=!1,run_all(r)}}}function create_if_block_1$f(s){let e;const t=s[16].default,n=create_slot(t,s,s[15],get_default_slot_context$a);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&32792)&&update_slot_base(n,t,r,r[15],e?get_slot_changes(t,r[15],o,get_default_slot_changes$a):get_all_dirty_from_scope(r[15]),get_default_slot_context$a)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_if_block$z(s){let e,t;const n=[s[2]];let r={};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new SwitchInput({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,a){const u=a&4?get_spread_update(n,[get_spread_object(o[2])]):{};e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function create_fragment$19(s){let e,t,n,r,o;const a=[create_if_block_1$f,create_else_block$g],u=[];function d(p,l){return p[1]?0:1}e=d(s),t=u[e]=a[e](s);let h=s[0]&&create_if_block$z(s);return{c(){t.c(),n=space(),h&&h.c(),r=empty()},l(p){t.l(p),n=claim_space(p),h&&h.l(p),r=empty()},m(p,l){u[e].m(p,l),insert_hydration(p,n,l),h&&h.m(p,l),insert_hydration(p,r,l),o=!0},p(p,[l]){let i=e;e=d(p),e===i?u[e].p(p,l):(group_outros(),transition_out(u[i],1,1,()=>{u[i]=null}),check_outros(),t=u[e],t?t.p(p,l):(t=u[e]=a[e](p),t.c()),transition_in(t,1),t.m(n.parentNode,n)),p[0]?h?(h.p(p,l),l&1&&transition_in(h,1)):(h=create_if_block$z(p),h.c(),transition_in(h,1),h.m(r.parentNode,r)):h&&(group_outros(),transition_out(h,1,1,()=>{h=null}),check_outros())},i(p){o||(transition_in(t),transition_in(h),o=!0)},o(p){transition_out(t),transition_out(h),o=!1},d(p){p&&(detach(n),detach(r)),u[e].d(p),h&&h.d(p)}}}function instance$1c(s,e,t){let n,r;const o=["checked","onCheckedChange","disabled","name","value","includeInput","required","asChild","inputAttrs"];let a=compute_rest_props(e,o),u,{$$slots:d={},$$scope:h}=e,{checked:p=void 0}=e,{onCheckedChange:l=void 0}=e,{disabled:i=void 0}=e,{name:c=void 0}=e,{value:f=void 0}=e,{includeInput:g=!0}=e,{required:m=void 0}=e,{asChild:_=!1}=e,{inputAttrs:b=void 0}=e;const{elements:{root:v},states:{checked:T},updateOption:y}=setCtx$2({disabled:i,name:c,value:f,required:m,defaultChecked:p,onCheckedChange:({next:w})=>(p!==w&&(l==null||l(w),t(8,p=w)),w)});component_subscribe(s,v,w=>t(14,u=w));const S=createDispatcher();return s.$$set=w=>{e=assign(assign({},e),exclude_internal_props(w)),t(7,a=compute_rest_props(e,o)),"checked"in w&&t(8,p=w.checked),"onCheckedChange"in w&&t(9,l=w.onCheckedChange),"disabled"in w&&t(10,i=w.disabled),"name"in w&&t(11,c=w.name),"value"in w&&t(12,f=w.value),"includeInput"in w&&t(0,g=w.includeInput),"required"in w&&t(13,m=w.required),"asChild"in w&&t(1,_=w.asChild),"inputAttrs"in w&&t(2,b=w.inputAttrs),"$$scope"in w&&t(15,h=w.$$scope)},s.$$.update=()=>{s.$$.dirty&256&&p!==void 0&&T.set(p),s.$$.dirty&1024&&y("disabled",i),s.$$.dirty&2048&&y("name",c),s.$$.dirty&4096&&y("value",f),s.$$.dirty&8192&&y("required",m),s.$$.dirty&16384&&t(4,n=u),s.$$.dirty&256&&t(3,r={...getAttrs$2("root"),"data-checked":p?"":void 0})},[g,_,b,r,n,v,S,a,p,l,i,c,f,m,u,h,d]}class Switch extends SvelteComponent{constructor(e){super(),init(this,e,instance$1c,create_fragment$19,safe_not_equal,{checked:8,onCheckedChange:9,disabled:10,name:11,value:12,includeInput:0,required:13,asChild:1,inputAttrs:2})}}const get_default_slot_changes$9=s=>({checked:s&2,attrs:s&4}),get_default_slot_context$9=s=>({checked:s[1],attrs:s[2]});function create_else_block$f(s){let e,t=[s[4],s[2]],n={};for(let r=0;r<t.length;r+=1)n=assign(n,t[r]);return{c(){e=element("span"),this.h()},l(r){e=claim_element(r,"SPAN",{}),children(e).forEach(detach),this.h()},h(){set_attributes(e,n)},m(r,o){insert_hydration(r,e,o)},p(r,o){set_attributes(e,n=get_spread_update(t,[o&16&&r[4],o&4&&r[2]]))},i:noop,o:noop,d(r){r&&detach(e)}}}function create_if_block$y(s){let e;const t=s[6].default,n=create_slot(t,s,s[5],get_default_slot_context$9);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&38)&&update_slot_base(n,t,r,r[5],e?get_slot_changes(t,r[5],o,get_default_slot_changes$9):get_all_dirty_from_scope(r[5]),get_default_slot_context$9)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$18(s){let e,t,n,r;const o=[create_if_block$y,create_else_block$f],a=[];function u(d,h){return d[0]?0:1}return e=u(s),t=a[e]=o[e](s),{c(){t.c(),n=empty()},l(d){t.l(d),n=empty()},m(d,h){a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,[h]){let p=e;e=u(d),e===p?a[e].p(d,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),t=a[e],t?t.p(d,h):(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n))},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),a[e].d(d)}}}function instance$1b(s,e,t){let n;const r=["asChild"];let o=compute_rest_props(e,r),a,{$$slots:u={},$$scope:d}=e,{asChild:h=!1}=e;const{states:{checked:p}}=getCtx$2();return component_subscribe(s,p,l=>t(1,a=l)),s.$$set=l=>{e=assign(assign({},e),exclude_internal_props(l)),t(4,o=compute_rest_props(e,r)),"asChild"in l&&t(0,h=l.asChild),"$$scope"in l&&t(5,d=l.$$scope)},s.$$.update=()=>{s.$$.dirty&2&&t(2,n={...getAttrs$2("thumb"),"data-state":a?"checked":"unchecked","data-checked":a?"":void 0})},[h,a,n,p,o,d,u]}class SwitchThumb extends SvelteComponent{constructor(e){super(),init(this,e,instance$1b,create_fragment$18,safe_not_equal,{asChild:0})}}const get_default_slot_changes_1$6=s=>({builder:s&2}),get_default_slot_context_1$6=s=>({builder:s[1],attrs:s[3]}),get_default_slot_changes$8=s=>({builder:s&2}),get_default_slot_context$8=s=>({builder:s[1],attrs:s[3]});function create_else_block$e(s){let e,t,n,r;const o=s[13].default,a=create_slot(o,s,s[12],get_default_slot_context_1$6);let u=[s[1],s[4],s[3]],d={};for(let h=0;h<u.length;h+=1)d=assign(d,u[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,d)},m(h,p){insert_hydration(h,e,p),a&&a.m(e,null),t=!0,n||(r=action_destroyer(s[1].action(e)),n=!0)},p(h,p){a&&a.p&&(!t||p&4098)&&update_slot_base(a,o,h,h[12],t?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,d=get_spread_update(u,[p&2&&h[1],p&16&&h[4],h[3]]))},i(h){t||(transition_in(a,h),t=!0)},o(h){transition_out(a,h),t=!1},d(h){h&&detach(e),a&&a.d(h),n=!1,r()}}}function create_if_block$x(s){let e;const t=s[13].default,n=create_slot(t,s,s[12],get_default_slot_context$8);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&4098)&&update_slot_base(n,t,r,r[12],e?get_slot_changes(t,r[12],o,get_default_slot_changes$8):get_all_dirty_from_scope(r[12]),get_default_slot_context$8)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$17(s){let e,t,n,r;const o=[create_if_block$x,create_else_block$e],a=[];function u(d,h){return d[0]?0:1}return e=u(s),t=a[e]=o[e](s),{c(){t.c(),n=empty()},l(d){t.l(d),n=empty()},m(d,h){a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,[h]){let p=e;e=u(d),e===p?a[e].p(d,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),t=a[e],t?t.p(d,h):(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n))},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),a[e].d(d)}}}function instance$1a(s,e,t){let n;const r=["orientation","activateOnFocus","loop","autoSet","value","onValueChange","asChild"];let o=compute_rest_props(e,r),a,{$$slots:u={},$$scope:d}=e,{orientation:h=void 0}=e,{activateOnFocus:p=void 0}=e,{loop:l=void 0}=e,{autoSet:i=void 0}=e,{value:c=void 0}=e,{onValueChange:f=void 0}=e,{asChild:g=!1}=e;const{elements:{root:m},states:{value:_},updateOption:b}=setCtx$3({orientation:h,activateOnFocus:p,loop:l,autoSet:i,defaultValue:c,onValueChange:({next:T})=>(c!==T&&(f==null||f(T),t(5,c=T)),T)});component_subscribe(s,m,T=>t(11,a=T));const v=getAttrs$3("root");return s.$$set=T=>{e=assign(assign({},e),exclude_internal_props(T)),t(4,o=compute_rest_props(e,r)),"orientation"in T&&t(6,h=T.orientation),"activateOnFocus"in T&&t(7,p=T.activateOnFocus),"loop"in T&&t(8,l=T.loop),"autoSet"in T&&t(9,i=T.autoSet),"value"in T&&t(5,c=T.value),"onValueChange"in T&&t(10,f=T.onValueChange),"asChild"in T&&t(0,g=T.asChild),"$$scope"in T&&t(12,d=T.$$scope)},s.$$.update=()=>{s.$$.dirty&32&&c!==void 0&&_.set(c),s.$$.dirty&64&&b("orientation",h),s.$$.dirty&128&&b("activateOnFocus",p),s.$$.dirty&256&&b("loop",l),s.$$.dirty&512&&b("autoSet",i),s.$$.dirty&2048&&t(1,n=a)},[g,n,m,v,o,c,h,p,l,i,f,a,d,u]}class Tabs extends SvelteComponent{constructor(e){super(),init(this,e,instance$1a,create_fragment$17,safe_not_equal,{orientation:6,activateOnFocus:7,loop:8,autoSet:9,value:5,onValueChange:10,asChild:0})}}const get_default_slot_changes_1$5=s=>({builder:s&2}),get_default_slot_context_1$5=s=>({builder:s[1],attrs:s[3]}),get_default_slot_changes$7=s=>({builder:s&2}),get_default_slot_context$7=s=>({builder:s[1],attrs:s[3]});function create_else_block$d(s){let e,t,n,r;const o=s[8].default,a=create_slot(o,s,s[7],get_default_slot_context_1$5);let u=[s[1],s[4],s[3]],d={};for(let h=0;h<u.length;h+=1)d=assign(d,u[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,d)},m(h,p){insert_hydration(h,e,p),a&&a.m(e,null),t=!0,n||(r=action_destroyer(s[1].action(e)),n=!0)},p(h,p){a&&a.p&&(!t||p&130)&&update_slot_base(a,o,h,h[7],t?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,d=get_spread_update(u,[p&2&&h[1],p&16&&h[4],h[3]]))},i(h){t||(transition_in(a,h),t=!0)},o(h){transition_out(a,h),t=!1},d(h){h&&detach(e),a&&a.d(h),n=!1,r()}}}function create_if_block$w(s){let e;const t=s[8].default,n=create_slot(t,s,s[7],get_default_slot_context$7);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&130)&&update_slot_base(n,t,r,r[7],e?get_slot_changes(t,r[7],o,get_default_slot_changes$7):get_all_dirty_from_scope(r[7]),get_default_slot_context$7)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$16(s){let e,t,n,r;const o=[create_if_block$w,create_else_block$d],a=[];function u(d,h){return d[0]?0:1}return e=u(s),t=a[e]=o[e](s),{c(){t.c(),n=empty()},l(d){t.l(d),n=empty()},m(d,h){a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,[h]){let p=e;e=u(d),e===p?a[e].p(d,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),t=a[e],t?t.p(d,h):(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n))},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),a[e].d(d)}}}function instance$19(s,e,t){let n;const r=["value","asChild"];let o=compute_rest_props(e,r),a,{$$slots:u={},$$scope:d}=e,{value:h}=e,{asChild:p=!1}=e;const{elements:{content:l}}=getCtx$3();component_subscribe(s,l,c=>t(6,a=c));const i=getAttrs$3("content");return s.$$set=c=>{e=assign(assign({},e),exclude_internal_props(c)),t(4,o=compute_rest_props(e,r)),"value"in c&&t(5,h=c.value),"asChild"in c&&t(0,p=c.asChild),"$$scope"in c&&t(7,d=c.$$scope)},s.$$.update=()=>{s.$$.dirty&96&&t(1,n=a(h))},[p,n,l,i,o,h,a,d,u]}class TabsContent extends SvelteComponent{constructor(e){super(),init(this,e,instance$19,create_fragment$16,safe_not_equal,{value:5,asChild:0})}}const get_default_slot_changes_1$4=s=>({builder:s&2}),get_default_slot_context_1$4=s=>({builder:s[1],attrs:s[3]}),get_default_slot_changes$6=s=>({builder:s&2}),get_default_slot_context$6=s=>({builder:s[1],attrs:s[3]});function create_else_block$c(s){let e,t,n,r;const o=s[7].default,a=create_slot(o,s,s[6],get_default_slot_context_1$4);let u=[s[1],s[4],s[3]],d={};for(let h=0;h<u.length;h+=1)d=assign(d,u[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,d)},m(h,p){insert_hydration(h,e,p),a&&a.m(e,null),t=!0,n||(r=action_destroyer(s[1].action(e)),n=!0)},p(h,p){a&&a.p&&(!t||p&66)&&update_slot_base(a,o,h,h[6],t?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,d=get_spread_update(u,[p&2&&h[1],p&16&&h[4],h[3]]))},i(h){t||(transition_in(a,h),t=!0)},o(h){transition_out(a,h),t=!1},d(h){h&&detach(e),a&&a.d(h),n=!1,r()}}}function create_if_block$v(s){let e;const t=s[7].default,n=create_slot(t,s,s[6],get_default_slot_context$6);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&66)&&update_slot_base(n,t,r,r[6],e?get_slot_changes(t,r[6],o,get_default_slot_changes$6):get_all_dirty_from_scope(r[6]),get_default_slot_context$6)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$15(s){let e,t,n,r;const o=[create_if_block$v,create_else_block$c],a=[];function u(d,h){return d[0]?0:1}return e=u(s),t=a[e]=o[e](s),{c(){t.c(),n=empty()},l(d){t.l(d),n=empty()},m(d,h){a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,[h]){let p=e;e=u(d),e===p?a[e].p(d,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),t=a[e],t?t.p(d,h):(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n))},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),a[e].d(d)}}}function instance$18(s,e,t){let n;const r=["asChild"];let o=compute_rest_props(e,r),a,{$$slots:u={},$$scope:d}=e,{asChild:h=!1}=e;const{elements:{list:p}}=getCtx$3();component_subscribe(s,p,i=>t(5,a=i));const l=getAttrs$3("list");return s.$$set=i=>{e=assign(assign({},e),exclude_internal_props(i)),t(4,o=compute_rest_props(e,r)),"asChild"in i&&t(0,h=i.asChild),"$$scope"in i&&t(6,d=i.$$scope)},s.$$.update=()=>{s.$$.dirty&32&&t(1,n=a)},[h,n,p,l,o,a,d,u]}class TabsList extends SvelteComponent{constructor(e){super(),init(this,e,instance$18,create_fragment$15,safe_not_equal,{asChild:0})}}const get_default_slot_changes_1$3=s=>({builder:s&2}),get_default_slot_context_1$3=s=>({builder:s[1],attrs:s[4]}),get_default_slot_changes$5=s=>({builder:s&2}),get_default_slot_context$5=s=>({builder:s[1],attrs:s[4]});function create_else_block$b(s){let e,t,n,r;const o=s[10].default,a=create_slot(o,s,s[9],get_default_slot_context_1$3);let u=[s[1],{type:"button"},s[5],s[4]],d={};for(let h=0;h<u.length;h+=1)d=assign(d,u[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,d)},m(h,p){insert_hydration(h,e,p),a&&a.m(e,null),e.autofocus&&e.focus(),t=!0,n||(r=[action_destroyer(s[1].action(e)),listen(e,"m-click",s[3]),listen(e,"m-focus",s[3]),listen(e,"m-keydown",s[3])],n=!0)},p(h,p){a&&a.p&&(!t||p&514)&&update_slot_base(a,o,h,h[9],t?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,d=get_spread_update(u,[p&2&&h[1],{type:"button"},p&32&&h[5],h[4]]))},i(h){t||(transition_in(a,h),t=!0)},o(h){transition_out(a,h),t=!1},d(h){h&&detach(e),a&&a.d(h),n=!1,run_all(r)}}}function create_if_block$u(s){let e;const t=s[10].default,n=create_slot(t,s,s[9],get_default_slot_context$5);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&514)&&update_slot_base(n,t,r,r[9],e?get_slot_changes(t,r[9],o,get_default_slot_changes$5):get_all_dirty_from_scope(r[9]),get_default_slot_context$5)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$14(s){let e,t,n,r;const o=[create_if_block$u,create_else_block$b],a=[];function u(d,h){return d[0]?0:1}return e=u(s),t=a[e]=o[e](s),{c(){t.c(),n=empty()},l(d){t.l(d),n=empty()},m(d,h){a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,[h]){let p=e;e=u(d),e===p?a[e].p(d,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),t=a[e],t?t.p(d,h):(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n))},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),a[e].d(d)}}}function instance$17(s,e,t){let n;const r=["value","disabled","asChild"];let o=compute_rest_props(e,r),a,{$$slots:u={},$$scope:d}=e,{value:h}=e,{disabled:p=void 0}=e,{asChild:l=!1}=e;const{elements:{trigger:i}}=getCtx$3();component_subscribe(s,i,g=>t(8,a=g));const c=createDispatcher(),f=getAttrs$3("trigger");return s.$$set=g=>{e=assign(assign({},e),exclude_internal_props(g)),t(5,o=compute_rest_props(e,r)),"value"in g&&t(6,h=g.value),"disabled"in g&&t(7,p=g.disabled),"asChild"in g&&t(0,l=g.asChild),"$$scope"in g&&t(9,d=g.$$scope)},s.$$.update=()=>{s.$$.dirty&448&&t(1,n=a({value:h,disabled:p}))},[l,n,i,c,f,o,h,p,a,d,u]}class TabsTrigger extends SvelteComponent{constructor(e){super(),init(this,e,instance$17,create_fragment$14,safe_not_equal,{value:6,disabled:7,asChild:0})}}function create_default_slot$G(s){let e;const t=s[3].default,n=create_slot(t,s,s[4],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&16)&&update_slot_base(n,t,r,r[4],e?get_slot_changes(t,r[4],o,null):get_all_dirty_from_scope(r[4]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$13(s){let e,t;const n=[{class:cn("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s[0])},{value:s[1]},s[2]];let r={$$slots:{default:[create_default_slot$G]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new TabsContent({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&7?get_spread_update(n,[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&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$16(s,e,t){const n=["class","value"];let r=compute_rest_props(e,n),{$$slots:o={},$$scope:a}=e,{class:u=void 0}=e,{value:d}=e;return s.$$set=h=>{e=assign(assign({},e),exclude_internal_props(h)),t(2,r=compute_rest_props(e,n)),"class"in h&&t(0,u=h.class),"value"in h&&t(1,d=h.value),"$$scope"in h&&t(4,a=h.$$scope)},[u,d,r,o,a]}class Tabs_content extends SvelteComponent{constructor(e){super(),init(this,e,instance$16,create_fragment$13,safe_not_equal,{class:0,value:1})}}function create_default_slot$F(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$12(s){let e,t;const n=[{class:cn("inline-flex w-full h-10 items-center justify-center text-muted-foreground",s[0])},s[1]];let r={$$slots:{default:[create_default_slot$F]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new TabsList({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[a&1&&{class:cn("inline-flex w-full h-10 items-center justify-center text-muted-foreground",o[0])},a&2&&get_spread_object(o[1])]):{};a&8&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$15(s,e,t){const n=["class"];let r=compute_rest_props(e,n),{$$slots:o={},$$scope:a}=e,{class:u=void 0}=e;return s.$$set=d=>{e=assign(assign({},e),exclude_internal_props(d)),t(1,r=compute_rest_props(e,n)),"class"in d&&t(0,u=d.class),"$$scope"in d&&t(3,a=d.$$scope)},[u,r,o,a]}class Tabs_list extends SvelteComponent{constructor(e){super(),init(this,e,instance$15,create_fragment$12,safe_not_equal,{class:0})}}function create_default_slot$E(s){let e;const t=s[3].default,n=create_slot(t,s,s[5],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&32)&&update_slot_base(n,t,r,r[5],e?get_slot_changes(t,r[5],o,null):get_all_dirty_from_scope(r[5]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$11(s){let e,t;const n=[{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=inactive]:bg-white data-[state=active]:font-bold",s[0])},{value:s[1]},s[2]];let r={$$slots:{default:[create_default_slot$E]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new TabsTrigger({props:r}),e.$on("click",s[4]),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&7?get_spread_update(n,[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=inactive]:bg-white data-[state=active]:font-bold",o[0])},a&2&&{value:o[1]},a&4&&get_spread_object(o[2])]):{};a&32&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$14(s,e,t){const n=["class","value"];let r=compute_rest_props(e,n),{$$slots:o={},$$scope:a}=e,{class:u=void 0}=e,{value:d}=e;function h(p){bubble.call(this,s,p)}return s.$$set=p=>{e=assign(assign({},e),exclude_internal_props(p)),t(2,r=compute_rest_props(e,n)),"class"in p&&t(0,u=p.class),"value"in p&&t(1,d=p.value),"$$scope"in p&&t(5,a=p.$$scope)},[u,d,r,o,h,a]}class Tabs_trigger extends SvelteComponent{constructor(e){super(),init(this,e,instance$14,create_fragment$11,safe_not_equal,{class:0,value:1})}}const Root$1=Tabs;function create_fragment$10(s){let e,t,n=[{class:t=cn("animate-pulse rounded-md bg-muted",s[0])},s[1]],r={};for(let o=0;o<n.length;o+=1)r=assign(r,n[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,r)},m(o,a){insert_hydration(o,e,a)},p(o,[a]){set_attributes(e,r=get_spread_update(n,[a&1&&t!==(t=cn("animate-pulse rounded-md bg-muted",o[0]))&&{class:t},a&2&&o[1]]))},i:noop,o:noop,d(o){o&&detach(e)}}}function instance$13(s,e,t){const n=["class"];let r=compute_rest_props(e,n),{class:o=void 0}=e;return s.$$set=a=>{e=assign(assign({},e),exclude_internal_props(a)),t(1,r=compute_rest_props(e,n)),"class"in a&&t(0,o=a.class)},[o,r]}class Skeleton extends SvelteComponent{constructor(e){super(),init(this,e,instance$13,create_fragment$10,safe_not_equal,{class:0})}}function create_default_slot$D(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$$(s){let e,t;const n=[{name:"box-select"},s[1],{iconNode:s[0]}];let r={$$slots:{default:[create_default_slot$D]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[n[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$12(s,e,t){let{$$slots:n={},$$scope:r}=e;const o=[["path",{d:"M5 3a2 2 0 0 0-2 2"}],["path",{d:"M19 3a2 2 0 0 1 2 2"}],["path",{d:"M21 19a2 2 0 0 1-2 2"}],["path",{d:"M5 21a2 2 0 0 1-2-2"}],["path",{d:"M9 3h1"}],["path",{d:"M9 21h1"}],["path",{d:"M14 3h1"}],["path",{d:"M14 21h1"}],["path",{d:"M3 9v1"}],["path",{d:"M21 9v1"}],["path",{d:"M3 14v1"}],["path",{d:"M21 14v1"}]];return s.$$set=a=>{t(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&t(3,r=a.$$scope)},e=exclude_internal_props(e),[o,e,n,r]}class Box_select extends SvelteComponent{constructor(e){super(),init(this,e,instance$12,create_fragment$$,safe_not_equal,{})}}const BoxSelectIcon=Box_select;function create_default_slot$C(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$_(s){let e,t;const n=[{name:"brush"},s[1],{iconNode:s[0]}];let r={$$slots:{default:[create_default_slot$C]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[n[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$11(s,e,t){let{$$slots:n={},$$scope:r}=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 s.$$set=a=>{t(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&t(3,r=a.$$scope)},e=exclude_internal_props(e),[o,e,n,r]}class Brush extends SvelteComponent{constructor(e){super(),init(this,e,instance$11,create_fragment$_,safe_not_equal,{})}}function create_default_slot$B(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$Z(s){let e,t;const n=[{name:"check-check"},s[1],{iconNode:s[0]}];let r={$$slots:{default:[create_default_slot$B]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[n[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$10(s,e,t){let{$$slots:n={},$$scope:r}=e;const o=[["path",{d:"M18 6 7 17l-5-5"}],["path",{d:"m22 10-7.5 7.5L13 16"}]];return s.$$set=a=>{t(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&t(3,r=a.$$scope)},e=exclude_internal_props(e),[o,e,n,r]}class Check_check extends SvelteComponent{constructor(e){super(),init(this,e,instance$10,create_fragment$Z,safe_not_equal,{})}}function create_default_slot$A(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$Y(s){let e,t;const n=[{name:"chevron-right"},s[1],{iconNode:s[0]}];let r={$$slots:{default:[create_default_slot$A]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[n[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$$(s,e,t){let{$$slots:n={},$$scope:r}=e;const o=[["path",{d:"m9 18 6-6-6-6"}]];return s.$$set=a=>{t(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&t(3,r=a.$$scope)},e=exclude_internal_props(e),[o,e,n,r]}class Chevron_right extends SvelteComponent{constructor(e){super(),init(this,e,instance$$,create_fragment$Y,safe_not_equal,{})}}const ChevronRight=Chevron_right;function create_default_slot$z(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$X(s){let e,t;const n=[{name:"chevrons-up-down"},s[1],{iconNode:s[0]}];let r={$$slots:{default:[create_default_slot$z]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[n[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$_(s,e,t){let{$$slots:n={},$$scope:r}=e;const o=[["path",{d:"m7 15 5 5 5-5"}],["path",{d:"m7 9 5-5 5 5"}]];return s.$$set=a=>{t(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&t(3,r=a.$$scope)},e=exclude_internal_props(e),[o,e,n,r]}class Chevrons_up_down extends SvelteComponent{constructor(e){super(),init(this,e,instance$_,create_fragment$X,safe_not_equal,{})}}function create_default_slot$y(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$W(s){let e,t;const n=[{name:"eye-off"},s[1],{iconNode:s[0]}];let r={$$slots:{default:[create_default_slot$y]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[n[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$Z(s,e,t){let{$$slots:n={},$$scope:r}=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 s.$$set=a=>{t(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&t(3,r=a.$$scope)},e=exclude_internal_props(e),[o,e,n,r]}class Eye_off extends SvelteComponent{constructor(e){super(),init(this,e,instance$Z,create_fragment$W,safe_not_equal,{})}}function create_default_slot$x(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$V(s){let e,t;const n=[{name:"eye"},s[1],{iconNode:s[0]}];let r={$$slots:{default:[create_default_slot$x]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[n[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$Y(s,e,t){let{$$slots:n={},$$scope:r}=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 s.$$set=a=>{t(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&t(3,r=a.$$scope)},e=exclude_internal_props(e),[o,e,n,r]}class Eye extends SvelteComponent{constructor(e){super(),init(this,e,instance$Y,create_fragment$V,safe_not_equal,{})}}function create_default_slot$w(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$U(s){let e,t;const n=[{name:"filter"},s[1],{iconNode:s[0]}];let r={$$slots:{default:[create_default_slot$w]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[n[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$X(s,e,t){let{$$slots:n={},$$scope:r}=e;const o=[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"}]];return s.$$set=a=>{t(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&t(3,r=a.$$scope)},e=exclude_internal_props(e),[o,e,n,r]}class Filter extends SvelteComponent{constructor(e){super(),init(this,e,instance$X,create_fragment$U,safe_not_equal,{})}}function create_default_slot$v(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$T(s){let e,t;const n=[{name:"minus-circle"},s[1],{iconNode:s[0]}];let r={$$slots:{default:[create_default_slot$v]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[n[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$W(s,e,t){let{$$slots:n={},$$scope:r}=e;const o=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M8 12h8"}]];return s.$$set=a=>{t(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&t(3,r=a.$$scope)},e=exclude_internal_props(e),[o,e,n,r]}class Minus_circle extends SvelteComponent{constructor(e){super(),init(this,e,instance$W,create_fragment$T,safe_not_equal,{})}}function create_default_slot$u(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$S(s){let e,t;const n=[{name:"mouse-pointer"},s[1],{iconNode:s[0]}];let r={$$slots:{default:[create_default_slot$u]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[n[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$V(s,e,t){let{$$slots:n={},$$scope:r}=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 s.$$set=a=>{t(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&t(3,r=a.$$scope)},e=exclude_internal_props(e),[o,e,n,r]}class Mouse_pointer extends SvelteComponent{constructor(e){super(),init(this,e,instance$V,create_fragment$S,safe_not_equal,{})}}function create_default_slot$t(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$R(s){let e,t;const n=[{name:"pencil"},s[1],{iconNode:s[0]}];let r={$$slots:{default:[create_default_slot$t]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[n[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$U(s,e,t){let{$$slots:n={},$$scope:r}=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 s.$$set=a=>{t(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&t(3,r=a.$$scope)},e=exclude_internal_props(e),[o,e,n,r]}class Pencil extends SvelteComponent{constructor(e){super(),init(this,e,instance$U,create_fragment$R,safe_not_equal,{})}}function create_default_slot$s(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$Q(s){let e,t;const n=[{name:"plus-circle"},s[1],{iconNode:s[0]}];let r={$$slots:{default:[create_default_slot$s]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[n[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$T(s,e,t){let{$$slots:n={},$$scope:r}=e;const o=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M8 12h8"}],["path",{d:"M12 8v8"}]];return s.$$set=a=>{t(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&t(3,r=a.$$scope)},e=exclude_internal_props(e),[o,e,n,r]}class Plus_circle extends SvelteComponent{constructor(e){super(),init(this,e,instance$T,create_fragment$Q,safe_not_equal,{})}}function create_default_slot$r(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$P(s){let e,t;const n=[{name:"search"},s[1],{iconNode:s[0]}];let r={$$slots:{default:[create_default_slot$r]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[n[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$S(s,e,t){let{$$slots:n={},$$scope:r}=e;const o=[["circle",{cx:"11",cy:"11",r:"8"}],["path",{d:"m21 21-4.3-4.3"}]];return s.$$set=a=>{t(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&t(3,r=a.$$scope)},e=exclude_internal_props(e),[o,e,n,r]}class Search extends SvelteComponent{constructor(e){super(),init(this,e,instance$S,create_fragment$P,safe_not_equal,{})}}function create_default_slot$q(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$O(s){let e,t;const n=[{name:"share-2"},s[1],{iconNode:s[0]}];let r={$$slots:{default:[create_default_slot$q]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[n[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$R(s,e,t){let{$$slots:n={},$$scope:r}=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 s.$$set=a=>{t(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&t(3,r=a.$$scope)},e=exclude_internal_props(e),[o,e,n,r]}class Share_2 extends SvelteComponent{constructor(e){super(),init(this,e,instance$R,create_fragment$O,safe_not_equal,{})}}function create_default_slot$p(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$N(s){let e,t;const n=[{name:"square"},s[1],{iconNode:s[0]}];let r={$$slots:{default:[create_default_slot$p]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[n[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$Q(s,e,t){let{$$slots:n={},$$scope:r}=e;const o=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}]];return s.$$set=a=>{t(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&t(3,r=a.$$scope)},e=exclude_internal_props(e),[o,e,n,r]}class Square extends SvelteComponent{constructor(e){super(),init(this,e,instance$Q,create_fragment$N,safe_not_equal,{})}}function create_default_slot$o(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$M(s){let e,t;const n=[{name:"trash-2"},s[1],{iconNode:s[0]}];let r={$$slots:{default:[create_default_slot$o]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[n[0],a&2&&get_spread_object(o[1]),a&1&&{iconNode:o[0]}]):{};a&8&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$P(s,e,t){let{$$slots:n={},$$scope:r}=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 s.$$set=a=>{t(1,e=assign(assign({},e),exclude_internal_props(a))),"$$scope"in a&&t(3,r=a.$$scope)},e=exclude_internal_props(e),[o,e,n,r]}class Trash_2 extends SvelteComponent{constructor(e){super(),init(this,e,instance$P,create_fragment$M,safe_not_equal,{})}}function styleToString(s){return Object.keys(s).reduce((e,t)=>s[t]===void 0?e:e+`${t}:${s[t]};`,"")}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(s,e,t,n){const r=Array.isArray(e)?e:[e];return r.forEach(o=>s.addEventListener(o,t,n)),()=>{r.forEach(o=>s.removeEventListener(o,t,n))}}function executeCallbacks(...s){return(...e)=>{for(const t of s)typeof t=="function"&&t(...e)}}const get_default_slot_spread_changes_1=s=>s&4,get_default_slot_changes_1$2=s=>({}),get_default_slot_context_1$2=s=>({...s[2]}),get_default_slot_spread_changes=s=>s&4,get_default_slot_changes$4=s=>({}),get_default_slot_context$4=s=>({...s[2]});function create_else_block$a(s){let e,t,n=(s[0]??"")+"",r,o,a,u,d,h=[s[6]],p={};for(let g=0;g<h.length;g+=1)p=assign(p,h[g]);const l=s[18].default,i=create_slot(l,s,s[17],get_default_slot_context_1$2);let c=[s[5],s[7]],f={};for(let g=0;g<c.length;g+=1)f=assign(f,c[g]);return{c(){e=element("div"),t=element("label"),r=text(n),o=space(),i&&i.c(),this.h()},l(g){e=claim_element(g,"DIV",{});var m=children(e);t=claim_element(m,"LABEL",{});var _=children(t);r=claim_text(_,n),_.forEach(detach),o=claim_space(m),i&&i.l(m),m.forEach(detach),this.h()},h(){set_attributes(t,p),set_attributes(e,f)},m(g,m){insert_hydration(g,e,m),append_hydration(e,t),append_hydration(t,r),append_hydration(e,o),i&&i.m(e,null),a=!0,u||(d=action_destroyer(s[4].call(null,e)),u=!0)},p(g,m){(!a||m&1)&&n!==(n=(g[0]??"")+"")&&set_data_maybe_contenteditable(r,n,p.contenteditable),i&&i.p&&(!a||m&131076)&&update_slot_base(i,l,g,g[17],get_default_slot_spread_changes_1(m)||!a?get_all_dirty_from_scope(g[17]):get_slot_changes(l,g[17],m,get_default_slot_changes_1$2),get_default_slot_context_1$2),set_attributes(e,f=get_spread_update(c,[g[5],m&128&&g[7]]))},i(g){a||(transition_in(i,g),a=!0)},o(g){transition_out(i,g),a=!1},d(g){g&&detach(e),i&&i.d(g),u=!1,d()}}}function create_if_block$t(s){let e;const t=s[18].default,n=create_slot(t,s,s[17],get_default_slot_context$4);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&131076)&&update_slot_base(n,t,r,r[17],get_default_slot_spread_changes(o)||!e?get_all_dirty_from_scope(r[17]):get_slot_changes(t,r[17],o,get_default_slot_changes$4),get_default_slot_context$4)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$L(s){let e,t,n,r;const o=[create_if_block$t,create_else_block$a],a=[];function u(d,h){return d[1]?0:1}return e=u(s),t=a[e]=o[e](s),{c(){t.c(),n=empty()},l(d){t.l(d),n=empty()},m(d,h){a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,[h]){let p=e;e=u(d),e===p?a[e].p(d,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),t=a[e],t?t.p(d,h):(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n))},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),a[e].d(d)}}}function instance$O(s,e,t){let n;const r=["label","shouldFilter","filter","value","onValueChange","loop","onKeydown","state","ids","asChild"];let o=compute_rest_props(e,r),a,{$$slots:u={},$$scope:d}=e,{label:h=void 0}=e,{shouldFilter:p=!0}=e,{filter:l=void 0}=e,{value:i=void 0}=e,{onValueChange:c=void 0}=e,{loop:f=void 0}=e,{onKeydown:g=void 0}=e,{state:m=void 0}=e,{ids:_=void 0}=e,{asChild:b=!1}=e;const{commandEl:v,handleRootKeydown:T,ids:y,state:S}=createCommand({label:h,shouldFilter:p,filter:l,value:i,onValueChange:E=>{E!==i&&(t(8,i=E),c==null||c(E))},loop:f,state:m,ids:_});component_subscribe(s,S,E=>t(16,a=E));function w(E){E&&E!==a.value&&set_store_value(S,a.value=E,a)}function k(E){return v.set(E),{destroy:executeCallbacks(addEventListener(E,"keydown",F))}}const P={role:"application",id:y.root,"data-cmdk-root":""},I={"data-cmdk-label":"",for:y.input,id:y.label,style:styleToString(srOnlyStyles)};function F(E){g==null||g(E),!E.defaultPrevented&&T(E)}const C={action:k,attrs:P};return s.$$set=E=>{e=assign(assign({},e),exclude_internal_props(E)),t(7,o=compute_rest_props(e,r)),"label"in E&&t(0,h=E.label),"shouldFilter"in E&&t(9,p=E.shouldFilter),"filter"in E&&t(10,l=E.filter),"value"in E&&t(8,i=E.value),"onValueChange"in E&&t(11,c=E.onValueChange),"loop"in E&&t(12,f=E.loop),"onKeydown"in E&&t(13,g=E.onKeydown),"state"in E&&t(14,m=E.state),"ids"in E&&t(15,_=E.ids),"asChild"in E&&t(1,b=E.asChild),"$$scope"in E&&t(17,d=E.$$scope)},s.$$.update=()=>{s.$$.dirty&256&&w(i),s.$$.dirty&65536&&t(2,n={root:C,label:{attrs:I},stateStore:S,state:a})},[h,b,n,S,k,P,I,o,i,p,l,c,f,g,m,_,a,d,u]}let Command$1=class extends SvelteComponent{constructor(e){super(),init(this,e,instance$O,create_fragment$L,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=s=>({container:s&32,group:s&16}),get_default_slot_context_1$1=s=>({container:s[5],group:s[4],heading:{attrs:s[8]}}),get_default_slot_changes$3=s=>({container:s&32,group:s&16}),get_default_slot_context$3=s=>({container:s[5],group:s[4],heading:{attrs:s[8]}});function create_else_block$9(s){let e,t,n,r,o,a,u=s[0]&&create_if_block_1$e(s);const d=s[14].default,h=create_slot(d,s,s[13],get_default_slot_context_1$1);let p=[s[2]],l={};for(let f=0;f<p.length;f+=1)l=assign(l,p[f]);let i=[s[3],s[9]],c={};for(let f=0;f<i.length;f+=1)c=assign(c,i[f]);return{c(){e=element("div"),u&&u.c(),t=space(),n=element("div"),h&&h.c(),this.h()},l(f){e=claim_element(f,"DIV",{});var g=children(e);u&&u.l(g),t=claim_space(g),n=claim_element(g,"DIV",{});var m=children(n);h&&h.l(m),m.forEach(detach),g.forEach(detach),this.h()},h(){set_attributes(n,l),set_attributes(e,c)},m(f,g){insert_hydration(f,e,g),u&&u.m(e,null),append_hydration(e,t),append_hydration(e,n),h&&h.m(n,null),r=!0,o||(a=action_destroyer(s[7].call(null,e)),o=!0)},p(f,g){f[0]?u?u.p(f,g):(u=create_if_block_1$e(f),u.c(),u.m(e,t)):u&&(u.d(1),u=null),h&&h.p&&(!r||g&8240)&&update_slot_base(h,d,f,f[13],r?get_slot_changes(d,f[13],g,get_default_slot_changes_1$1):get_all_dirty_from_scope(f[13]),get_default_slot_context_1$1),set_attributes(n,l=get_spread_update(p,[g&4&&f[2]])),set_attributes(e,c=get_spread_update(i,[g&8&&f[3],g&512&&f[9]]))},i(f){r||(transition_in(h,f),r=!0)},o(f){transition_out(h,f),r=!1},d(f){f&&detach(e),u&&u.d(),h&&h.d(f),o=!1,a()}}}function create_if_block$s(s){let e;const t=s[14].default,n=create_slot(t,s,s[13],get_default_slot_context$3);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8240)&&update_slot_base(n,t,r,r[13],e?get_slot_changes(t,r[13],o,get_default_slot_changes$3):get_all_dirty_from_scope(r[13]),get_default_slot_context$3)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_if_block_1$e(s){let e,t,n=[s[8]],r={};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return{c(){e=element("div"),t=text(s[0]),this.h()},l(o){e=claim_element(o,"DIV",{});var a=children(e);t=claim_text(a,s[0]),a.forEach(detach),this.h()},h(){set_attributes(e,r)},m(o,a){insert_hydration(o,e,a),append_hydration(e,t)},p(o,a){a&1&&set_data_maybe_contenteditable(t,o[0],r.contenteditable)},d(o){o&&detach(e)}}}function create_fragment$K(s){let e,t,n,r;const o=[create_if_block$s,create_else_block$9],a=[];function u(d,h){return d[1]?0:1}return e=u(s),t=a[e]=o[e](s),{c(){t.c(),n=empty()},l(d){t.l(d),n=empty()},m(d,h){a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,[h]){let p=e;e=u(d),e===p?a[e].p(d,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),t=a[e],t?t.p(d,h):(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n))},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),a[e].d(d)}}}function instance$N(s,e,t){let n,r,o,a;const u=["heading","value","alwaysRender","asChild"];let d=compute_rest_props(e,u),h,{$$slots:p={},$$scope:l}=e,{heading:i=void 0}=e,{value:c=""}=e,{alwaysRender:f=!1}=e,{asChild:g=!1}=e;const{id:m}=createGroup(f),_=getCtx$4(),b=getState(),v=generateId(),T=derived(b,w=>f||_.filter()===!1||!w.search?!0:w.filtered.groups.has(m));component_subscribe(s,T,w=>t(12,h=w)),onMount(()=>_.group(m));function y(w){if(c){_.value(m,c),w.setAttribute(VALUE_ATTR,c);return}i?t(10,c=i.trim().toLowerCase()):w.textContent&&t(10,c=w.textContent.trim().toLowerCase()),_.value(m,c),w.setAttribute(VALUE_ATTR,c)}const S={"data-cmdk-group-heading":"","aria-hidden":!0,id:v};return s.$$set=w=>{e=assign(assign({},e),exclude_internal_props(w)),t(9,d=compute_rest_props(e,u)),"heading"in w&&t(0,i=w.heading),"value"in w&&t(10,c=w.value),"alwaysRender"in w&&t(11,f=w.alwaysRender),"asChild"in w&&t(1,g=w.asChild),"$$scope"in w&&t(13,l=w.$$scope)},s.$$.update=()=>{s.$$.dirty&5120&&t(3,n={"data-cmdk-group":"",role:"presentation",hidden:h?void 0:!0,"data-value":c}),s.$$.dirty&1&&t(2,r={"data-cmdk-group-items":"",role:"group","aria-labelledby":i?v:void 0}),s.$$.dirty&8&&t(5,o={action:y,attrs:n}),s.$$.dirty&4&&t(4,a={attrs:r})},[i,g,r,n,a,o,T,y,S,d,c,f,h,l,p]}class CommandGroup extends SvelteComponent{constructor(e){super(),init(this,e,instance$N,create_fragment$K,safe_not_equal,{heading:0,value:10,alwaysRender:11,asChild:1})}}function sleep(s){return new Promise(e=>setTimeout(e,s))}const get_default_slot_changes$2=s=>({attrs:s&8}),get_default_slot_context$2=s=>({action:s[6],attrs:s[3]});function create_else_block$8(s){let e,t,n,r=[s[3],s[7]],o={};for(let a=0;a<r.length;a+=1)o=assign(o,r[a]);return{c(){e=element("input"),this.h()},l(a){e=claim_element(a,"INPUT",{}),this.h()},h(){set_attributes(e,o)},m(a,u){insert_hydration(a,e,u),e.autofocus&&e.focus(),s[16](e),set_input_value(e,s[0]),t||(n=[listen(e,"input",s[17]),action_destroyer(s[6].call(null,e)),listen(e,"input",s[12]),listen(e,"focus",s[13]),listen(e,"blur",s[14]),listen(e,"change",s[15])],t=!0)},p(a,u){set_attributes(e,o=get_spread_update(r,[u&8&&a[3],u&128&&a[7]])),u&1&&e.value!==a[0]&&set_input_value(e,a[0])},i:noop,o:noop,d(a){a&&detach(e),s[16](null),t=!1,run_all(n)}}}function create_if_block$r(s){let e;const t=s[11].default,n=create_slot(t,s,s[10],get_default_slot_context$2);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&1032)&&update_slot_base(n,t,r,r[10],e?get_slot_changes(t,r[10],o,get_default_slot_changes$2):get_all_dirty_from_scope(r[10]),get_default_slot_context$2)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$J(s){let e,t,n,r;const o=[create_if_block$r,create_else_block$8],a=[];function u(d,h){return d[2]?0:1}return e=u(s),t=a[e]=o[e](s),{c(){t.c(),n=empty()},l(d){t.l(d),n=empty()},m(d,h){a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,[h]){let p=e;e=u(d),e===p?a[e].p(d,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),t=a[e],t?t.p(d,h):(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n))},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),a[e].d(d)}}}function instance$M(s,e,t){const n=["autofocus","value","asChild","el"];let r=compute_rest_props(e,n),o,a,{$$slots:u={},$$scope:d}=e;const{ids:h,commandEl:p}=getCtx$4(),l=getState(),i=derived(l,C=>C.search);component_subscribe(s,i,C=>t(18,a=C));const c=derived(l,C=>C.value);let{autofocus:f=void 0}=e,{value:g=a}=e,{asChild:m=!1}=e,{el:_=void 0}=e;const b=derived([c,p],([C,E])=>{if(!isBrowser)return;const $=E==null?void 0:E.querySelector(`${ITEM_SELECTOR}[${VALUE_ATTR}="${C}"]`);return $==null?void 0:$.getAttribute("id")});component_subscribe(s,b,C=>t(9,o=C));function v(C){l.updateState("search",C)}function T(C){return f&&sleep(10).then(()=>C.focus()),{destroy:addEventListener(C,"change",$=>{isHTMLInputElement($.target)&&l.updateState("search",$.target.value)})}}let y;function S(C){bubble.call(this,s,C)}function w(C){bubble.call(this,s,C)}function k(C){bubble.call(this,s,C)}function P(C){bubble.call(this,s,C)}function I(C){binding_callbacks[C?"unshift":"push"](()=>{_=C,t(1,_)})}function F(){g=this.value,t(0,g)}return s.$$set=C=>{e=assign(assign({},e),exclude_internal_props(C)),t(7,r=compute_rest_props(e,n)),"autofocus"in C&&t(8,f=C.autofocus),"value"in C&&t(0,g=C.value),"asChild"in C&&t(2,m=C.asChild),"el"in C&&t(1,_=C.el),"$$scope"in C&&t(10,d=C.$$scope)},s.$$.update=()=>{s.$$.dirty&1&&v(g),s.$$.dirty&512&&t(3,y={type:"text","data-cmdk-input":"",autocomplete:"off",autocorrect:"off",spellcheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":h.list,"aria-labelledby":h.label,"aria-activedescendant":o??void 0,id:h.input})},[g,_,m,y,i,b,T,r,f,o,d,u,S,w,k,P,I,F]}class CommandInput extends SvelteComponent{constructor(e){super(),init(this,e,instance$M,create_fragment$J,safe_not_equal,{autofocus:8,value:0,asChild:2,el:1})}}const get_default_slot_changes_1=s=>({attrs:s&4}),get_default_slot_context_1=s=>({action:s[6],attrs:s[2]}),get_default_slot_changes$1=s=>({attrs:s&4}),get_default_slot_context$1=s=>({action:s[6],attrs:s[2]});function create_if_block$q(s){let e,t,n,r;const o=[create_if_block_1$d,create_else_block$7],a=[];function u(d,h){return d[0]?0:1}return e=u(s),t=a[e]=o[e](s),{c(){t.c(),n=empty()},l(d){t.l(d),n=empty()},m(d,h){a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,h){let p=e;e=u(d),e===p?a[e].p(d,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),t=a[e],t?t.p(d,h):(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n))},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),a[e].d(d)}}}function create_else_block$7(s){let e,t,n,r;const o=s[15].default,a=create_slot(o,s,s[14],get_default_slot_context_1);let u=[s[2],s[7]],d={};for(let h=0;h<u.length;h+=1)d=assign(d,u[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,d)},m(h,p){insert_hydration(h,e,p),a&&a.m(e,null),t=!0,n||(r=action_destroyer(s[6].call(null,e)),n=!0)},p(h,p){a&&a.p&&(!t||p&16388)&&update_slot_base(a,o,h,h[14],t?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,d=get_spread_update(u,[p&4&&h[2],p&128&&h[7]]))},i(h){t||(transition_in(a,h),t=!0)},o(h){transition_out(a,h),t=!1},d(h){h&&detach(e),a&&a.d(h),n=!1,r()}}}function create_if_block_1$d(s){let e;const t=s[15].default,n=create_slot(t,s,s[14],get_default_slot_context$1);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&16388)&&update_slot_base(n,t,r,r[14],e?get_slot_changes(t,r[14],o,get_default_slot_changes$1):get_all_dirty_from_scope(r[14]),get_default_slot_context$1)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$I(s){let e,t,n=(s[3]||s[1])&&create_if_block$q(s);return{c(){n&&n.c(),e=empty()},l(r){n&&n.l(r),e=empty()},m(r,o){n&&n.m(r,o),insert_hydration(r,e,o),t=!0},p(r,[o]){r[3]||r[1]?n?(n.p(r,o),o&10&&transition_in(n,1)):(n=create_if_block$q(r),n.c(),transition_in(n,1),n.m(e.parentNode,e)):n&&(group_outros(),transition_out(n,1,1,()=>{n=null}),check_outros())},i(r){t||(transition_in(n),t=!0)},o(r){transition_out(n),t=!1},d(r){r&&detach(e),n&&n.d(r)}}}function instance$L(s,e,t){let n;const r=["disabled","value","onSelect","alwaysRender","asChild","id"];let o=compute_rest_props(e,r),a,u,{$$slots:d={},$$scope:h}=e,{disabled:p=!1}=e,{value:l=""}=e,{onSelect:i=void 0}=e,{alwaysRender:c=!1}=e,{asChild:f=!1}=e,{id:g=generateId()}=e;const m=getGroup(),_=getCtx$4(),b=getState(),v=c??(m==null?void 0:m.alwaysRender),T=derived(b,I=>{if(v||_.filter()===!1||!I.search)return!0;const F=I.filtered.items.get(g);return isUndefined(F)?!1:F>0});component_subscribe(s,T,I=>t(3,u=I));let y=!0;onMount(()=>(t(1,y=!1),_.item(g,m==null?void 0:m.id)));const S=derived(b,I=>I.value===l);component_subscribe(s,S,I=>t(13,a=I));function w(I){!l&&I.textContent&&t(8,l=I.textContent.trim().toLowerCase()),_.value(g,l),I.setAttribute(VALUE_ATTR,l);const F=executeCallbacks(addEventListener(I,"pointermove",()=>{p||P()}),addEventListener(I,"click",()=>{p||k()}));return{destroy(){F()}}}function k(){P(),i==null||i(l)}function P(){b.updateState("value",l,!0)}return s.$$set=I=>{e=assign(assign({},e),exclude_internal_props(I)),t(7,o=compute_rest_props(e,r)),"disabled"in I&&t(9,p=I.disabled),"value"in I&&t(8,l=I.value),"onSelect"in I&&t(10,i=I.onSelect),"alwaysRender"in I&&t(11,c=I.alwaysRender),"asChild"in I&&t(0,f=I.asChild),"id"in I&&t(12,g=I.id),"$$scope"in I&&t(14,h=I.$$scope)},s.$$.update=()=>{s.$$.dirty&13056&&t(2,n={"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":l,role:"option",id:g})},[f,y,n,u,T,S,w,o,l,p,i,c,g,a,h,d]}class CommandItem extends SvelteComponent{constructor(e){super(),init(this,e,instance$L,create_fragment$I,safe_not_equal,{disabled:9,value:8,onSelect:10,alwaysRender:11,asChild:0,id:12})}}const get_default_slot_changes=s=>({}),get_default_slot_context=s=>({list:s[7],sizer:s[8]});function create_else_block$6(s){let e,t,n=s[2].search==="",r,o,a,u=create_key_block_1$1(s),d=[s[6]],h={};for(let i=0;i<d.length;i+=1)h=assign(h,d[i]);let p=[s[5],s[9]],l={};for(let i=0;i<p.length;i+=1)l=assign(l,p[i]);return{c(){e=element("div"),t=element("div"),u.c(),this.h()},l(i){e=claim_element(i,"DIV",{});var c=children(e);t=claim_element(c,"DIV",{});var f=children(t);u.l(f),f.forEach(detach),c.forEach(detach),this.h()},h(){set_attributes(t,h),set_attributes(e,l)},m(i,c){insert_hydration(i,e,c),append_hydration(e,t),u.m(t,null),s[12](e),r=!0,o||(a=action_destroyer(s[4].call(null,t)),o=!0)},p(i,c){c&4&&safe_not_equal(n,n=i[2].search==="")?(group_outros(),transition_out(u,1,1,noop),check_outros(),u=create_key_block_1$1(i),u.c(),transition_in(u,1),u.m(t,null)):u.p(i,c),set_attributes(e,l=get_spread_update(p,[i[5],c&512&&i[9]]))},i(i){r||(transition_in(u),r=!0)},o(i){transition_out(u),r=!1},d(i){i&&detach(e),u.d(i),s[12](null),o=!1,a()}}}function create_if_block$p(s){let e=s[2].search==="",t,n,r=create_key_block$3(s);return{c(){r.c(),t=empty()},l(o){r.l(o),t=empty()},m(o,a){r.m(o,a),insert_hydration(o,t,a),n=!0},p(o,a){a&4&&safe_not_equal(e,e=o[2].search==="")?(group_outros(),transition_out(r,1,1,noop),check_outros(),r=create_key_block$3(o),r.c(),transition_in(r,1),r.m(t.parentNode,t)):r.p(o,a)},i(o){n||(transition_in(r),n=!0)},o(o){transition_out(r),n=!1},d(o){o&&detach(t),r.d(o)}}}function create_key_block_1$1(s){let e;const t=s[11].default,n=create_slot(t,s,s[10],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&1024)&&update_slot_base(n,t,r,r[10],e?get_slot_changes(t,r[10],o,null):get_all_dirty_from_scope(r[10]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_key_block$3(s){let e;const t=s[11].default,n=create_slot(t,s,s[10],get_default_slot_context);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&1024)&&update_slot_base(n,t,r,r[10],e?get_slot_changes(t,r[10],o,get_default_slot_changes):get_all_dirty_from_scope(r[10]),get_default_slot_context)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$H(s){let e,t,n,r;const o=[create_if_block$p,create_else_block$6],a=[];function u(d,h){return d[1]?0:1}return e=u(s),t=a[e]=o[e](s),{c(){t.c(),n=empty()},l(d){t.l(d),n=empty()},m(d,h){a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,[h]){let p=e;e=u(d),e===p?a[e].p(d,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),t=a[e],t?t.p(d,h):(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n))},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),a[e].d(d)}}}function instance$K(s,e,t){const n=["el","asChild"];let r=compute_rest_props(e,n),o,{$$slots:a={},$$scope:u}=e;const{ids:d}=getCtx$4(),h=getState();component_subscribe(s,h,b=>t(2,o=b));let{el:p=void 0}=e,{asChild:l=!1}=e;function i(b){let v;const T=b.closest("[data-cmdk-list]");if(!isHTMLElement(T))return;const y=new ResizeObserver(()=>{v=requestAnimationFrame(()=>{const S=b.offsetHeight;T.style.setProperty("--cmdk-list-height",S.toFixed(1)+"px")})});return y.observe(b),{destroy(){cancelAnimationFrame(v),y.unobserve(b)}}}const c={"data-cmdk-list":"",role:"listbox","aria-label":"Suggestions",id:d.list,"aria-labelledby":d.input},f={"data-cmdk-list-sizer":""},g={attrs:c},m={attrs:f,action:i};function _(b){binding_callbacks[b?"unshift":"push"](()=>{p=b,t(0,p)})}return s.$$set=b=>{e=assign(assign({},e),exclude_internal_props(b)),t(9,r=compute_rest_props(e,n)),"el"in b&&t(0,p=b.el),"asChild"in b&&t(1,l=b.asChild),"$$scope"in b&&t(10,u=b.$$scope)},[p,l,o,h,i,c,f,g,m,r,u,a,_]}class CommandList extends SvelteComponent{constructor(e){super(),init(this,e,instance$K,create_fragment$H,safe_not_equal,{el:0,asChild:1})}}function create_default_slot$n(s){let e;const t=s[3].default,n=create_slot(t,s,s[5],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&32)&&update_slot_base(n,t,r,r[5],e?get_slot_changes(t,r[5],o,null):get_all_dirty_from_scope(r[5]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$G(s){let e,t,n;const r=[{class:cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground relative",s[1])},s[2]];function o(u){s[4](u)}let a={$$slots:{default:[create_default_slot$n]},$$scope:{ctx:s}};for(let u=0;u<r.length;u+=1)a=assign(a,r[u]);return s[0]!==void 0&&(a.value=s[0]),e=new Command$1({props:a}),binding_callbacks.push(()=>bind(e,"value",o)),{c(){create_component(e.$$.fragment)},l(u){claim_component(e.$$.fragment,u)},m(u,d){mount_component(e,u,d),n=!0},p(u,[d]){const h=d&6?get_spread_update(r,[d&2&&{class:cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground relative",u[1])},d&4&&get_spread_object(u[2])]):{};d&32&&(h.$$scope={dirty:d,ctx:u}),!t&&d&1&&(t=!0,h.value=u[0],add_flush_callback(()=>t=!1)),e.$set(h)},i(u){n||(transition_in(e.$$.fragment,u),n=!0)},o(u){transition_out(e.$$.fragment,u),n=!1},d(u){destroy_component(e,u)}}}function instance$J(s,e,t){const n=["value","class"];let r=compute_rest_props(e,n),{$$slots:o={},$$scope:a}=e,{value:u=void 0}=e,{class:d=void 0}=e;function h(p){u=p,t(0,u)}return s.$$set=p=>{e=assign(assign({},e),exclude_internal_props(p)),t(2,r=compute_rest_props(e,n)),"value"in p&&t(0,u=p.value),"class"in p&&t(1,d=p.class),"$$scope"in p&&t(5,a=p.$$scope)},[u,d,r,o,h,a]}class Command extends SvelteComponent{constructor(e){super(),init(this,e,instance$J,create_fragment$G,safe_not_equal,{value:0,class:1})}}function create_default_slot$m(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$F(s){let e,t;const n=[{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",s[0])},s[1]];let r={$$slots:{default:[create_default_slot$m]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new CommandGroup({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[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&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$I(s,e,t){const n=["class"];let r=compute_rest_props(e,n),{$$slots:o={},$$scope:a}=e,{class:u=void 0}=e;return s.$$set=d=>{e=assign(assign({},e),exclude_internal_props(d)),t(1,r=compute_rest_props(e,n)),"class"in d&&t(0,u=d.class),"$$scope"in d&&t(3,a=d.$$scope)},[u,r,o,a]}class Command_group extends SvelteComponent{constructor(e){super(),init(this,e,instance$I,create_fragment$F,safe_not_equal,{class:0})}}function create_default_slot$l(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$E(s){let e,t;const n=[{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",s[0])},s[1]];let r={$$slots:{default:[create_default_slot$l]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new CommandItem({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[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&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$H(s,e,t){const n=["class"];let r=compute_rest_props(e,n),{$$slots:o={},$$scope:a}=e,{class:u=void 0}=e;return s.$$set=d=>{e=assign(assign({},e),exclude_internal_props(d)),t(1,r=compute_rest_props(e,n)),"class"in d&&t(0,u=d.class),"$$scope"in d&&t(3,a=d.$$scope)},[u,r,o,a]}class Command_item extends SvelteComponent{constructor(e){super(),init(this,e,instance$H,create_fragment$E,safe_not_equal,{class:0})}}function create_fragment$D(s){let e,t,n,r,o,a;t=new Search({props:{class:"mr-2 h-4 w-4 shrink-0 opacity-50"}});const u=[{class:cn("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",s[1])},s[2]];function d(p){s[3](p)}let h={};for(let p=0;p<u.length;p+=1)h=assign(h,u[p]);return s[0]!==void 0&&(h.value=s[0]),r=new CommandInput({props:h}),binding_callbacks.push(()=>bind(r,"value",d)),r.$on("input",s[4]),r.$on("focus",s[5]),r.$on("blur",s[6]),{c(){e=element("div"),create_component(t.$$.fragment),n=space(),create_component(r.$$.fragment),this.h()},l(p){e=claim_element(p,"DIV",{class:!0,"data-cmdk-input-wrapper":!0});var l=children(e);claim_component(t.$$.fragment,l),n=claim_space(l),claim_component(r.$$.fragment,l),l.forEach(detach),this.h()},h(){attr(e,"class","flex items-center border-b px-2"),attr(e,"data-cmdk-input-wrapper","")},m(p,l){insert_hydration(p,e,l),mount_component(t,e,null),append_hydration(e,n),mount_component(r,e,null),a=!0},p(p,[l]){const i=l&6?get_spread_update(u,[l&2&&{class:cn("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",p[1])},l&4&&get_spread_object(p[2])]):{};!o&&l&1&&(o=!0,i.value=p[0],add_flush_callback(()=>o=!1)),r.$set(i)},i(p){a||(transition_in(t.$$.fragment,p),transition_in(r.$$.fragment,p),a=!0)},o(p){transition_out(t.$$.fragment,p),transition_out(r.$$.fragment,p),a=!1},d(p){p&&detach(e),destroy_component(t),destroy_component(r)}}}function instance$G(s,e,t){const n=["class","value"];let r=compute_rest_props(e,n),{class:o=void 0}=e,{value:a=""}=e;function u(l){a=l,t(0,a)}function d(l){bubble.call(this,s,l)}function h(l){bubble.call(this,s,l)}function p(l){bubble.call(this,s,l)}return s.$$set=l=>{e=assign(assign({},e),exclude_internal_props(l)),t(2,r=compute_rest_props(e,n)),"class"in l&&t(1,o=l.class),"value"in l&&t(0,a=l.value)},[a,o,r,u,d,h,p]}class Command_input extends SvelteComponent{constructor(e){super(),init(this,e,instance$G,create_fragment$D,safe_not_equal,{class:1,value:0})}}function create_default_slot$k(s){let e;const t=s[2].default,n=create_slot(t,s,s[3],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&8)&&update_slot_base(n,t,r,r[3],e?get_slot_changes(t,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$C(s){let e,t;const n=[{class:cn("max-h-[300px] overflow-y-auto overflow-x-hidden",s[0])},s[1]];let r={$$slots:{default:[create_default_slot$k]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new CommandList({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&3?get_spread_update(n,[a&1&&{class:cn("max-h-[300px] overflow-y-auto overflow-x-hidden",o[0])},a&2&&get_spread_object(o[1])]):{};a&8&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$F(s,e,t){const n=["class"];let r=compute_rest_props(e,n),{$$slots:o={},$$scope:a}=e,{class:u=void 0}=e;return s.$$set=d=>{e=assign(assign({},e),exclude_internal_props(d)),t(1,r=compute_rest_props(e,n)),"class"in d&&t(0,u=d.class),"$$scope"in d&&t(3,a=d.$$scope)},[u,r,o,a]}class Command_list extends SvelteComponent{constructor(e){super(),init(this,e,instance$F,create_fragment$C,safe_not_equal,{class:0})}}function create_default_slot$j(s){let e;const t=s[4].default,n=create_slot(t,s,s[5],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&32)&&update_slot_base(n,t,r,r[5],e?get_slot_changes(t,r[5],o,null):get_all_dirty_from_scope(r[5]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$B(s){let e,t;const n=[{transition:s[1]},{transitionConfig:s[2]},{class:cn("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none",s[0])},s[3]];let r={$$slots:{default:[create_default_slot$j]},$$scope:{ctx:s}};for(let o=0;o<n.length;o+=1)r=assign(r,n[o]);return e=new PopoverContent({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,[a]){const u=a&15?get_spread_update(n,[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&&(u.$$scope={dirty:a,ctx:o}),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function instance$E(s,e,t){const n=["class","transition","transitionConfig"];let r=compute_rest_props(e,n),{$$slots:o={},$$scope:a}=e,{class:u=void 0}=e,{transition:d=flyAndScale}=e,{transitionConfig:h=void 0}=e;return s.$$set=p=>{e=assign(assign({},e),exclude_internal_props(p)),t(3,r=compute_rest_props(e,n)),"class"in p&&t(0,u=p.class),"transition"in p&&t(1,d=p.transition),"transitionConfig"in p&&t(2,h=p.transitionConfig),"$$scope"in p&&t(5,a=p.$$scope)},[u,d,h,r,o,a]}class Popover_content extends SvelteComponent{constructor(e){super(),init(this,e,instance$E,create_fragment$B,safe_not_equal,{class:0,transition:1,transitionConfig:2})}}const Root=Popover,Trigger=PopoverTrigger;function get_each_context$7(s,e,t){const n=s.slice();return n[11]=e[t],n}function create_default_slot_6$1(s){let e,t,n,r;return n=new Chevrons_up_down({props:{class:"ml-2 h-4 w-4 shrink-0 opacity-50"}}),{c(){e=text(s[4]),t=space(),create_component(n.$$.fragment)},l(o){e=claim_text(o,s[4]),t=claim_space(o),claim_component(n.$$.fragment,o)},m(o,a){insert_hydration(o,e,a),insert_hydration(o,t,a),mount_component(n,o,a),r=!0},p(o,a){(!r||a&16)&&set_data(e,o[4])},i(o){r||(transition_in(n.$$.fragment,o),r=!0)},o(o){transition_out(n.$$.fragment,o),r=!1},d(o){o&&(detach(e),detach(t)),destroy_component(n,o)}}}function create_default_slot_5$4(s){let e,t;return e=new Button({props:{builders:[s[14]],variant:"outline",role:"combobox","aria-expanded":s[3],class:cn("justify-between",s[2]),$$slots:{default:[create_default_slot_6$1]},$$scope:{ctx:s}}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p(n,r){const o={};r&16384&&(o.builders=[n[14]]),r&8&&(o["aria-expanded"]=n[3]),r&4&&(o.class=cn("justify-between",n[2])),r&32784&&(o.$$scope={dirty:r,ctx:n}),e.$set(o)},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_default_slot_4$4(s){let e,t,n=s[11].label+"",r,o,a;return e=new Check({props:{class:cn("mr-2 h-4 w-4",s[0]!==s[11].value&&"text-transparent")}}),{c(){create_component(e.$$.fragment),t=space(),r=text(n),o=space()},l(u){claim_component(e.$$.fragment,u),t=claim_space(u),r=claim_text(u,n),o=claim_space(u)},m(u,d){mount_component(e,u,d),insert_hydration(u,t,d),insert_hydration(u,r,d),insert_hydration(u,o,d),a=!0},p(u,d){const h={};d&3&&(h.class=cn("mr-2 h-4 w-4",u[0]!==u[11].value&&"text-transparent")),e.$set(h),(!a||d&2)&&n!==(n=u[11].label+"")&&set_data(r,n)},i(u){a||(transition_in(e.$$.fragment,u),a=!0)},o(u){transition_out(e.$$.fragment,u),a=!1},d(u){u&&(detach(t),detach(r),detach(o)),destroy_component(e,u)}}}function create_each_block$7(s){let e,t;function n(...r){return s[8](s[10],...r)}return e=new Command_item({props:{value:s[11].value,onSelect:n,$$slots:{default:[create_default_slot_4$4]},$$scope:{ctx:s}}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,o){mount_component(e,r,o),t=!0},p(r,o){s=r;const a={};o&2&&(a.value=s[11].value),o&1025&&(a.onSelect=n),o&32771&&(a.$$scope={dirty:o,ctx:s}),e.$set(a)},i(r){t||(transition_in(e.$$.fragment,r),t=!0)},o(r){transition_out(e.$$.fragment,r),t=!1},d(r){destroy_component(e,r)}}}function create_default_slot_3$5(s){let e,t,n=ensure_array_like(s[1]),r=[];for(let a=0;a<n.length;a+=1)r[a]=create_each_block$7(get_each_context$7(s,n,a));const o=a=>transition_out(r[a],1,1,()=>{r[a]=null});return{c(){for(let a=0;a<r.length;a+=1)r[a].c();e=empty()},l(a){for(let u=0;u<r.length;u+=1)r[u].l(a);e=empty()},m(a,u){for(let d=0;d<r.length;d+=1)r[d]&&r[d].m(a,u);insert_hydration(a,e,u),t=!0},p(a,u){if(u&1059){n=ensure_array_like(a[1]);let d;for(d=0;d<n.length;d+=1){const h=get_each_context$7(a,n,d);r[d]?(r[d].p(h,u),transition_in(r[d],1)):(r[d]=create_each_block$7(h),r[d].c(),transition_in(r[d],1),r[d].m(e.parentNode,e))}for(group_outros(),d=n.length;d<r.length;d+=1)o(d);check_outros()}},i(a){if(!t){for(let u=0;u<n.length;u+=1)transition_in(r[u]);t=!0}},o(a){r=r.filter(Boolean);for(let u=0;u<r.length;u+=1)transition_out(r[u]);t=!1},d(a){a&&detach(e),destroy_each(r,a)}}}function create_default_slot_2$5(s){let e,t;return e=new Command_group({props:{$$slots:{default:[create_default_slot_3$5]},$$scope:{ctx:s}}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p(n,r){const o={};r&33795&&(o.$$scope={dirty:r,ctx:n}),e.$set(o)},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_default_slot_1$8(s){let e,t;return e=new Command({props:{$$slots:{default:[create_default_slot_2$5]},$$scope:{ctx:s}}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p(n,r){const o={};r&33795&&(o.$$scope={dirty:r,ctx:n}),e.$set(o)},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_default_slot$i(s){let e,t,n,r;return e=new Trigger({props:{asChild:!0,$$slots:{default:[create_default_slot_5$4,({builder:o})=>({14:o}),({builder:o})=>o?16384:0]},$$scope:{ctx:s}}}),n=new Popover_content({props:{class:cn("p-0",s[2]),$$slots:{default:[create_default_slot_1$8]},$$scope:{ctx:s}}}),{c(){create_component(e.$$.fragment),t=space(),create_component(n.$$.fragment)},l(o){claim_component(e.$$.fragment,o),t=claim_space(o),claim_component(n.$$.fragment,o)},m(o,a){mount_component(e,o,a),insert_hydration(o,t,a),mount_component(n,o,a),r=!0},p(o,a){const u={};a&49180&&(u.$$scope={dirty:a,ctx:o}),e.$set(u);const d={};a&4&&(d.class=cn("p-0",o[2])),a&33795&&(d.$$scope={dirty:a,ctx:o}),n.$set(d)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(n.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(n.$$.fragment,o),r=!1},d(o){o&&detach(t),destroy_component(e,o),destroy_component(n,o)}}}function create_fragment$A(s){let e,t,n;function r(a){s[9](a)}let o={$$slots:{default:[create_default_slot$i,({ids:a})=>({10:a}),({ids:a})=>a?1024:0]},$$scope:{ctx:s}};return s[3]!==void 0&&(o.open=s[3]),e=new Root({props:o}),binding_callbacks.push(()=>bind(e,"open",r)),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,u){mount_component(e,a,u),n=!0},p(a,[u]){const d={};u&33823&&(d.$$scope={dirty:u,ctx:a}),!t&&u&8&&(t=!0,d.open=a[3],add_flush_callback(()=>t=!1)),e.$set(d)},i(a){n||(transition_in(e.$$.fragment,a),n=!0)},o(a){transition_out(e.$$.fragment,a),n=!1},d(a){destroy_component(e,a)}}}function instance$D(s,e,t){let n,{listItems:r=[]}=e,{placeholder:o="Select an item"}=e,a=!1,{value:u=""}=e,{saveValue:d=()=>{}}=e,{width:h="w-[200px]"}=e;function p(c){t(3,a=!1),tick().then(()=>{var f;(f=document.getElementById(c))==null||f.focus()},()=>{})}const l=(c,f)=>{t(0,u=f),p(c.trigger)};function i(c){a=c,t(3,a)}return s.$$set=c=>{"listItems"in c&&t(1,r=c.listItems),"placeholder"in c&&t(6,o=c.placeholder),"value"in c&&t(0,u=c.value),"saveValue"in c&&t(7,d=c.saveValue),"width"in c&&t(2,h=c.width)},s.$$.update=()=>{var c;s.$$.dirty&67&&t(4,n=((c=r.find(f=>f.value===u))==null?void 0:c.label)??o),s.$$.dirty&129&&u&&d(u)},[u,r,h,a,n,p,o,d,l,i]}class Combobox extends SvelteComponent{constructor(e){super(),init(this,e,instance$D,create_fragment$A,safe_not_equal,{listItems:1,placeholder:6,value:0,saveValue:7,width:2})}}function create_fragment$z(s){let e,t,n,r,o,a,u,d;const h=s[5].default,p=create_slot(h,s,s[4],null);let l=[{class:r=cn("w-full p-2 placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",s[1])},s[3],s[2]?{autofocus:!0}:{}],i={};for(let c=0;c<l.length;c+=1)i=assign(i,l[c]);return{c(){e=element("div"),p&&p.c(),t=space(),n=element("input"),this.h()},l(c){e=claim_element(c,"DIV",{class:!0});var f=children(e);p&&p.l(f),t=claim_space(f),n=claim_element(f,"INPUT",{class:!0}),f.forEach(detach),this.h()},h(){set_attributes(n,i),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",s[1]))},m(c,f){insert_hydration(c,e,f),p&&p.m(e,null),append_hydration(e,t),append_hydration(e,n),n.autofocus&&n.focus(),set_input_value(n,s[0]),a=!0,u||(d=[listen(n,"input",s[18]),listen(n,"blur",s[6]),listen(n,"change",s[7]),listen(n,"click",s[8]),listen(n,"focus",s[9]),listen(n,"keydown",s[10]),listen(n,"keypress",s[11]),listen(n,"keyup",s[12]),listen(n,"mouseover",s[13]),listen(n,"mouseenter",s[14]),listen(n,"mouseleave",s[15]),listen(n,"paste",s[16]),listen(n,"input",s[17])],u=!0)},p(c,[f]){p&&p.p&&(!a||f&16)&&update_slot_base(p,h,c,c[4],a?get_slot_changes(h,c[4],f,null):get_all_dirty_from_scope(c[4]),null),set_attributes(n,i=get_spread_update(l,[(!a||f&2&&r!==(r=cn("w-full p-2 placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",c[1])))&&{class:r},f&8&&c[3],f&4&&(c[2]?{autofocus:!0}:{})])),f&1&&n.value!==c[0]&&set_input_value(n,c[0]),(!a||f&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",c[1])))&&attr(e,"class",o)},i(c){a||(transition_in(p,c),a=!0)},o(c){transition_out(p,c),a=!1},d(c){c&&detach(e),p&&p.d(c),u=!1,run_all(d)}}}function instance$C(s,e,t){const n=["class","value","autofocus"];let r=compute_rest_props(e,n),{$$slots:o={},$$scope:a}=e,{class:u=void 0}=e,{value:d=void 0}=e,{autofocus:h=!1}=e;function p(w){bubble.call(this,s,w)}function l(w){bubble.call(this,s,w)}function i(w){bubble.call(this,s,w)}function c(w){bubble.call(this,s,w)}function f(w){bubble.call(this,s,w)}function g(w){bubble.call(this,s,w)}function m(w){bubble.call(this,s,w)}function _(w){bubble.call(this,s,w)}function b(w){bubble.call(this,s,w)}function v(w){bubble.call(this,s,w)}function T(w){bubble.call(this,s,w)}function y(w){bubble.call(this,s,w)}function S(){d=this.value,t(0,d)}return s.$$set=w=>{e=assign(assign({},e),exclude_internal_props(w)),t(3,r=compute_rest_props(e,n)),"class"in w&&t(1,u=w.class),"value"in w&&t(0,d=w.value),"autofocus"in w&&t(2,h=w.autofocus),"$$scope"in w&&t(4,a=w.$$scope)},[d,u,h,r,a,o,p,l,i,c,f,g,m,_,b,v,T,y,S]}class Input extends SvelteComponent{constructor(e){super(),init(this,e,instance$C,create_fragment$z,safe_not_equal,{class:1,value:0,autofocus:2})}}function create_if_block$o(s){let e;return{c(){e=text(s[4])},l(t){e=claim_text(t,s[4])},m(t,n){insert_hydration(t,e,n)},p(t,n){n&16&&set_data(e,t[4])},d(t){t&&detach(e)}}}function create_default_slot$h(s){let e,t,n,r,o,a,u,d,h;t=new SliderRange({props:{class:"absolute h-full bg-primary"}});let p=s[3]&&s[2]>0&&s[2]<s[5].max*100&&create_if_block$o(s);return{c(){e=element("span"),create_component(t.$$.fragment),n=space(),r=element("button"),p&&p.c(),this.h()},l(l){e=claim_element(l,"SPAN",{class:!0});var i=children(e);claim_component(t.$$.fragment,i),i.forEach(detach),n=claim_space(l),r=claim_element(l,"BUTTON",{role:!0,"aria-valuemin":!0,"aria-valuemax":!0,"aria-valuenow":!0,"data-melt-part":!0,tabindex:!0,"data-melt-slider-thumb":!0,class:!0,"data-bits-slider-thumb":!0,style:!0});var c=children(r);p&&p.l(c),c.forEach(detach),this.h()},h(){attr(e,"class","relative h-2 w-full grow overflow-hidden rounded-full bg-white"),attr(r,"role","slider"),attr(r,"aria-valuemin","0"),attr(r,"aria-valuemax","100"),attr(r,"aria-valuenow",s[2]),attr(r,"data-melt-part","thumb"),attr(r,"tabindex","0"),attr(r,"data-melt-slider-thumb",""),attr(r,"class",o=cn("block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{"h-10 w-10":s[3]})),attr(r,"data-bits-slider-thumb",""),attr(r,"style",a=`position: absolute; left: ${s[2]}%; translate: -50%;`)},m(l,i){insert_hydration(l,e,i),mount_component(t,e,null),insert_hydration(l,n,i),insert_hydration(l,r,i),p&&p.m(r,null),u=!0,d||(h=[listen(r,"mouseenter",s[7]),listen(r,"mouseleave",s[8])],d=!0)},p(l,i){l[3]&&l[2]>0&&l[2]<l[5].max*100?p?p.p(l,i):(p=create_if_block$o(l),p.c(),p.m(r,null)):p&&(p.d(1),p=null),(!u||i&4)&&attr(r,"aria-valuenow",l[2]),(!u||i&8&&o!==(o=cn("block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{"h-10 w-10":l[3]})))&&attr(r,"class",o),(!u||i&4&&a!==(a=`position: absolute; left: ${l[2]}%; translate: -50%;`))&&attr(r,"style",a)},i(l){u||(transition_in(t.$$.fragment,l),u=!0)},o(l){transition_out(t.$$.fragment,l),u=!1},d(l){l&&(detach(e),detach(n),detach(r)),destroy_component(t),p&&p.d(),d=!1,run_all(h)}}}function create_fragment$y(s){let e,t,n="0",r,o,a,u,d,h=s[5].max+"",p,l;const i=[{class:cn(" relative flex w-full touch-none select-none items-center",s[1])},s[5]];function c(g){s[9](g)}let f={$$slots:{default:[create_default_slot$h]},$$scope:{ctx:s}};for(let g=0;g<i.length;g+=1)f=assign(f,i[g]);return s[0]!==void 0&&(f.value=s[0]),o=new Slider({props:f}),binding_callbacks.push(()=>bind(o,"value",c)),{c(){e=element("div"),t=element("span"),t.textContent=n,r=space(),create_component(o.$$.fragment),u=space(),d=element("span"),p=text(h),this.h()},l(g){e=claim_element(g,"DIV",{class:!0});var m=children(e);t=claim_element(m,"SPAN",{"data-svelte-h":!0}),get_svelte_dataset(t)!=="svelte-spsr2y"&&(t.textContent=n),r=claim_space(m),claim_component(o.$$.fragment,m),u=claim_space(m),d=claim_element(m,"SPAN",{});var _=children(d);p=claim_text(_,h),_.forEach(detach),m.forEach(detach),this.h()},h(){attr(e,"class","flex gap-4")},m(g,m){insert_hydration(g,e,m),append_hydration(e,t),append_hydration(e,r),mount_component(o,e,null),append_hydration(e,u),append_hydration(e,d),append_hydration(d,p),l=!0},p(g,[m]){const _=m&34?get_spread_update(i,[m&2&&{class:cn(" relative flex w-full touch-none select-none items-center",g[1])},m&32&&get_spread_object(g[5])]):{};m&1084&&(_.$$scope={dirty:m,ctx:g}),!a&&m&1&&(a=!0,_.value=g[0],add_flush_callback(()=>a=!1)),o.$set(_),(!l||m&32)&&h!==(h=g[5].max+"")&&set_data(p,h)},i(g){l||(transition_in(o.$$.fragment,g),l=!0)},o(g){transition_out(o.$$.fragment,g),l=!1},d(g){g&&detach(e),destroy_component(o)}}}function instance$B(s,e,t){let n,r;const o=["class","value","onChange"];let a=compute_rest_props(e,o),{class:u=void 0}=e,{value:d=[0]}=e,h=!1,{onChange:p}=e;const l=()=>t(3,h=!0),i=()=>t(3,h=!1);function c(f){d=f,t(0,d)}return s.$$set=f=>{e=assign(assign({},e),exclude_internal_props(f)),t(5,a=compute_rest_props(e,o)),"class"in f&&t(1,u=f.class),"value"in f&&t(0,d=f.value),"onChange"in f&&t(6,p=f.onChange)},s.$$.update=()=>{t(2,n=Math.round(((d==null?void 0:d[0])||0)/a.max*100)),s.$$.dirty&4&&t(4,r=`${n/100}`),s.$$.dirty&65&&p(d)},[d,u,n,h,r,a,p,l,i,c]}class SliderRoot extends SvelteComponent{constructor(e){super(),init(this,e,instance$B,create_fragment$y,safe_not_equal,{class:1,value:0,onChange:6})}}function create_default_slot$g(s){let e,t;return e=new SwitchThumb({props:{class:cn("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p:noop,i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_fragment$x(s){let e,t,n;const r=[{class:cn("peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",s[1])},s[2]];function o(u){s[4](u)}let a={$$slots:{default:[create_default_slot$g]},$$scope:{ctx:s}};for(let u=0;u<r.length;u+=1)a=assign(a,r[u]);return s[0]!==void 0&&(a.checked=s[0]),e=new Switch({props:a}),binding_callbacks.push(()=>bind(e,"checked",o)),{c(){create_component(e.$$.fragment)},l(u){claim_component(e.$$.fragment,u)},m(u,d){mount_component(e,u,d),n=!0},p(u,[d]){const h=d&6?get_spread_update(r,[d&2&&{class:cn("peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",u[1])},d&4&&get_spread_object(u[2])]):{};d&32&&(h.$$scope={dirty:d,ctx:u}),!t&&d&1&&(t=!0,h.checked=u[0],add_flush_callback(()=>t=!1)),e.$set(h)},i(u){n||(transition_in(e.$$.fragment,u),n=!0)},o(u){transition_out(e.$$.fragment,u),n=!1},d(u){destroy_component(e,u)}}}function instance$A(s,e,t){const n=["class","checked","onChange"];let r=compute_rest_props(e,n),{class:o=void 0}=e,{checked:a=void 0}=e,{onChange:u}=e;function d(h){a=h,t(0,a)}return s.$$set=h=>{e=assign(assign({},e),exclude_internal_props(h)),t(2,r=compute_rest_props(e,n)),"class"in h&&t(1,o=h.class),"checked"in h&&t(0,a=h.checked),"onChange"in h&&t(3,u=h.onChange)},s.$$.update=()=>{s.$$.dirty&9&&u(a)},[a,o,r,u,d]}class SwitchRoot extends SvelteComponent{constructor(e){super(),init(this,e,instance$A,create_fragment$x,safe_not_equal,{class:1,checked:0,onChange:3})}}const prerender=!1,ssr=!1,_page=Object.freeze(Object.defineProperty({__proto__:null,prerender,ssr},Symbol.toStringTag,{value:"Module"}));function create_fragment$w(s){let e,t,n,r,o,a;return{c(){e=svg_element("svg"),t=svg_element("g"),n=svg_element("rect"),r=svg_element("rect"),o=svg_element("rect"),a=svg_element("rect"),this.h()},l(u){e=claim_svg_element(u,"svg",{xmlns:!0,version:!0,viewBox:!0,class:!0,fill:!0});var d=children(e);t=claim_svg_element(d,"g",{"stroke-width":!0,fill:!0,"stroke-linecap":!0});var h=children(t);n=claim_svg_element(h,"rect",{fill:!0,x:!0,y:!0,transform:!0,width:!0,height:!0,rx:!0}),children(n).forEach(detach),r=claim_svg_element(h,"rect",{fill:!0,x:!0,y:!0,width:!0,height:!0,rx:!0}),children(r).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),d.forEach(detach),this.h()},h(){attr(n,"fill","currentColor"),attr(n,"x","-5.92"),attr(n,"y","-4.01"),attr(n,"transform","translate(27.13,84.71) rotate(43.3)"),attr(n,"width","11.84"),attr(n,"height","8.02"),attr(n,"rx","0.52"),attr(r,"fill","currentColor"),attr(r,"x","15.28"),attr(r,"y","95.80"),attr(r,"width","14.22"),attr(r,"height","7.96"),attr(r,"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(t,"stroke-width","2.00"),attr(t,"fill","none"),attr(t,"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(u,d){insert_hydration(u,e,d),append_hydration(e,t),append_hydration(t,n),append_hydration(t,r),append_hydration(t,o),append_hydration(t,a)},p:noop,i:noop,o:noop,d(u){u&&detach(e)}}}class MagicIcon extends SvelteComponent{constructor(e){super(),init(this,e,null,create_fragment$w,safe_not_equal,{})}}const panTool={name:"Move image",type:"PAN",cursor:"move"},rectangleTool={name:"Create a bounding box",type:"RECTANGLE",cursor:"crosshair",isSmart:!1},polygonTool={name:"Create a polygon",type:"POLYGON",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},smartRectangleTool={name:"Rectangle selection",type:"RECTANGLE",cursor:"crosshair",isSmart:!0};function maskDataToFortranArrayToRle(s,e,t){const n=[];let r=0,o=!1;for(let a=0;a<t;a++)for(let u=0;u<e;u++){const d=a+u*t;d<s.length&&(s[d]>0!==o?(n.push(r),o=!o,r=1):r++)}return r>0&&n.push(r),n}function splitPointKey(s){return s.split(" ").map(e=>parseInt(e))}function getLineBreakpoints(s,e){const t=[],n={line:-1,points:[]};let r=0;const o=()=>{n.points.length>0&&(t.push({line:n.line,points:n.points}),n.points=[])};for(let a=1;a<s.length;a+=2){r+=s[a-1];const u=r%e,d=Math.floor(r/e);r+=s[a];const h=r%e,p=Math.floor(r/e);if(n.line!==d&&(o(),n.line=d),d===p){n.points.push(u,h);continue}n.points.push(u,e),o(),n.line=p;for(let l=d+1;l<p;l++)t.push({line:l,points:[0,e]});h>0&&n.points.push(0,h)}return o(),t}function generatePolygonSegments(s,e){const t=getLineBreakpoints(s,e);if(t.length===0)return new Map;const n=new Map;let r=-1,o=[];const a=new Map,u=(i,c)=>{const f=`${i.x} ${i.y}`,g=`${c.x} ${c.y}`;n.has(f)||n.set(f,new Set),n.get(f).add(g),n.has(g)||n.set(g,new Set),n.get(g).add(f)},d=(i,c)=>{c!==a.get(i)&&(u({x:a.get(i),y:i},{x:c,y:i}),a.delete(i))},h=(i,c,f,g)=>{if(c===g){a.has(c)||a.set(c,i);return}let m=!1;const _=Math.max(i,f);a.has(c)&&(d(c,_),m=!0),a.has(g)&&(d(g,_),m=!0),m?u({x:_,y:c},{x:_,y:g}):u({x:i,y:c},{x:f,y:g})},p=(i,c)=>{for(const f of c)h(i,f,i+1,f);for(let f=1;f<c.length;f+=2)h(i+1,c[f-1],i+1,c[f])};for(const{line:i,points:c}of t){i!==r+1&&(p(r,o),r=i-1,o=[]);let f=o.length&&o[0]<=c[0]?r:i,g=f===r?o[0]:c[0],m=f===r?1:0,_=f===r?0:1,b=!0;for(;m<o.length||_<c.length;){let v,T;m===o.length||c[_]<o[m]?(v=i,T=c[_],_++):(v=r,T=o[m],m++),b&&(f===r&&v===r?(h(r,g,i,g),h(r,T,i,T),h(i,g,i,T)):h(f,g,v,T)),b=!b,f=v,g=T}r=i,o=c}return p(r,o),new Map([...n].sort((i,c)=>{const[f,g]=splitPointKey(i[0]),[m,_]=splitPointKey(c[0]);return f===m?g-_:f-m}))}function convertSegmentsToSVG(s){const e=[];for(;s.size;){let[a,u]=s.entries().next().value;const d=a,h=[splitPointKey(d)];let p=null;for(;p!==d;){p=u.values().next().value,h.push(splitPointKey(p)),u.delete(p),u.size===0&&s.delete(a);const l=s.get(p);if(l.delete(a),l.size===0){s.delete(p);break}else a=p,u=l}e.push(h)}const t=[],n=[],o=document.createElement("canvas").getContext("2d");for(const a of e){let u=!1;const[d,h]=a[0];for(const c of t)o.isPointInPath(c,d+.5,h+.5)&&(u=!u);u&&a.reverse();const p=a.slice(1).map(([c,f])=>`${c} ${f}`).join(" "),l=`M${a[0][0]} ${a[0][1]} L`+p;n.push(l);const i=new Path2D(l);o.fill(i),t.push(i)}return 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 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(s){const e=new Uint8Array(s);if(e[6]!=1)throw"Only npy version 1 is supported";const t=e[8]+e[9]*256,n=10+t,r=JSON.parse(new TextDecoder("utf-8").decode(e.slice(10,10+t)).replace(/'/g,'"').replace("False","false").replace("(","[").replace(/,*\),*/g,"]"));if(r.fortan_order)throw"Fortran-contiguous array data are not supported";const o=dtypes[r.descr];return{data:new o.arrayConstructor(e.slice(n).buffer),shape:r.shape,dtype:o.name}}function b64ToBuffer(s){const e=atob(s),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t.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(s,e){module.exports=e()})(self,()=>(()=>{var __webpack_modules__={5716:(s,e,t)=>{e.R=void 0;const n=t(6027),r=t(1723);e.R=new class{async init(){}async createSessionHandler(o,a){const u=new n.Session(a);return await u.loadModel(o),new r.OnnxjsSessionHandler(u)}}},2818:(s,e,t)=>{e.c8=e.rX=void 0;const n=t(2235),r=t(5381),o=t(9544),a=t(6640);e.rX=()=>{if((typeof n.env.wasm.initTimeout!="number"||n.env.wasm.initTimeout<0)&&(n.env.wasm.initTimeout=0),typeof n.env.wasm.simd!="boolean"&&(n.env.wasm.simd=!0),typeof n.env.wasm.proxy!="boolean"&&(n.env.wasm.proxy=!1),typeof n.env.wasm.numThreads!="number"||!Number.isInteger(n.env.wasm.numThreads)||n.env.wasm.numThreads<=0){const u=typeof navigator>"u"?(0,r.cpus)().length:navigator.hardwareConcurrency;n.env.wasm.numThreads=Math.min(4,Math.ceil((u||1)/2))}},e.c8=new class{async init(){(0,e.rX)(),await(0,o.initializeWebAssemblyInstance)()}async createSessionHandler(u,d){const h=new a.OnnxruntimeWebAssemblySessionHandler;return await h.loadModel(u,d),Promise.resolve(h)}}},1057:function(s,e,t){var n=this&&this.__createBinding||(Object.create?function(u,d,h,p){p===void 0&&(p=h);var l=Object.getOwnPropertyDescriptor(d,h);l&&!("get"in l?!d.__esModule:l.writable||l.configurable)||(l={enumerable:!0,get:function(){return d[h]}}),Object.defineProperty(u,p,l)}:function(u,d,h,p){p===void 0&&(p=h),u[p]=d[h]}),r=this&&this.__exportStar||function(u,d){for(var h in u)h==="default"||Object.prototype.hasOwnProperty.call(d,h)||n(d,u,h)};Object.defineProperty(e,"__esModule",{value:!0}),r(t(2235),e);const o=t(2235),a=t(8408);{const u=t(5716).R;(0,o.registerBackend)("webgl",u,-10)}{const u=t(2818).c8;(0,o.registerBackend)("cpu",u,10),(0,o.registerBackend)("wasm",u,10),(0,o.registerBackend)("xnnpack",u,9),(0,o.registerBackend)("webnn",u,9)}o.env.versions.web=a.version},4910:(s,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createAttributeWithCacheKey=void 0;class t{constructor(r){Object.assign(this,r)}get cacheKey(){return this._cacheKey||(this._cacheKey=Object.getOwnPropertyNames(this).sort().map(r=>`${this[r]}`).join(";")),this._cacheKey}}e.createAttributeWithCacheKey=n=>new t(n)},6874:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Attribute=void 0;const n=t(5127),r=t(2446),o=t(9240),a=t(7273);var u=n.onnxruntime.experimental.fbs;class d{constructor(p){if(this._attributes=new Map,p!=null){for(const l of p)l instanceof r.onnx.AttributeProto?this._attributes.set(l.name,[d.getValue(l),d.getType(l)]):l instanceof u.Attribute&&this._attributes.set(l.name(),[d.getValue(l),d.getType(l)]);if(this._attributes.size<p.length)throw new Error("duplicated attribute names")}}set(p,l,i){this._attributes.set(p,[i,l])}delete(p){this._attributes.delete(p)}getFloat(p,l){return this.get(p,"float",l)}getInt(p,l){return this.get(p,"int",l)}getString(p,l){return this.get(p,"string",l)}getTensor(p,l){return this.get(p,"tensor",l)}getFloats(p,l){return this.get(p,"floats",l)}getInts(p,l){return this.get(p,"ints",l)}getStrings(p,l){return this.get(p,"strings",l)}getTensors(p,l){return this.get(p,"tensors",l)}get(p,l,i){const c=this._attributes.get(p);if(c===void 0){if(i!==void 0)return i;throw new Error(`required attribute not found: ${p}`)}if(c[1]!==l)throw new Error(`type mismatch: expected ${l} but got ${c[1]}`);return c[0]}static getType(p){const l=p instanceof r.onnx.AttributeProto?p.type:p.type();switch(l){case r.onnx.AttributeProto.AttributeType.FLOAT:return"float";case r.onnx.AttributeProto.AttributeType.INT:return"int";case r.onnx.AttributeProto.AttributeType.STRING:return"string";case r.onnx.AttributeProto.AttributeType.TENSOR:return"tensor";case r.onnx.AttributeProto.AttributeType.FLOATS:return"floats";case r.onnx.AttributeProto.AttributeType.INTS:return"ints";case r.onnx.AttributeProto.AttributeType.STRINGS:return"strings";case r.onnx.AttributeProto.AttributeType.TENSORS:return"tensors";default:throw new Error(`attribute type is not supported yet: ${r.onnx.AttributeProto.AttributeType[l]}`)}}static getValue(p){const l=p instanceof r.onnx.AttributeProto?p.type:p.type();if(l===r.onnx.AttributeProto.AttributeType.GRAPH||l===r.onnx.AttributeProto.AttributeType.GRAPHS)throw new Error("graph attribute is not supported yet");const i=this.getValueNoCheck(p);if(l===r.onnx.AttributeProto.AttributeType.INT&&a.LongUtil.isLong(i))return a.LongUtil.longToNumber(i);if(l===r.onnx.AttributeProto.AttributeType.INTS){const c=i,f=new Array(c.length);for(let g=0;g<c.length;g++){const m=c[g];f[g]=a.LongUtil.longToNumber(m)}return f}if(l===r.onnx.AttributeProto.AttributeType.TENSOR)return p instanceof r.onnx.AttributeProto?o.Tensor.fromProto(i):o.Tensor.fromOrtTensor(i);if(l===r.onnx.AttributeProto.AttributeType.TENSORS){if(p instanceof r.onnx.AttributeProto)return i.map(c=>o.Tensor.fromProto(c));if(p instanceof u.Attribute)return i.map(c=>o.Tensor.fromOrtTensor(c))}if(l===r.onnx.AttributeProto.AttributeType.STRING&&p instanceof r.onnx.AttributeProto){const c=i;return(0,a.decodeUtf8String)(c)}return l===r.onnx.AttributeProto.AttributeType.STRINGS&&p instanceof r.onnx.AttributeProto?i.map(a.decodeUtf8String):i}static getValueNoCheck(p){return p instanceof r.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(p):this.getValueNoCheckFromOrtFormat(p)}static getValueNoCheckFromOnnxFormat(p){switch(p.type){case r.onnx.AttributeProto.AttributeType.FLOAT:return p.f;case r.onnx.AttributeProto.AttributeType.INT:return p.i;case r.onnx.AttributeProto.AttributeType.STRING:return p.s;case r.onnx.AttributeProto.AttributeType.TENSOR:return p.t;case r.onnx.AttributeProto.AttributeType.GRAPH:return p.g;case r.onnx.AttributeProto.AttributeType.FLOATS:return p.floats;case r.onnx.AttributeProto.AttributeType.INTS:return p.ints;case r.onnx.AttributeProto.AttributeType.STRINGS:return p.strings;case r.onnx.AttributeProto.AttributeType.TENSORS:return p.tensors;case r.onnx.AttributeProto.AttributeType.GRAPHS:return p.graphs;default:throw new Error(`unsupported attribute type: ${r.onnx.AttributeProto.AttributeType[p.type]}`)}}static getValueNoCheckFromOrtFormat(p){switch(p.type()){case u.AttributeType.FLOAT:return p.f();case u.AttributeType.INT:return p.i();case u.AttributeType.STRING:return p.s();case u.AttributeType.TENSOR:return p.t();case u.AttributeType.GRAPH:return p.g();case u.AttributeType.FLOATS:return p.floatsArray();case u.AttributeType.INTS:{const l=[];for(let i=0;i<p.intsLength();i++)l.push(p.ints(i));return l}case u.AttributeType.STRINGS:{const l=[];for(let i=0;i<p.stringsLength();i++)l.push(p.strings(i));return l}case u.AttributeType.TENSORS:{const l=[];for(let i=0;i<p.tensorsLength();i++)l.push(p.tensors(i));return l}default:throw new Error(`unsupported attribute type: ${u.AttributeType[p.type()]}`)}}}e.Attribute=d},1975:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveBackend=e.backend=void 0;const n=t(4418),r=new Map;async function o(a){const u=e.backend;if(u[a]!==void 0&&function(d){const h=d;return"initialize"in h&&typeof h.initialize=="function"&&"createSessionHandler"in h&&typeof h.createSessionHandler=="function"&&"dispose"in h&&typeof h.dispose=="function"}(u[a])){const d=u[a];let h=d.initialize();if(typeof h=="object"&&"then"in h&&(h=await h),h)return r.set(a,d),d}}e.backend={webgl:new n.WebGLBackend},e.resolveBackend=async function a(u){if(!u)return a(["webgl"]);{const d=typeof u=="string"?[u]:u;for(const h of d){const p=r.get(h);if(p)return p;const l=await o(h);if(l)return l}}throw new Error("no available backend to use")}},4418:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLBackend=void 0;const n=t(2235),r=t(1315),o=t(2171),a=t(3389);e.WebGLBackend=class{get contextId(){return n.env.webgl.contextId}set contextId(u){n.env.webgl.contextId=u}get matmulMaxBatchSize(){return n.env.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(u){n.env.webgl.matmulMaxBatchSize=u}get textureCacheMode(){return n.env.webgl.textureCacheMode}set textureCacheMode(u){n.env.webgl.textureCacheMode=u}get pack(){return n.env.webgl.pack}set pack(u){n.env.webgl.pack=u}get async(){return n.env.webgl.async}set async(u){n.env.webgl.async=u}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),r.Logger.setWithEnv(n.env),r.Logger.verbose("WebGLBackend",`Created WebGLContext: ${typeof this.glContext} with matmulMaxBatchSize: ${this.matmulMaxBatchSize}; textureCacheMode: ${this.textureCacheMode}; pack: ${this.pack}; async: ${this.async}.`),!0}catch(u){return r.Logger.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${u}`),!1}}createSessionHandler(u){return new o.WebGLSessionHandler(this,u)}dispose(){this.glContext.dispose()}}},6859:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CoordsGlslLib=void 0;const n=t(7273),r=t(1997),o=t(6757),a=t(7618),u=t(432);class d extends r.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 r.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 r.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 l=p.unpackedShape,i=[p.width,p.height],c={},f="getOutputCoords";switch(l.length){case 0:c[f]=this.getOutputScalarCoords();break;case 1:c[f]=this.getOutputPacked1DCoords(l,i);break;case 2:c[f]=this.getOutputPacked2DCoords(l,i);break;case 3:c[f]=this.getOutputPacked3DCoords(l,i);break;default:c[f]=this.getOutputPackedNDCoords(l,i)}const g=`
      void setOutput(vec4 val) {
        ${(0,o.getGlsl)(this.context.glContext.version).output} = val;
      }
    `;return c.floatTextureSetRGBA=new r.GlslLibRoutine(g),c}getUnpackedOutputSamplingSnippet(p){const l=p.unpackedShape,i=[p.width,p.height],c={},f="getOutputCoords";switch(l.length){case 0:c[f]=this.getOutputScalarCoords();break;case 1:c[f]=this.getOutputUnpacked1DCoords(l,i);break;case 2:c[f]=this.getOutputUnpacked2DCoords(l,i);break;case 3:c[f]=this.getOutputUnpacked3DCoords(l,i);break;case 4:c[f]=this.getOutputUnpacked4DCoords(l,i);break;case 5:c[f]=this.getOutputUnpacked5DCoords(l,i);break;case 6:c[f]=this.getOutputUnpacked6DCoords(l,i);break;default:throw new Error(`Unsupported output dimensionality: ${l.length}`)}const g=`
        void setOutput(float val) {
          ${(0,o.getGlsl)(this.context.glContext.version).output} = vec4(val, 0, 0, 0);
        }
    `;return c.floatTextureSetR=new r.GlslLibRoutine(g),c}getOutputScalarCoords(){return new r.GlslLibRoutine(`
      int getOutputCoords() {
        return 0;
      }
    `)}getOutputPacked1DCoords(p,l){const i=l;let c="";return i[0]===1?(c=`
          int getOutputCoords() {
            return 2 * int(TexCoords.y * ${i[1]}.0);
          }
        `,new r.GlslLibRoutine(c)):i[1]===1?(c=`
          int getOutputCoords() {
            return 2 * int(TexCoords.x * ${i[0]}.0);
          }
        `,new r.GlslLibRoutine(c)):(c=`
        int getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                 vec2(${i[0]}, ${i[1]}));
          return 2 * (resTexRC.y * ${i[0]} + resTexRC.x);
        }
      `,new r.GlslLibRoutine(c))}getOutputPacked2DCoords(p,l){let i="";if(n.ArrayUtil.arraysEqual(p,l))return i=`
        ivec2 getOutputCoords() {
          return 2 * ivec2(TexCoords.xy * vec2(${l[0]}, ${l[1]}));
        }
      `,new r.GlslLibRoutine(i);const c=l,f=Math.ceil(p[1]/2);return i=`
        ivec2 getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${c[0]}, ${c[1]}));

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

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

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

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

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

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

        ${m}

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

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

        return ivec${p.length}(${_});
      }
    `;return new r.GlslLibRoutine(b)}getOutputUnpacked1DCoords(p,l){const i=`
        int getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${l[0]}, ${l[1]}));
          return resTexRC.y * ${l[0]} + resTexRC.x;
        }
      `;return new r.GlslLibRoutine(i)}getOutputUnpacked2DCoords(p,l){const i=`
        ivec2 getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${l[0]}, ${l[1]}));
          int index = resTexRC.y * ${l[0]} + resTexRC.x;
          int r = index / ${p[1]};
          int c = index - r * ${p[1]};
          return ivec2(r, c);
        }
      `;return new r.GlslLibRoutine(i)}getOutputUnpacked3DCoords(p,l){let i="";const c=p.length;let f=null;c<2&&(f=[]),f=new Array(c-1),f[c-2]=p[c-1];for(let _=c-3;_>=0;--_)f[_]=f[_+1]*p[_+1];const g=["r","c","d"],m=f.map((_,b)=>`int ${g[b]} = index / ${_}; ${b===f.length-1?`int ${g[b+1]} = index - ${g[b]} * ${_}`:`index -= ${g[b]} * ${_}`};`).join("");return i=`
        ivec3 getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${l[0]}, ${l[1]}));
          int index = resTexRC.y * ${l[0]} + resTexRC.x;
          ${m}
          return ivec3(r, c, d);
        }
      `,new r.GlslLibRoutine(i)}getOutputUnpacked4DCoords(p,l){let i="";const c=p.length;let f=null;c<2&&(f=[]),f=new Array(c-1),f[c-2]=p[c-1];for(let _=c-3;_>=0;--_)f[_]=f[_+1]*p[_+1];const g=["r","c","d","d2"],m=f.map((_,b)=>`int ${g[b]} = index / ${_}; ${b===f.length-1?`int ${g[b+1]} = index - ${g[b]} * ${_}`:`index -= ${g[b]} * ${_}`};`).join("");return i=`
      ivec4 getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${l[0]}, ${l[1]}));
          int index = resTexRC.y * ${l[0]} + resTexRC.x;
          ${m}
          return ivec4(r, c, d, d2);
        }
      `,new r.GlslLibRoutine(i)}getOutputUnpacked5DCoords(p,l){let i="";const c=p.length;let f=null;c<2&&(f=[]),f=new Array(c-1),f[c-2]=p[c-1];for(let _=c-3;_>=0;--_)f[_]=f[_+1]*p[_+1];const g=["r","c","d","d2","d3"],m=f.map((_,b)=>`int ${g[b]} = index / ${_}; ${b===f.length-1?`int ${g[b+1]} = index - ${g[b]} * ${_}`:`index -= ${g[b]} * ${_}`};`).join("");return i=`
      ivec5 getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${l[0]}, ${l[1]}));
          int index = resTexRC.y * ${l[0]} + resTexRC.x;
          ${m}
          return ivec5(r, c, d, d2, d3);
        }
      `,new r.GlslLibRoutine(i)}getOutputUnpacked6DCoords(p,l){let i="";const c=p.length;let f=null;c<2&&(f=[]),f=new Array(c-1),f[c-2]=p[c-1];for(let _=c-3;_>=0;--_)f[_]=f[_+1]*p[_+1];const g=["r","c","d","d2","d3","d4"],m=f.map((_,b)=>`int ${g[b]} = index / ${_}; ${b===f.length-1?`int ${g[b+1]} = index - ${g[b]} * ${_}`:`index -= ${g[b]} * ${_}`};`).join("");return i=`
     ivec6 getOutputCoords() {
         ivec2 resTexRC = ivec2(TexCoords.xy *
                               vec2(${l[0]}, ${l[1]}));
         int index = resTexRC.y * ${l[0]} + resTexRC.x;
         ${m}
         return ivec6(r, c, d, d2, d3, d4);
       }
     `,new r.GlslLibRoutine(i)}getCommonUtilFuncs(){const p={};let l="uvFromFlat";p[l]=new r.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);
    }
    `),l="packedUVfrom1D",p[l]=new r.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);
      }
      `),l="packedUVfrom2D",p[l]=new r.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);
      }
      `),l="packedUVfrom3D",p[l]=new r.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);
      }
      `),l="sampleTexture";const i=(0,o.getGlsl)(this.context.glContext.version);return p[l]=new r.GlslLibRoutine(`
        float sampleTexture(sampler2D textureSampler, vec2 uv) {
            return ${i.texture2D}(textureSampler, uv).r;
        }`),p}getInputsSamplingSnippets(){const p={},l=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((i,c)=>{const f=this.context.inputTextureLayouts[c],g=(0,u.generateShaderFuncNameFromInputSamplerName)(i);f.isPacked?p[g]=this.getPackedSamplerFromInput(g,i,f):p[g]=this.getUnpackedSamplerFromInput(g,i,f);const m=(0,u.generateShaderFuncNameFromInputSamplerNameAtOutCoords)(i);f.unpackedShape.length<=l.unpackedShape.length&&(f.isPacked?p[m]=this.getPackedSamplerAtOutputCoords(m,f,l,i):p[m]=this.getUnpackedSamplerAtOutputCoords(m,f,l,i))}),p}getPackedSamplerAtOutputCoords(p,l,i,c){const f=l.unpackedShape,g=i.unpackedShape,m=c,_=(0,u.generateShaderFuncNameFromInputSamplerName)(m),b=f.length,v=g.length,T=n.BroadcastUtil.getBroadcastDims(f,g),y=(0,u.getCoordsDataType)(v),S=v-b;let w;const k=(0,u.getGlChannels)();w=b===0?"":v<2&&T.length>=1?"coords = 0;":T.map($=>`coords.${k[$+S]} = 0;`).join(`
`);let P="";P=v<2&&b>0?"coords":f.map(($,x)=>`coords.${k[x+S]}`).join(", ");let I="return outputValue;";const F=n.ShapeUtil.size(f)===1,C=n.ShapeUtil.size(g)===1;if(b!==1||F||C){if(F&&!C)I=v===1?`
          return vec4(outputValue.x, outputValue.x, 0., 0.);
        `:`
          return vec4(outputValue.x);
        `;else if(T.length){const $=b-2,x=b-1;T.indexOf($)>-1&&T.indexOf(x)>-1?I="return vec4(outputValue.x);":T.indexOf($)>-1?I="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":T.indexOf(x)>-1&&(I="return vec4(outputValue.xx, outputValue.zz);")}}else I=`
        return vec4(outputValue.xy, outputValue.xy);
      `;const E=`
      vec4 ${p}() {
        ${y} coords = getOutputCoords();
        
        int lastDim = coords.${k[v-1]};
        coords.${k[v-1]} = coords.${k[v-2]};
        coords.${k[v-2]} = lastDim;
      
        ${w}
        vec4 outputValue = ${_}(${P});
        ${I}
      }
    `;return new r.GlslLibRoutine(E,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(p,l,i,c){const f=[i.width,i.height],g=[l.width,l.height],m=l.unpackedShape.length,_=i.unpackedShape.length,b=l.unpackedShape,v=i.unpackedShape,T=(0,u.generateShaderFuncNameFromInputSamplerName)(c);if(m===_&&n.ArrayUtil.arraysEqual(g,f)){const C=`
          float ${p}() {
            return sampleTexture(${c}, TexCoords);
          }
        `;return new r.GlslLibRoutine(C,["coordinates.sampleTexture"])}const y=(0,u.getCoordsDataType)(_),S=n.BroadcastUtil.getBroadcastDims(b,v),w=_-m;let k;const P=(0,u.getGlChannels)();k=m===0?"":_<2&&S.length>=1?"coords = 0;":S.map(C=>`coords.${P[C+w]} = 0;`).join(`
`);let I="";I=_<2&&m>0?"coords":l.unpackedShape.map((C,E)=>`coords.${P[E+w]}`).join(", ");const F=`
        float ${p}() {
          ${y} coords = getOutputCoords();
          ${k}
          return ${T}(${I});
        }
      `;return new r.GlslLibRoutine(F,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(p,l,i){switch(i.unpackedShape.length){case 0:return this.getPackedSamplerScalar(p,l);case 1:return this.getPackedSampler1D(p,l,i);case 2:return this.getPackedSampler2D(p,l,i);case 3:return this.getPackedSampler3D(p,l,i);default:return this.getPackedSamplerND(p,l,i)}}getUnpackedSamplerFromInput(p,l,i){const c=i.unpackedShape;switch(c.length){case 0:return this.getUnpackedSamplerScalar(p,l,i);case 1:return this.getUnpackedSampler1D(p,l,i);case 2:return this.getUnpackedSampler2D(p,l,i);case 3:return this.getUnpackedSampler3D(p,l,i);case 4:return this.getUnpackedSampler4D(p,l,i);case 5:return this.getUnpackedSampler5D(p,l,i);case 6:return this.getUnpackedSampler6D(p,l,i);default:throw new Error(`Unsupported dimension ${c.length}-D`)}}getPackedSamplerScalar(p,l){const i=`
          vec4 ${p}() {
            return ${(0,o.getGlsl)(this.context.glContext.version).texture2D}(${l}, halfCR);
          }
        `;return new r.GlslLibRoutine(i)}getPackedSampler1D(p,l,i){const c=[i.width,i.height],f=[c[1],c[0]],g=(0,o.getGlsl)(this.context.glContext.version),m=`vec4 ${p}(int index) {
      vec2 uv = packedUVfrom1D(
      ${f[0]}, ${f[1]}, index);
      return ${g.texture2D}(${l}, uv);
    }`;return new r.GlslLibRoutine(m,["coordinates.packedUVfrom1D"])}getPackedSampler2D(p,l,i){const c=i.unpackedShape,f=[i.width,i.height],g=(0,o.getGlsl)(this.context.glContext.version),m=f[0],_=f[1];if(f!=null&&n.ArrayUtil.arraysEqual(c,f)){const y=`vec4 ${p}(int row, int col) {
        vec2 uv = (vec2(col, row) + halfCR) / vec2(${_}.0, ${m}.0);
        return ${g.texture2D}(${l}, uv);
      }`;return new r.GlslLibRoutine(y)}const b=f,v=Math.ceil(c[1]/2),T=`vec4 ${p}(int row, int col) {
      vec2 uv = packedUVfrom2D(${b[1]}, ${b[0]}, ${v}, row, col);
      return ${g.texture2D}(${l}, uv);
    }`;return new r.GlslLibRoutine(T,["coordinates.packedUVfrom2D"])}getPackedSampler3D(p,l,i){const c=i.unpackedShape,f=[i.width,i.height],g=[f[0],f[1]],m=(0,o.getGlsl)(this.context.glContext.version);if(c[0]===1){const y=c.slice(1),S=[1,2],w=(0,u.squeezeInputShape)(c,y),k=["b","row","col"],P=JSON.parse(JSON.stringify(i));P.unpackedShape=w;const I=this.getPackedSamplerFromInput(p,l,P),F=`${I.routineBody}
      vec4 ${p}(int b, int row, int col) {
        return ${p}(${(0,u.getSqueezedParams)(k,S)});
      } `;return new r.GlslLibRoutine(F,I.dependencies)}const _=g[0],b=g[1],v=Math.ceil(c[2]/2),T=`vec4 ${p}(int b, int row, int col) {
      vec2 uv = packedUVfrom3D(
        ${b}, ${_}, ${v*Math.ceil(c[1]/2)}, ${v}, b, row, col);
      return ${m.texture2D}(${l}, uv);}`;return new r.GlslLibRoutine(T,["coordinates.packedUVfrom3D"])}getPackedSamplerND(p,l,i){const c=i.unpackedShape,f=c.length,g=[i.width,i.height],m=(0,o.getGlsl)(this.context.glContext.version),_=[g[0],g[1]],b=_[1],v=_[0],T=Math.ceil(c[f-1]/2);let y=T*Math.ceil(c[f-2]/2),S="int b, int row, int col",w=`b * ${y} + (row / 2) * ${T} + (col / 2)`;for(let P=2;P<f-1;P++)S=`int b${P}, `+S,y*=c[f-P-1],w=`b${P} * ${y} + `+w;const k=`vec4 ${p}(${S}) {
      int index = ${w};
      int texR = index / ${v};
      int texC = index - texR * ${v};
      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${v}, ${b});
      return ${m.texture2D}(${l}, uv);
    }`;return new r.GlslLibRoutine(k)}getUnpackedSamplerScalar(p,l,i){const[c,f]=[i.width,i.height];if(c===1&&f===1){const m=`
          float ${p}() {
            return sampleTexture(${l}, halfCR);
          }
        `;return new r.GlslLibRoutine(m,["coordinates.sampleTexture"])}const g=`
        float ${p}() {
          int offset_${l} = coordsToOffset(TexCoords, ${c}, ${f});
          vec2 uv = uvFromFlat(${c}, ${f}, offset_${l});
          return sampleTexture(${l}, uv);
        }
      `;return new r.GlslLibRoutine(g,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler1D(p,l,i){const c=i.width,f=i.height;if(f===1&&c===1){const m=`
        float ${p}(int index) {
          return sampleTexture(${l}, halfCR);
        }
      `;return new r.GlslLibRoutine(m,["coordinates.sampleTexture"])}if(f===1){const m=`
          float ${p}(int index) {
            vec2 uv = vec2((float(index) + 0.5) / ${c}.0, 0.5);
            return sampleTexture(${l}, uv);
          }
        `;return new r.GlslLibRoutine(m,["coordinates.sampleTexture"])}if(c===1){const m=`
          float ${p}(int index) {
            vec2 uv = vec2(0.5, (float(index) + 0.5) / ${f}.0);
            return sampleTexture(${l}, uv);
          }
        `;return new r.GlslLibRoutine(m,["coordinates.sampleTexture"])}const g=`
        float ${p}(int index) {
          vec2 uv = uvFromFlat(${c}, ${f}, index);
          return sampleTexture(${l}, uv);
        }
      `;return new r.GlslLibRoutine(g,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler2D(p,l,i){const c=i.unpackedShape,f=[i.height,i.width];if(f!=null&&n.ArrayUtil.arraysEqual(c,f)){const y=`
          float ${p}(int row, int col) {
            vec2 uv = (vec2(row, col) + halfCR) / vec2(${f[1]}.0, ${f[0]}.0);
            return sampleTexture(${l}, uv);
          }
        `;return new r.GlslLibRoutine(y,["coordinates.sampleTexture"])}const{newShape:g,keptDims:m}=(0,a.squeezeShape)(c),_=g;if(_.length<c.length){const y=(0,u.squeezeInputShape)(c,_),S=JSON.parse(JSON.stringify(i));S.unpackedShape=y;const w=["col","row"],k=`
          ${this.getUnpackedSamplerFromInput(p,l,S).routineBody}
          float ${p}(int row, int col) {
            return ${p}(${(0,u.getSqueezedParams)(w,m)});
          }
        `;return new r.GlslLibRoutine(k,["coordinates.sampleTexture"])}const b=f[1],v=f[0];if(v===1){const y=`
          float ${p}(int row, int col) {
            int offset_${l} = coordsToOffset(TexCoords, ${b}, ${v});
            float index = dot(vec3(row, col, offset_${l}), vec3(${c[1]}, 1, 1));
            vec2 uv = vec2(0.5, (index + 0.5) / ${b}.0);
            return sampleTexture(${l}, uv);
          }
        `;return new r.GlslLibRoutine(y,["coordinates.sampleTexture","coordinates.coordsToOffset"])}if(b===1){const y=`
          float ${p}(int row, int col) {
            int offset_${l} = coordsToOffset(TexCoords, ${b}, ${v});
            float index = dot(vec3(row, col, offset_${l}), vec3(${c[1]}, 1, 1));
            vec2 uv = vec2((index + 0.5) / ${v}.0, 0.5);
            return sampleTexture(${l}, uv);
          }
        `;return new r.GlslLibRoutine(y,["coordinates.sampleTexture","coordinates.coordsToOffset"])}const T=`
        float ${p}(int row, int col) {
          int index = col * ${c[1]} + row;
          vec2 uv = uvFromFlat(${b}, ${v}, index);
          return sampleTexture(${l}, uv);
        }
      `;return new r.GlslLibRoutine(T,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler3D(p,l,i){const c=i.unpackedShape,f=c[1]*c[2],g=c[2],{newShape:m,keptDims:_}=(0,a.squeezeShape)(c),b=m;if(b.length<c.length){const T=(0,u.squeezeInputShape)(c,b),y=["batch","col","row"],S=JSON.parse(JSON.stringify(i));S.unpackedShape=T;const w=this.getUnpackedSamplerFromInput(p,l,S),k=_.reverse(),P=`
          ${w.routineBody}
          float ${p}(int batch, int row, int col) {
            return ${p}(${(0,u.getSqueezedParams)(y,k)});
          }
        `;return new r.GlslLibRoutine(P,w.dependencies)}const v=`
          float ${p}(int depth, int row, int col) {
            // Explicitly use integer operations as dot() only works on floats.
            int index = depth * ${f} + col * ${g} + row;
            vec2 uv = uvFromFlat(${i.width}, ${i.height}, index);
            return sampleTexture(${l}, uv);
          }
      `;return new r.GlslLibRoutine(v,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler4D(p,l,i){const c=i.unpackedShape,f=c[3],g=c[2]*f,m=`
        float ${p}(int row, int col, int depth, int depth2) {
          int index = row * ${c[1]*g} + col * ${g} +
              depth2 * ${f} + depth;
          vec2 uv = uvFromFlat(${i.width}, ${i.height}, index);
          return sampleTexture(${l}, uv);
        }
      `;return new r.GlslLibRoutine(m,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler5D(p,l,i){const c=i.unpackedShape,f=c[4],g=c[3]*f,m=c[2]*g,_=c[1]*m,{newShape:b,keptDims:v}=(0,a.squeezeShape)(c);if(b.length<c.length){const y=(0,u.squeezeInputShape)(c,b),S=["row","col","depth","depth2","depth3"],w=JSON.parse(JSON.stringify(i));w.unpackedShape=y;const k=`
          ${this.getUnpackedSamplerFromInput(p,l,w).routineBody}
          float ${p}(int row, int col, int depth, int depth2, int depth3) {
            return ${p}(${(0,u.getSqueezedParams)(S,v)});
          }
        `;return new r.GlslLibRoutine(k,["coordinates.sampleTexture","coordinates.uvFromFlat"])}const T=`
        float ${p}(int row, int col, int depth, int depth2, int depth3) {
          int index = row * ${_} + col * ${m} + depth * ${g} +
          depth3 * ${f} + depth2;
          vec2 uv = uvFromFlat(${i.width}, ${i.height}, index);
          return sampleTexture(${l}, uv);
        }
      `;return new r.GlslLibRoutine(T,["coordinates.sampleTexture","coordinates.uvFromFlat"])}getUnpackedSampler6D(p,l,i){const c=i.unpackedShape,f=c[5],g=c[4]*f,m=c[3]*g,_=c[2]*m,b=c[1]*_,{newShape:v,keptDims:T}=(0,a.squeezeShape)(c);if(v.length<c.length){const S=(0,u.squeezeInputShape)(c,v),w=["row","col","depth","depth2","depth3","depth4"],k=JSON.parse(JSON.stringify(i));k.unpackedShape=S;const P=`
            ${this.getUnpackedSamplerFromInput(p,l,k).routineBody}
            float ${p}(int row, int col, int depth,
              int depth2, int depth3, int depth4) {
              return ${p}(${(0,u.getSqueezedParams)(w,T)});
            }
          `;return new r.GlslLibRoutine(P,["coordinates.sampleTexture","coordinates.uvFromFlat"])}const y=`
          float ${p}(int row, int col, int depth,
            int depth2, int depth3, int depth4) {
            int index = row * ${b} + col * ${_} + depth * ${m} +
            depth2 * ${g} + depth3 * ${f} + depth4;
            vec2 uv = uvFromFlat(${i.width}, ${i.height}, index);
            return sampleTexture(${l}, uv);
          }
        `;return new r.GlslLibRoutine(y,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}toVec(){const p=this.context.outputTextureLayout,l=p.shape.length,i=p.strides,c=p.width,f=p.height,g=[];for(let _=0;_<l-1;++_)g.push(`
        c[${_}] = offset / ${i[_]};`),g.push(`
        offset -= c[${_}] * ${i[_]};`);g.push(`
        c[${l-1}] = offset;`);const m=`
      void toVec(vec2 texCoords, out int c[${l}]) {
        int offset = coordsToOffset(texCoords, ${c}, ${f});
        ${g.join("")}
      }
      void toVec(int offset, out int c[${l}]) {
        ${g.join("")}
      }
    `;return{toVec:new r.GlslLibRoutine(m,["coordinates.coordsToOffset"])}}valueFrom(){const p={};return this.context.programInfo.inputNames.forEach((l,i)=>{const c=this.context.inputTextureLayouts[i],f=(c.unpackedShape.length>0?c.unpackedShape:c.shape).length;let g=`_${l}`;p[g]=new r.GlslLibRoutine(this.getValueFromSingle(l,f,c.width,c.height,!1),[`shapeUtils.indicesToOffset${g}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),g+="_T",p[g]=new r.GlslLibRoutine(this.getValueFromSingle(l,f,c.width,c.height,!0),[`shapeUtils.indicesToOffset${g}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),p}getValueFromSingle(p,l,i,c,f){let g=`_${p}`;return f&&(g+="_T"),`
        float ${g}(int m[${l}]) {
          int offset = indicesToOffset${g}(m);
          vec2 coords = offsetToCoords(offset, ${i}, ${c});
          float value = getColorAsFloat(${(0,o.getGlsl)(this.context.glContext.version).texture2D}(${p}, coords));
          return value;
        }
        `}getPackedValueFrom(p,l,i,c,f){let g=`_${p}_Pack`;return f&&(g+="_T"),`
        vec4 ${g}(int m[${l}]) {
          int offset = indicesToOffset_${p}(m);
          vec2 coords = offsetToCoords(offset, ${i}, ${c});
          return ${(0,o.getGlsl)(this.context.glContext.version).texture2D}(${p}, coords);
        }
        `}}e.CoordsGlslLib=d},1997:(s,e)=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.TopologicalSortGlslRoutines=e.GlslLibRoutineNode=e.GlslLibRoutine=e.GlslLib=e.GlslContext=e.FunctionType=void 0,(t=e.FunctionType||(e.FunctionType={}))[t.ValueBased=0]="ValueBased",t[t.Positional=1]="Positional",e.GlslContext=class{constructor(n,r,o,a){this.glContext=n,this.programInfo=r,this.inputTextureLayouts=o,this.outputTextureLayout=a}},e.GlslLib=class{constructor(n){this.context=n}},e.GlslLibRoutine=class{constructor(n,r){this.routineBody=n,this.dependencies=r}},e.GlslLibRoutineNode=class{constructor(n,r,o){this.name=n,this.dependencies=o||[],r&&(this.routineBody=r)}addDependency(n){n&&this.dependencies.push(n)}},e.TopologicalSortGlslRoutines=class{static returnOrderedNodes(n){if(!n||n.length===0)return[];if(n.length===1)return n;const r=new Set,o=new Set,a=new Array;return this.createOrderedNodes(n,r,o,a),a}static createOrderedNodes(n,r,o,a){for(let u=0;u<n.length;++u)this.dfsTraverse(n[u],r,o,a)}static dfsTraverse(n,r,o,a){if(!n||o.has(n.name))return;if(r.has(n.name))throw new Error("Cyclic dependency detected. Can't topologically sort routines needed for shader.");r.add(n.name);const u=n.dependencies;if(u&&u.length>0)for(let d=0;d<u.length;++d)this.dfsTraverse(u[d],r,o,a);a.push(n),o.add(n.name),r.delete(n.name)}}},1371:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EncodingGlslLib=void 0;const n=t(1997);class r extends n.GlslLib{constructor(a){super(a)}getFunctions(){return Object.assign(Object.assign({},this.encodeFloat32()),this.decodeFloat32())}getCustomTypes(){return{}}encodeFloat32(){return{encode:new n.GlslLibRoutine(`highp vec4 encode(highp float f) {
        return vec4(f, 0.0, 0.0, 0.0);
      }
        `)}}decodeFloat32(){return{decode:new n.GlslLibRoutine(`highp float decode(highp vec4 rgba) {
        return rgba.r;
      }
        `)}}encodeUint8(){const a=r.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new n.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=r.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new n.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),u=new Uint32Array(a),d=new Uint8Array(a);if(u[0]=3735928559,d[0]===239)return!0;if(d[0]===222)return!1;throw new Error("unknown endianness")}}e.EncodingGlslLib=r},2691:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.FragColorGlslLib=void 0;const n=t(1997),r=t(6757);class o extends n.GlslLib{constructor(u){super(u)}getFunctions(){return Object.assign(Object.assign({},this.setFragColor()),this.getColorAsFloat())}getCustomTypes(){return{}}setFragColor(){const u=(0,r.getGlsl)(this.context.glContext.version);return{setFragColor:new n.GlslLibRoutine(`
        void setFragColor(float value) {
            ${u.output} = encode(value);
        }
        `,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new n.GlslLibRoutine(`
        float getColorAsFloat(vec4 color) {
            return decode(color);
        }
        `,["encoding.decode"])}}}e.FragColorGlslLib=o},3878:(s,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.replaceInlines=void 0;const t=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm;e.replaceInlines=function(n){const r={};let o;for(;(o=t.exec(n))!==null;){const a=o[3].split(",").map(u=>{const d=u.trim().split(" ");return d&&d.length===2?{type:d[0],name:d[1]}:null}).filter(u=>u!==null);r[o[2]]={params:a,body:o[4]}}for(const a in r){const u="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;".replace("__FUNC__",a),d=new RegExp(u,"gm");for(;(o=d.exec(n))!==null;){const h=o[1],p=o[2],l=o[3].split(","),i=h?`${h} ${p};`:"";let c=r[a].body,f="";r[a].params.forEach((m,_)=>{m&&(f+=`${m.type} ${m.name} = ${l[_]};
`)}),c=`${f}
 ${c}`,c=c.replace("return",`${p} = `);const g=`
      ${i}
      {
        ${c}
      }
      `;n=n.replace(o[0],g)}}return n.replace(t,"")}},8897:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GlslPreprocessor=void 0;const n=t(1997),r=t(3878),o=t(1248),a=t(6757);e.GlslPreprocessor=class{constructor(u,d,h,p){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new n.GlslContext(u,d,h,p),Object.keys(o.glslRegistry).forEach(i=>{const c=new o.glslRegistry[i](this.context);this.libs[i]=c});const l=this.glslLibRoutineDependencyGraph;for(const i in this.libs){const c=this.libs[i].getFunctions();for(const f in c){const g=i+"."+f;let m;l[g]?(m=l[g],m.routineBody=c[f].routineBody):(m=new n.GlslLibRoutineNode(g,c[f].routineBody),l[g]=m);const _=c[f].dependencies;if(_)for(let b=0;b<_.length;++b)if(l[_[b]])m.addDependency(l[_[b]]);else{const v=new n.GlslLibRoutineNode(_[b]);l[_[b]]=v,m.addDependency(v)}}}}preprocess(){const u=this.context.programInfo;let d=u.shaderSource;return this.context.programInfo.hasMain||(d=`${d}
      ${(0,a.getDefaultFragShaderMain)(this.context.glContext.version,this.context.outputTextureLayout.shape.length)}`),d=(0,r.replaceInlines)(d),`${(0,a.getFragShaderPreamble)(this.context.glContext.version)}
    ${this.getUniforms(u.inputNames,u.variables)}
    ${this.getImports(d)}
    ${d}`}getImports(u){const d=this.selectGlslLibRoutinesToBeIncluded(u);if(d.length===0)return"";let h="";for(let p=0;p<d.length;++p){if(!d[p].routineBody)throw new Error(`Missing body for the Glsl Library routine: ${d[p].name}`);h+=d[p].routineBody+`
`}return h}selectGlslLibRoutinesToBeIncluded(u){const d=[];return Object.keys(this.glslLibRoutineDependencyGraph).forEach(h=>{const p=h.split(".")[1];u.indexOf(p)!==-1&&d.push(this.glslLibRoutineDependencyGraph[h])}),n.TopologicalSortGlslRoutines.returnOrderedNodes(d)}getUniforms(u,d){const h=[];if(u)for(const p of u)h.push(`uniform sampler2D ${p};`);if(d)for(const p of d)h.push(`uniform ${p.type} ${p.name}${p.arrayLength?`[${p.arrayLength}]`:""};`);return h.join(`
`)}}},1248:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.glslRegistry=void 0;const n=t(6859),r=t(1371),o=t(2691),a=t(9183),u=t(9314);e.glslRegistry={encoding:r.EncodingGlslLib,fragcolor:o.FragColorGlslLib,vec:u.VecGlslLib,shapeUtils:a.ShapeUtilsGlslLib,coordinates:n.CoordsGlslLib}},9183:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ShapeUtilsGlslLib=void 0;const n=t(1997);class r extends n.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,u={};return this.context.programInfo.inputNames.forEach((d,h)=>{const p=this.context.inputTextureLayouts[h].unpackedShape;if(p.length<=a){const l=p.length,i=a-l,c=`bcastIndices_${d}`;let f="";for(let m=0;m<l;++m)f+=`
          realIndices[${m}] = int( mod(float(bcastedIndices[${i+m}]), ${p[m]}.0) );
          `;const g=`
        void ${c} (int bcastedIndices[${a}], out int realIndices[${l}]) {
          ${f}
        }
        `;u[c]=new n.GlslLibRoutine(g)}}),u}bcastMatmulIndex(){const a=this.context.outputTextureLayout.shape.length,u={};return this.context.programInfo.inputNames.forEach((d,h)=>{const p=this.context.inputTextureLayouts[h].shape;if(!(p.length<2||p.length>a)){const l=p.length,i=a-l,c=`bcastMatmulIndices_${d}`;let f="";for(let m=0;m<l-2;++m)f+=`
          realIndices[${m}] = int( mod(float(bcastedIndices[${i+m}]), ${p[m]}.0) );
          `;const g=`
        void ${c}(int bcastedIndices[${a}], out int realIndices[${l}]) {
          ${f}
          realIndices[${l-1}] = bcastedIndices[${a-1}];
          realIndices[${l-2}] = bcastedIndices[${a-2}];
        }
        `;u[c]=new n.GlslLibRoutine(g)}}),u}indicesToOffset(){const a={};return this.context.programInfo.inputNames.forEach((u,d)=>{const h=this.context.inputTextureLayouts[d].shape,p=this.context.inputTextureLayouts[d].strides,l=h.length;let i=`indicesToOffset_${u}`;a[i]=new n.GlslLibRoutine(r.indexToOffsetSingle(i,l,p)),i=`indicesToOffset_${u}_T`,a[i]=new n.GlslLibRoutine(r.indexToOffsetSingle(i,l,p.slice().reverse()))}),a}static indexToOffsetSingle(a,u,d){let h="";for(let p=u-1;p>=0;--p)h+=`
        offset += indices[${p}] * ${d[p]};
        `;return`
      int ${a}(int indices[${u}]) {
        int offset = 0;
        ${h}
        return offset;
      }
      `}offsetToIndices(){const a={};return this.context.programInfo.inputNames.forEach((u,d)=>{const h=this.context.inputTextureLayouts[d].shape,p=this.context.inputTextureLayouts[d].strides,l=h.length;let i=`offsetToIndices_${u}`;a[i]=new n.GlslLibRoutine(r.offsetToIndicesSingle(i,l,p)),i=`offsetToIndices_${u}_T`,a[i]=new n.GlslLibRoutine(r.offsetToIndicesSingle(i,l,p.slice().reverse()))}),a}static offsetToIndicesSingle(a,u,d){const h=[];for(let p=0;p<u-1;++p)h.push(`
      indices[${p}] = offset / ${d[p]};`),h.push(`
        offset -= indices[${p}] * ${d[p]};`);return h.push(`
      indices[${u-1}] = offset;`),`
      void ${a}(int offset, out int indices[${u}]) {
        ${h.join("")}
      }
      `}incrementIndices(){const a={};return this.context.programInfo.inputNames.forEach((u,d)=>{const h=this.context.inputTextureLayouts[d].shape,p=h.length,l=`incrementIndices_${u}`;let i="";for(let f=0;f<p;++f)i+=`
        shape[${f}] = ${h[f]};`;const c=`
        void ${l}(int axis, out int indices[${p}]) {
          int shape[${p}];
          ${i};
          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[l]=new n.GlslLibRoutine(c)}),a}}e.ShapeUtilsGlslLib=r},6757:(s,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getDefaultFragShaderMain=e.getFragShaderPreamble=e.getVertexShaderSource=e.getGlsl=void 0;const t={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},n={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"};function r(o){return o===1?t:n}e.getGlsl=r,e.getVertexShaderSource=function(o){const a=r(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=r(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));
    ${r(o).output} = result;
  }
  `}},9314:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.VecGlslLib=void 0;const n=t(1997);class r extends n.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,u={add:"+=",sub:"-=",mul:"*=",div:"/="},d={};for(const h in u){const p=`${h}Vec`;let l="";for(let c=0;c<a;++c)l+=`
          dest[${c}] ${u[h]} src[${c}];
          `;const i=`
        void ${p}(int src[${a}], out int dest[${a}]) {
          ${l}
        }
        `;d[p]=new n.GlslLibRoutine(i)}return d}copyVec(){const a=this.context.outputTextureLayout.shape.length;let u="";for(let h=0;h<a;++h)u+=`
        dest[${h}] = src[${h}];
        `;const d=`
      void copyVec(int src[${a}], out int dest[${a}]) {
        ${u}
      }
      `;return{copyVec:new n.GlslLibRoutine(d)}}setVecItem(){const a=this.context.outputTextureLayout.shape.length;let u=`
        if(index < 0)
            index =${a} + index;
        if (index == 0)
            m[0] = value;
        `;for(let h=1;h<a-1;++h)u+=`
        else if (index == ${h})
            m[${h}] = value;
            `;u+=`
        else
            m[${a-1}] = value;
        `;const d=`
      void setVecItem(out int m[${a}], int index, int value) {
        ${u}
      }
        `;return{setVecItem:new n.GlslLibRoutine(d)}}getVecItem(){const a=this.context.outputTextureLayout.shape.length;let u=`
        if(index < 0)
            index = ${a} + index;
        if (index == 0)
            return m[0];
      `;for(let h=1;h<a-1;++h)u+=`
        else if (index == ${h})
            return m[${h}];
      `;u+=`
        else
            return m[${a-1}];
        `;const d=`
      int getVecItem(int m[${a}], int index) {
        ${u}
      }
    `;return{getVecItem:new n.GlslLibRoutine(d)}}}e.VecGlslLib=r},7860:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLInferenceHandler=void 0;const n=t(1315),r=t(9240),o=t(7273),a=t(9),u=t(7379),d=t(2488),h=t(540),p=t(3314),l=t(5639);e.WebGLInferenceHandler=class{constructor(i){this.session=i,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(i,c){return(0,p.calculateTextureWidthAndHeight)(this.session.layoutStrategy,i,c)}executeProgram(i,c){if(c.length<i.inputNames.length)throw new Error(`Input size mustn't be less than ${i.inputNames.length}.`);if(i.inputNames.length!==i.inputTypes.length)throw new Error("input names size does not match input types");const f=[];for(let T=0;T<i.inputNames.length;++T)f[T]=this.getOrCreateTextureData(c[T],i.inputTypes[T]);const g=((T,y)=>{const S=y.map(k=>`${k.unpackedShape.join(",")};${k.width}x${k.height}`).join("_");let w=T.name;return T.cacheHint&&(w+="["+T.cacheHint+"]"),w+=":"+S,w})(i,f);let m=this.session.programManager.getArtifact(g);const _=m?m.programInfo:typeof i.get=="function"?i.get():i,b=(0,p.createTextureLayoutFromTextureType)(this.session.layoutStrategy,_.output.dims,_.output.textureType),v=this.createTextureData(b,_.output.type);return m||(m=this.session.programManager.build(_,f,v),this.session.programManager.setArtifact(g,m)),this.runProgram(m,f,v),v}run(i,c){return this.executeProgram(i,c).tensor}runProgram(i,c,f){for(let g=0;g<c.length;++g)if(!!c[g].isPacked!=(i.programInfo.inputTypes[g]===l.TextureType.packed))throw new Error(`input[${g}] property packed inconsistent`);if(!!f.isPacked!=(i.programInfo.output.textureType===l.TextureType.packed))throw new Error("output property packed inconsistent");this.session.programManager.run(i,c,f)}getOrCreateTextureData(i,c){let f=this.getTextureData(i.dataId,c===l.TextureType.packed);if(!f&&(f=this.getTextureData(i.dataId,c!==l.TextureType.packed),f))return c===l.TextureType.packed?this.pack(f):this.unpack(f);if(!f){const g=(0,p.createTextureLayoutFromTextureType)(this.session.layoutStrategy,i.dims,c);if(c===l.TextureType.packedLastDimension){const b=i.dims;if(b.length===4){const v=[b[0],Math.ceil(b[1]*b[2]*b[3]/4)],T=(0,p.createTextureLayoutFromTextureType)(this.session.layoutStrategy,v,c);let y=i.numberData;if(b[1]*b[2]*b[3]%4!=0){const S=b[0],w=b[1]*b[2]*b[3],k=Math.ceil(w*1/4)*4;y=new Float32Array(S*k);for(let P=0;P<S;++P){const I=P*w,F=P*k+P%1*w;y.set(i.numberData.subarray(I,I+w),F)}}return this.createTextureData(T,i.type,y,i,1)}}if(c===l.TextureType.packed){const m=(0,p.createTextureLayoutFromShape)(this.session.layoutStrategy,i.dims,1,[],{reverseWH:!0}),_=this.createTextureData(m,i.type,i.numberData,i,1);f=this.pack(_)}else f=this.createTextureData(g,i.type,i.numberData,i,1)}return f}createTextureDataFromLayoutBindTensor(i,c,f,g){return this.createTextureData(i,c,f,g,1)}createTextureData(i,c,f,g,m){n.Logger.verbose("InferenceHandler",`Creating TextureData: layout:[${JSON.stringify(i)}]`);const _=this.session.textureManager.createTextureFromLayout(c,i,f,m);return this.createTextureDataFromTexture(i,c,_,g)}reshapeUnpacked(i,c){const f=this.getOrCreateTextureData(i,l.TextureType.unpacked),g={channels:f.channels,height:f.height,width:f.width,shape:c.length!==0?c:[1],strides:o.ShapeUtil.computeStrides(c),unpackedShape:c};return this.createTextureDataFromTexture(g,i.type,f.texture).tensor}reshapePacked(i,c){const f=this.getOrCreateTextureData(i,l.TextureType.packed);if((0,u.isReshapeCheap)(i.dims,c)){const v={channels:f.channels,height:f.height,width:f.width,shape:c.length!==0?c:[1],strides:o.ShapeUtil.computeStrides(c),unpackedShape:c,isPacked:!0};return this.createTextureDataFromTexture(v,i.type,f.texture).tensor}const g=(0,u.processDims3D)(i.dims),m=(0,u.processDims3D)(c),_=this.reshapePacked(i,g),b=this.run((0,u.createPackedReshape3DProgramInfoLoader)(this,_,m),[_]);return this.reshapePacked(b,c)}cast(i,c){const f=this.getOrCreateTextureData(i,l.TextureType.unpacked);return this.createTextureDataFromTexture(f,c,f.texture).tensor}createTextureDataFromTexture(i,c,f,g,m){const _=Object.assign(Object.assign({},i),{tensor:g||new r.Tensor(i.unpackedShape,c,b=>this.readTexture(_),async b=>this.readTextureAsync(_),void 0,m),texture:f});return this.setTextureData(_.tensor.dataId,_,i.isPacked),_}getTextureData(i,c=!1){return this.session.isInitializer(i)?this.session.getTextureData(i,c):c?this.packedTextureDataCache.get(i):this.unpackedTextureDataCache.get(i)}setTextureData(i,c,f=!1){this.session.isInitializer(i)?this.session.setTextureData(i,c,f):(f?this.packedTextureDataCache:this.unpackedTextureDataCache).set(i,c)}isTextureLayoutCached(i,c=!1){return!!this.getTextureData(i.dataId,c)}dispose(){this.session.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(i=>this.session.textureManager.releaseTexture(i)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(i=>this.session.textureManager.releaseTexture(i)),this.unpackedTextureDataCache=new Map}readTexture(i){return i.isPacked?this.readTexture(this.unpack(i)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTexture(i,i.tensor.type,i.channels):this.session.textureManager.readUint8TextureAsFloat((0,d.encodeAsUint8)(this,i))}async readTextureAsync(i){return i.isPacked?this.readTextureAsync(this.unpack(i)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTextureAsync(i,i.tensor.type,i.channels):this.session.textureManager.readUint8TextureAsFloat((0,d.encodeAsUint8)(this,i))}pack(i){return this.executeProgram((0,a.createPackProgramInfoLoader)(this,i.tensor),[i.tensor])}unpack(i){return this.executeProgram((0,h.createUnpackProgramInfoLoader)(this,i.tensor),[i.tensor])}}},4110:function(s,e,t){var n=this&&this.__createBinding||(Object.create?function(J,X,ee,Q){Q===void 0&&(Q=ee);var re=Object.getOwnPropertyDescriptor(X,ee);re&&!("get"in re?!X.__esModule:re.writable||re.configurable)||(re={enumerable:!0,get:function(){return X[ee]}}),Object.defineProperty(J,Q,re)}:function(J,X,ee,Q){Q===void 0&&(Q=ee),J[Q]=X[ee]}),r=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 ee in J)ee!=="default"&&Object.prototype.hasOwnProperty.call(J,ee)&&n(X,J,ee);return r(X,J),X};Object.defineProperty(e,"__esModule",{value:!0}),e.WEBGL_OP_RESOLVE_RULES=void 0;const a=t(8817),u=o(t(5194)),d=t(4752),h=t(6668),p=t(9754),l=t(5042),i=t(6742),c=t(4125),f=t(6149),g=t(5378),m=t(6981),_=t(7413),b=t(7006),v=t(8276),T=t(5565),y=t(2834),S=t(1010),w=t(8126),k=t(2801),P=t(565),I=t(2444),F=t(815),C=t(564),E=t(5416),$=t(1240),x=t(5944),A=t(5707),L=o(t(9087)),B=t(7862),H=t(3980);e.WEBGL_OP_RESOLVE_RULES=[["Abs","","6+",L.abs],["Acos","","7+",L.acos],["Add","","7+",u.add],["And","","7+",u.and],["Asin","","7+",L.asin],["Atan","","7+",L.atan],["AveragePool","","7+",y.averagePool,y.parseAveragePoolAttributes],["BatchNormalization","","7+",a.batchNormalization,a.parseBatchNormalizationAttributes],["Cast","","6+",d.cast,d.parseCastAttributes],["Ceil","","6+",L.ceil],["Clip","","6-10",L.clip,L.parseClipAttributes],["Clip","","11+",L.clipV11],["Concat","","4+",h.concat,h.parseConcatAttributes],["Conv","","1+",p.conv,p.parseConvAttributes],["ConvTranspose","","1+",l.convTranspose,l.parseConvTransposeAttributes],["Cos","","7+",L.cos],["Div","","7+",u.div],["Dropout","","7+",L.identity],["DepthToSpace","","1+",i.depthToSpace,i.parseDepthToSpaceAttributes],["Equal","","7+",u.equal],["Elu","","6+",L.elu,L.parseEluAttributes],["Exp","","6+",L.exp],["Flatten","","1+",c.flatten,c.parseFlattenAttributes],["Floor","","6+",L.floor],["FusedConv","com.microsoft","1+",p.conv,p.parseConvAttributes],["Gather","","1+",f.gather,f.parseGatherAttributes],["Gemm","","7-10",g.gemm,g.parseGemmAttributesV7],["Gemm","","11+",g.gemm,g.parseGemmAttributesV11],["GlobalAveragePool","","1+",y.globalAveragePool,y.parseGlobalAveragePoolAttributes],["GlobalMaxPool","","1+",y.globalMaxPool],["Greater","","7+",u.greater],["Identity","","1+",L.identity],["ImageScaler","","1+",m.imageScaler,m.parseImageScalerAttributes],["InstanceNormalization","","6+",_.instanceNormalization,_.parseInstanceNormalizationAttributes],["LeakyRelu","","6+",L.leakyRelu,L.parseLeakyReluAttributes],["Less","","7+",u.less],["LRN","","1+",b.lrn,b.parseLrnAttributes],["Log","","6+",L.log],["MatMul","","1+",v.matMul,v.parseMatMulAttributes],["MaxPool","","1+",y.maxPool,y.parseMaxPoolAttributes],["Mul","","7+",u.mul],["Neg","","6+",L.neg],["Not","","1+",L.not],["Or","","7+",u.or],["Pad","","2-10",T.padV2,T.parsePadAttributesV2],["Pad","","11+",T.padV11,T.parsePadAttributesV11],["Pow","","7+",u.pow],["PRelu","","7+",u.pRelu],["ReduceLogSum","","1+",S.reduceLogSum,S.parseReduceAttributes],["ReduceMax","","1+",S.reduceMax,S.parseReduceAttributes],["ReduceMean","","1+",S.reduceMean,S.parseReduceAttributes],["ReduceMin","","1+",S.reduceMin,S.parseReduceAttributes],["ReduceProd","","1+",S.reduceProd,S.parseReduceAttributes],["ReduceSum","","1-12",S.reduceSum,S.parseReduceAttributes],["ReduceSumSquare","","1+",S.reduceLogSumSquare,S.parseReduceAttributes],["Relu","","6+",L.relu],["Reshape","","5+",w.reshape],["Resize","","10",k.resize,k.parseResizeAttributesV10],["Resize","","11+",k.resize,k.parseResizeAttributesV11],["Shape","","1+",P.shape],["Sigmoid","","6+",L.sigmoid],["Sin","","7+",L.sin],["Slice","","10+",I.sliceV10],["Slice","","1-9",I.slice,I.parseSliceAttributes],["Softmax","","1-12",F.softmax,F.parseSoftmaxAttributes],["Softmax","","13+",F.softmaxV13,F.parseSoftmaxAttributesV13],["Split","","2-12",C.split,C.parseSplitAttributes],["Sqrt","","6+",L.sqrt],["Squeeze","","1-12",E.squeeze,E.parseSqueezeAttributes],["Squeeze","","13+",E.squeezeV13],["Sub","","7+",u.sub],["Sum","","6+",$.sum],["Tan","","7+",L.tan],["Tanh","","6+",L.tanh],["Tile","","6+",x.tile],["Transpose","","1+",A.transpose,A.parseTransposeAttributes],["Upsample","","7-8",H.upsample,H.parseUpsampleAttributesV7],["Upsample","","9",H.upsample,H.parseUpsampleAttributesV9],["Unsqueeze","","1-12",B.unsqueeze,B.parseUnsqueezeAttributes],["Unsqueeze","","13+",B.unsqueezeV13],["Xor","","7+",u.xor]]},8817:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseBatchNormalizationAttributes=e.batchNormalization=void 0;const n=t(4910),r=t(6757),o=t(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,l)=>(d(p),[h.run(Object.assign(Object.assign({},a),{cacheHint:l.cacheKey,get:()=>u(h,p,l)}),p)]),e.parseBatchNormalizationAttributes=h=>{const p=h.attributes.getFloat("epsilon",1e-5),l=h.attributes.getFloat("momentum",.9),i=h.attributes.getInt("spatial",1);return(0,n.createAttributeWithCacheKey)({epsilon:p,momentum:l,spatial:i})};const u=(h,p,l)=>{const i=(0,r.getGlsl)(h.session.backend.glContext.version),c=p[0].dims.length,[f,g]=h.calculateTextureWidthAndHeight(p[1].dims,o.TextureType.unpacked),m=`
  float process(int[${c}] indices) {
    vec2 position = offsetToCoords(indices[1], ${f}, ${g});
    float scale = getColorAsFloat(${i.texture2D}(Scale, position));
    float mean = getColorAsFloat(${i.texture2D}(Mean, position));
    float variance = getColorAsFloat(${i.texture2D}(Variance, position));
    float b = getColorAsFloat(${i.texture2D}(B, position));

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          `;const F=`
      ${k}

      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({},f),{output:{dims:S,type:g.type,textureType:r.TextureType.packed},shaderSource:F,hasMain:!0})})(a,l,u,d,h,p)})}},1625:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.calculateIm2ColDims=e.createIm2ColProgramInfoLoader=void 0;const n=t(5639);e.createIm2ColProgramInfoLoader=(r,o,a,u,d)=>{const h=(p=d.cacheKey,{name:"Im2Col",inputNames:["X"],inputTypes:[n.TextureType.unpacked],cacheHint:p});var p;return Object.assign(Object.assign({},h),{get:()=>((l,i,c,f,g,m)=>{const _=c.dims,b=f.dims,v=g.length,T=(0,e.calculateIm2ColDims)(_,b,g,4),y=`
        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[${v}]) {
          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({},i),{output:{dims:T,type:c.type,textureType:n.TextureType.packedLastDimension},shaderSource:y})})(0,h,o,a,u,d)})},e.calculateIm2ColDims=(r,o,a,u=4)=>[a[0],a[2],a[3],Math.ceil(r[1]*o[2]*o[3]/u)]},6981:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseImageScalerAttributes=e.imageScaler=void 0;const n=t(4910),r=t(5639);e.imageScaler=(h,p,l)=>(d(p),[h.run(a(h,p,l),p)]),e.parseImageScalerAttributes=h=>{const p=h.attributes.getFloat("scale"),l=h.attributes.getFloats("bias");return(0,n.createAttributeWithCacheKey)({scale:p,bias:l})};const o={name:"ImageScaler",inputNames:["X"],inputTypes:[r.TextureType.unpacked]},a=(h,p,l)=>{const i=Object.assign(Object.assign({},o),{cacheHint:l.cacheKey});return Object.assign(Object.assign({},i),{get:()=>((c,f,g,m)=>{const _=g[0].dims.slice(),b=_.length,v=`
      ${u(m.bias.length)}
      float process(int indices[${b}]) {
        return _X(indices) * scale + getBias(bias, indices[1]);
      }`;return Object.assign(Object.assign({},f),{output:{dims:_,type:g[0].type,textureType:r.TextureType.unpacked},variables:[{name:"bias",type:"float",arrayLength:m.bias.length,data:m.bias},{name:"scale",type:"float",data:m.scale}],shaderSource:v})})(0,i,p,l)})},u=h=>{const p=[`float getBias(float bias[${h}], int channel) {`];for(let l=0;l<h;++l)l===0?p.push(`	if (channel == ${l}) { return bias[${l}]; }`):l===h-1?p.push(`	else { return bias[${l}]; }`):p.push(`	else if (channel == ${l}) { return bias[${l}]; }`);return p.push("	}"),p.join(`
`)},d=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:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseInstanceNormalizationAttributes=e.instanceNormalization=void 0;const n=t(6757),r=t(5639);e.instanceNormalization=(p,l,i)=>{h(l);const c=p.run(a(l[0]),l);return[p.run(d(p,l[0],i,c.dims),[l[0],c,l[1],l[2]])]},e.parseInstanceNormalizationAttributes=p=>p.attributes.getFloat("epsilon",1e-5);const o={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[r.TextureType.unpacked]},a=p=>Object.assign(Object.assign({},o),{get:()=>((l,i)=>{const c=i.dims.slice(),f=c[1],g=c[2]*c[3],m=[c[0],f],_=`
      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<${c[2]}; a2++) {
          a[2] = a2;
          for(int a3=0; a3<${c[3]}; a3++) {
            a[3] = a3;
            float x = _X(a);
            temp += x;
          }
        }
        float mean = temp / float(${g});
        temp = 0.0;
        for(int a2=0; a2<${c[2]}; a2++) {
          a[2] = a2;
          for(int a3=0; a3<${c[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({},l),{output:{dims:m,type:i.type,textureType:r.TextureType.packedLastDimension},shaderSource:_})})(o,p)}),u={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[r.TextureType.unpacked,r.TextureType.packedLastDimension,r.TextureType.unpacked,r.TextureType.unpacked]},d=(p,l,i,c)=>{const f=Object.assign(Object.assign({},u),{cacheHint:`${i}`});return Object.assign(Object.assign({},f),{get:()=>((g,m,_,b,v)=>{const T=(0,n.getGlsl)(g.session.backend.glContext.version),[y,S]=g.calculateTextureWidthAndHeight(v,r.TextureType.packedLastDimension),[w,k]=[y/4,S],P=`
      vec4 get_MeanAndVariance(int[2] mv) {
        int offset = indicesToOffset_MeanAndVariance(mv);
        vec2 coords = offsetToCoords(offset, ${w}, ${k});
        return ${T.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:r.TextureType.unpacked},variables:[{name:"epsilon",type:"float",data:b}],shaderSource:P})})(p,f,l,i,c)})},h=p=>{if(!p||p.length!==3)throw new Error("InstanceNormalization requires 3 inputs.");const l=p[0],i=p[1],c=p[2];if(l.dims.length<3||i.dims.length!==1||c.dims.length!==1)throw new Error("Invalid input shape.");if(i.dims[0]!==l.dims[1]||c.dims[0]!==l.dims[1])throw new Error("Input shapes are mismatched.");if(l.type!=="float32"&&l.type!=="float64"||i.type!=="float32"&&i.type!=="float64"||c.type!=="float32"&&c.type!=="float64")throw new Error("Invalid input type.");if(p[0].dims.length!==4)throw new Error("Only support 4-D input shape.")}},7006:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createLrnProgramInfoLoader=e.parseLrnAttributes=e.lrn=void 0;const n=t(4910),r=t(5639);e.lrn=(d,h,p)=>(u(h),[d.run(a(h,p),h)]),e.parseLrnAttributes=d=>{const h=d.attributes.getFloat("alpha",1e-4),p=d.attributes.getFloat("beta",.75),l=d.attributes.getFloat("bias",1),i=d.attributes.getInt("size");return(0,n.createAttributeWithCacheKey)({alpha:h,beta:p,bias:l,size:i})};const o={name:"LRN",inputNames:["X"],inputTypes:[r.TextureType.unpacked]};function a(d,h){return Object.assign(Object.assign({},o),{cacheHint:h.cacheKey,get:()=>function(p,l){const i=p[0].dims[1],c=p[0].dims.length,f=-Math.floor((l.size-1)/2),g=Math.ceil((l.size-1)/2),m=`float(${l.alpha}) / float(${l.size})`,_=`
    float process(int indices[${c}]) {
        int c = indices[1];
        float x = _X(indices);
        float square_sum = 0.0;

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

vec4 getBAtOutCoordsMatmul(int i) {
  ${re} coords = getOutputCoords();
  ${Me}
  ${$e}
  vec4 outputValue = getB(${we});
  return outputValue;
}`}($,A,_,w)}`:"",X=k?"getAAtOutCoordsMatmul(i)":`getA(${function(re,oe){let ce="";for(let fe=0;fe<oe-2;fe++)ce+=`rc.${re[fe]}, `;return ce+=`rc.${re[oe-2]}, i*2`,ce}(A,F)})`,ee=k?"getBAtOutCoordsMatmul(i)":`getB(${function(re,oe){let ce="";for(let fe=0;fe<oe-2;fe++)ce+=`rc.${re[fe]}, `;return ce+=`i*2, rc.${re[oe-1]}`,ce}(A,C)})`,Q=`
            ${J}
            ${H}
            ${L}
            void main() {
              ${k?"":`${$} rc =
          getOutputCoords(); int lastDim = rc.${A[x-1]}; rc.${A[x-1]} =
          rc.${A[x-2]}; rc.${A[x-2]} = lastDim;
      `}

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

                value += (a.rrbb * b.rgrg);
                value += (a.ggaa * b.baba);
              }
              ${T}
              ${B}
              ${E.output} = value;
            }`;return Object.assign(Object.assign({},m),{output:{dims:w,type:_[0].type,textureType:o.TextureType.packed},shaderSource:Q,hasMain:!0})})(h,i,p,l)})}},8276:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getBiasForMatmul=e.createMatmulProgramInfoLoader=e.parseMatMulAttributes=e.matMul=void 0;const n=t(7273),r=t(5639),o=t(432),a=t(2150),u=t(5632);e.matMul=(i,c,f)=>(p(c),i.session.pack?[i.run((0,u.createPackedMatmulProgramInfoLoader)(i,c,f),c)]:[i.run(h(c,f),c)]),e.parseMatMulAttributes=i=>(0,a.parseInternalActivationAttributes)(i.attributes);const d=(i,c)=>({name:"MatMul",inputNames:i?["A","B","Bias"]:["A","B"],inputTypes:i?[r.TextureType.unpacked,r.TextureType.unpacked,r.TextureType.unpacked]:[r.TextureType.unpacked,r.TextureType.unpacked],cacheHint:c});function h(i,c){const f=d(i.length>2,c.activationCacheKey);return Object.assign(Object.assign({},f),{get:()=>function(g,m,_){const b=m[0].dims,v=m[1].dims,T=n.BroadcastUtil.calcShape(b,v,!0);if(!T)throw new Error("Can't use matmul on the given tensors");const y=(0,o.getCoordsDataType)(T.length),S=(0,o.getGlChannels)(),{activationFunction:w,applyActivation:k}=(0,a.getActivationSnippet)(_),P=m.length>2,I=P?"value += getBiasForMatmul();":"",F=P?`${l(y,S,m[2].dims,T,!1)}`:"",C=T.length,E=b.length,$=v.length,x=`
    ${w}
    ${F}
    float process(int indices[${C}]) {
        int a[${E}];
        int b[${$}];
        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[${$-2}] = k;
            value += _A(a) * _B(b);
        }
        ${I}
        ${k}
        return value;
    }`;return Object.assign(Object.assign({},g),{output:{dims:T,type:m[0].type,textureType:r.TextureType.unpacked},shaderSource:x})}(f,i,c)})}e.createMatmulProgramInfoLoader=h;const p=i=>{if(!i||i.length!==2)throw new Error("MatMul requires 2 inputs.");if(i[0].dims[i[0].dims.length-1]!==i[1].dims[i[1].dims.length-2])throw new Error("shared dimension does not match.");if(i[0].type!=="float32"&&i[0].type!=="float64"||i[1].type!=="float32"&&i[1].type!=="float64")throw new Error("inputs should be float type");if(i[0].type!==i[1].type)throw new Error("inputs types should match")};function l(i,c,f,g,m){let _="";const b=f.length,v=g.length,T=v-b;_=v<2&&b>0?"coords":f.map((w,k)=>`coords.${c[k+T]}`).join(", ");const y=n.BroadcastUtil.getBroadcastDims(f,g).map(w=>`coords.${c[w+T]} = 0;`).join(`
`);let S="vec4(outputValue.xx, outputValue.yy)";return n.ShapeUtil.size(f)===1&&(S="vec4(outputValue.x)"),m?`
vec4 getBiasForMatmul() {
  ${i} coords = getOutputCoords();
  ${y}
  vec4 outputValue = getBias(${_});
  return ${S};
}`:`
float getBiasForMatmul() {
  ${i} coords = getOutputCoords();
  ${y}
  return getBias(coords.x);
}`}e.getBiasForMatmul=l},9:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createPackProgramInfoLoader=void 0;const n=t(6757),r=t(5639),o=t(432),a=t(5614),u={name:"pack",inputNames:["A"],inputTypes:[r.TextureType.unpackedReversed]};e.createPackProgramInfoLoader=(d,h)=>Object.assign(Object.assign({},u),{get:()=>((p,l)=>{const i=(0,n.getGlsl)(p.session.backend.glContext.version),c=l.dims,f=c.length,g=l.dims.length,m=(0,o.getCoordsDataType)(g),_=(0,a.getChannels)("rc",g),b=(v=g,T=_,y=c[c.length-2],S=c[c.length-1],v===0||v===1?"":`
    int r = ${T[v-2]};
    int c = ${T[v-1]};
    int rp1 = ${T[v-2]} + 1;
    int cp1 = ${T[v-1]} + 1;
    bool rEdge = rp1 >= ${S};
    bool cEdge = cp1 >= ${y};
    `);var v,T,y,S;let w;w=f===0?[1,1]:f===1?[c[0],1]:[c[g-1],c[g-2]];const k=function(F,C,E){if(F===0)return"false";if(F===1)return`rc > ${C[0]}`;let $="";for(let x=F-2;x<F;x++)$+=`${E[x]} >= ${C[x-F+2]}`,x<F-1&&($+="||");return $}(g,w,_),P=function(F,C){const E=F.length;if(E===0)return"getA(), 0, 0, 0";if(E===1)return`getA(rc),
            rc + 1 >= ${F[0]} ? 0. : getA(rc + 1),
            0, 0`;let $="";if(E>2)for(let x=0;x<E-2;++x)$+=`${C[x]},`;return`getA(${$}r, c),
          rEdge ? 0. : getA(${$}rp1, c),
          cEdge ? 0. : getA(${$}r, cp1),
          rEdge || cEdge ? 0. : getA(${$}rp1, cp1)`}(c,_),I=`
        void main() {
          ${m} rc = getOutputCoords();

          if(${k}) {
            ${i.output} = vec4(0);
          } else {
            ${b}

            ${i.output} = vec4(${P});
          }
        }
      `;return Object.assign(Object.assign({},u),{hasMain:!0,output:{dims:l.dims,type:l.type,textureType:r.TextureType.packed},shaderSource:I})})(d,h)})},5614:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.unpackFromChannel=e.getChannels=e.getVecChannels=void 0;const n=t(432);function r(o,a){return(0,n.getGlChannels)(a).map(u=>`${o}.${u}`)}e.getVecChannels=r,e.getChannels=function(o,a){return a===1?[o]:r(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:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parsePadAttributesV11=e.padV11=e.parsePadAttributesV2=e.padV2=void 0;const n=t(4910),r=t(7273),o=t(6757),a=t(5639),u={name:"Pad",inputNames:["A"],inputTypes:[a.TextureType.unpacked]};e.padV2=(m,_,b)=>(p(_),[m.run(Object.assign(Object.assign({},u),{cacheHint:b.cacheKey,get:()=>h(m,_[0],b)}),_)]),e.parsePadAttributesV2=m=>{const _=m.attributes.getString("mode","constant"),b=m.attributes.getFloat("value",0),v=m.attributes.getInts("pads");return(0,n.createAttributeWithCacheKey)({mode:_,value:b,pads:v})},e.padV11=(m,_,b)=>{l(_);const v=d(m,_,b);return(0,e.padV2)(m,[_[0]],v)},e.parsePadAttributesV11=m=>m.attributes.getString("mode","constant");const d=(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 v=Array.from(_[1].integerData),T=_.length>=3?_[2].floatData[0]:0;return(0,n.createAttributeWithCacheKey)({mode:b,pads:v,value:T})},h=(m,_,b)=>{const v=r.ShapeUtil.padShape(_.dims.slice(),b.pads),T=v.length,y=`
      ${i(m,_,b)}
      float process(int[${T}] indices) {
          return padA(indices);
      }`;return{name:"Pad",inputNames:["A"],inputTypes:[a.TextureType.unpacked],output:{dims:v,type:_.type,textureType:a.TextureType.unpacked},shaderSource:y}},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.")},l=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.")},i=(m,_,b)=>{const v=(0,o.getGlsl)(m.session.backend.glContext.version),[T,y]=m.calculateTextureWidthAndHeight(_.dims,a.TextureType.unpacked),S=r.ShapeUtil.computeStrides(_.dims);switch(b.mode){case"constant":return c(v,_.dims,S,T,y,b.pads,b.value);case"reflect":return f(v,_.dims,S,T,y,b.pads);case"edge":return g(v,_.dims,S,T,y,b.pads);default:throw new Error("Invalid mode")}},c=(m,_,b,v,T,y,S)=>{const w=_.length;let k="";for(let P=w-1;P>=0;--P)k+=`
        k = m[${P}] - ${y[P]};
        if (k < 0)  return constant;
        if (k >= ${_[P]}) return constant;
        offset += k * ${b[P]};
        `;return`
      float padA(int m[${w}]) {
        const float constant = float(${S});
        int offset = 0;
        int k = 0;
        ${k}
        vec2 coords = offsetToCoords(offset, ${v}, ${T});
        float value = getColorAsFloat(${m.texture2D}(A, coords));
        return value;
      }
      `},f=(m,_,b,v,T,y)=>{const S=_.length;let w="";for(let k=S-1;k>=0;--k)w+=`
        k = m[${k}] - ${y[k]};
        if (k < 0) { k = -k; }
        {
          const int _2n_1 = ${2*(_[k]-1)};
          k = int( mod( float(k), float(_2n_1) ) ) ;
          if(k >= ${_[k]}) { k = _2n_1 - k; }
        }
        offset += k * ${b[k]};
        `;return`
      float padA(int m[${S}]) {
        int offset = 0;
        int k = 0;
        ${w}
        vec2 coords = offsetToCoords(offset, ${v}, ${T});
        float value = getColorAsFloat(${m.texture2D}(A, coords));
        return value;
      }
      `},g=(m,_,b,v,T,y)=>{const S=_.length;let w="";for(let k=S-1;k>=0;--k)w+=`
        k = m[${k}] - ${y[k]};
        if (k < 0)  k = 0;
        if (k >= ${_[k]}) k = ${_[k]-1};
        offset += k * ${b[k]};
      `;return`
      float padA(int m[${S}]) {
        int offset = 0;
        int k = 0;
        ${w}
        vec2 coords = offsetToCoords(offset, ${v}, ${T});
        float value = getColorAsFloat(${m.texture2D}(A, coords));
        return value;
      }
      `}},2834:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.globalMaxPool=e.parseMaxPoolAttributes=e.maxPool=e.parseGlobalAveragePoolAttributes=e.globalAveragePool=e.parseAveragePoolAttributes=e.averagePool=void 0;const n=t(4910),r=t(7273),o=t(5639);e.averagePool=(g,m,_)=>{l(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,v=g.attributes.getInts("kernel_shape"),T=g.attributes.getInts("strides",[]),y=g.attributes.getInts("pads",[]);if(_!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return(0,n.createAttributeWithCacheKey)({autoPad:m,ceilMode:_,countIncludePad:b,kernelShape:v,strides:T,pads:y})};const a=(g,m,_,b)=>{const[v,T]=d(g,b,_),y=r.ShapeUtil.size(v.kernelShape);let S="";v.countIncludePad?S+=`value /= float(${y});`:S+=`value /= float(${y} - pad);`;const w=`
        ${i(g[0].dims,v,"value += _X(x);",S,"0.0")}
      `;return Object.assign(Object.assign({},m),{output:{dims:T,type:g[0].type,textureType:o.TextureType.unpacked},shaderSource:w})};e.globalAveragePool=(g,m,_)=>{l(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,n.createAttributeWithCacheKey)({autoPad:"",ceilMode:0,countIncludePad:m,kernelShape:[],strides:[],pads:[]})},e.maxPool=(g,m,_)=>{l(m);const b={name:"MaxPool",inputNames:["X"],inputTypes:[o.TextureType.unpacked],cacheHint:_.cacheKey};return[g.run(Object.assign(Object.assign({},b),{get:()=>u(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"),v=g.attributes.getInts("strides",[]),T=g.attributes.getInts("pads",[]),y=g.attributes.getInt("storage_order",0),S=g.attributes.getInts("dilations",[]);if(y!==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,n.createAttributeWithCacheKey)({autoPad:m,ceilMode:_,countIncludePad:!1,kernelShape:b,strides:v,pads:T,storageOrder:y,dilations:S})};const u=(g,m,_,b)=>{const[v,T]=d(g,b,_),y=`
      ${i(g[0].dims,v,`
      value = max(_X(x), value);
    `,"","-1e5")}
    `;return Object.assign(Object.assign({},m),{output:{dims:T,type:g[0].type,textureType:o.TextureType.unpacked},shaderSource:y})},d=(g,m,_)=>{const b=g[0].dims.slice(),v=Object.hasOwnProperty.call(m,"dilations"),T=m.kernelShape.slice(),y=m.strides.slice(),S=v?m.dilations.slice():[],w=m.pads.slice();r.PoolConvUtil.adjustPoolAttributes(_,b,T,y,S,w);const k=r.PoolConvUtil.computePoolOutputShape(_,b,y,S,T,w,m.autoPad),P=Object.assign({},m);return v?Object.assign(P,{kernelShape:T,strides:y,pads:w,dilations:S,cacheKey:m.cacheKey}):Object.assign(P,{kernelShape:T,strides:y,pads:w,cacheKey:m.cacheKey}),[P,k]},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)=>(l(m),[g.run(Object.assign(Object.assign({},p),{get:()=>u(m,p,!0,h)}),m)]);const l=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.")},i=(g,m,_,b,v)=>{const T=g.length;if(m.kernelShape.length<=2){const y=m.kernelShape[m.kernelShape.length-1],S=m.strides[m.strides.length-1],w=m.pads[m.pads.length/2-1],k=m.pads[m.pads.length-1],P=g[T-1];let I="",F="",C="";if(I=w+k!==0?`
          for (int i = 0; i < ${y}; i++) {
            x[${T} - 1] = indices[${T} - 1] * ${S} - ${w} + i;
            if (x[${T} - 1] < 0 || x[${T} - 1] >= ${P}) {
              pad++;
              continue;
            }
            ${_}
          }`:`
          for (int i = 0; i < ${y}; i++) {
            x[${T} - 1] = indices[${T} - 1] * ${S} - ${w} + i;
            ${_}
          }`,m.kernelShape.length===2){const E=m.kernelShape[m.kernelShape.length-2],$=m.strides[m.strides.length-2],x=m.pads[m.pads.length/2-2],A=m.pads[m.pads.length-2],L=g[T-2];F=x+A!==0?`
            for (int j = 0; j < ${E}; j++) {
              x[${T} - 2] = indices[${T} - 2] * ${$} - ${x} + j;
              if (x[${T} - 2] < 0 || x[${T} - 2] >= ${L}) {
                pad+= ${y};
                continue;
              }
          `:`
            for (int j = 0; j < ${E}; j++) {
              x[${T} - 2] = indices[${T} - 2] * ${$} - ${x} + j;
            `,C=`
          }
        `}return`
        float process(int indices[${T}]) {
          int x[${T}];
          copyVec(indices, x);

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

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

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

        ${T>0?"}":""}
      `}const b=(0,r.getGlsl)(l.session.backend.glContext.version),v=`
      ${function(T){const y=n.ShapeUtil.computeStrides(T),S=["b","r","c"],w="index";return`
    ivec3 inputCoordsFromReshapedOutCoords(int index) {
      ${y.map((k,P)=>`int ${S[P]} = ${w} / ${k}; ${P===y.length-1?`int ${S[P+1]} = ${w} - ${S[P]} * ${k}`:`index -= ${S[P]} * ${k}`};`).join("")}
      return ivec3(b, r, c);
    }
  `}(g)}
      ${function(T){const y=n.ShapeUtil.computeStrides(T);return`
  int getFlattenedIndex(ivec3 coords) {
    // reverse y, z order
    return coords.x * ${y[0]} + coords.z * ${y[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({},c),{output:{dims:m,type:i.type,textureType:o.TextureType.packed},shaderSource:v,hasMain:!0})})(u,d,p,h)})},e.processDims3D=function(u){if(u.length===0)return[1,1,1];let d=1;for(let h=0;h<u.length-2;++h)d*=u[h];return[d,u.length>1?u[u.length-2]:1,u[u.length-1]]},e.isReshapeCheap=function(u,d){let h=!1;return h=u.length===0||d.length===0||(u.length<2||d.length<2?u[u.length-1]===d[d.length-1]:u[u.length-1]===d[d.length-1]&&u[u.length-2]===d[d.length-2]),h}},8126:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.reshape=void 0;const n=t(7273);e.reshape=(r,o)=>{const a=n.ShapeUtil.calculateReshapedDims(o[0].dims,o[1].integerData);return r.session.pack?[r.reshapePacked(o[0],a)]:[r.reshapeUnpacked(o[0],a)]}},2801:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseResizeAttributesV11=e.parseResizeAttributesV10=e.resize=void 0;const n=t(6757),r=t(5639),o=t(432),a=t(5614),u=t(3980),d={name:"Resize",inputNames:["A"],inputTypes:[r.TextureType.packed]};e.resize=(c,f,g)=>((0,u.validateInputs)(f,g),[c.run(Object.assign(Object.assign({},d),{cacheHint:g.cacheKey,get:()=>h(c,f,g)}),f)]),e.parseResizeAttributesV10=c=>(0,u.parseUpsampleAttributes)(c,10),e.parseResizeAttributesV11=c=>(0,u.parseUpsampleAttributes)(c,11);const h=(c,f,g)=>{const m=(0,n.getGlsl)(c.session.backend.glContext.version),[_,b]=p(f,g);if(_.every($=>$===1)&&g.coordinateTransformMode!=="tf_crop_and_resize")return Object.assign(Object.assign({},d),{output:{dims:b,type:f[0].type,textureType:r.TextureType.packed},hasMain:!0,shaderSource:`void main() {
                    vec4 v = ${m.texture2D}(X, TexCoords);
                    ${m.output} = v;
                }`});const v=b.length;if(v<2)throw new Error(`output dimension should be at least 2, but got ${v}`);const T=b[v-2],y=b[v-1],S=f[0].dims;if(v!==S.length)throw new Error(`output dimension should match input ${S.length}, but got ${v}`);const w=S[v-2],k=S[v-1],P=_[v-2],I=_[v-1];let F="";if(g.mode!=="linear")throw new Error(`resize (packed) does not support mode: '${g.mode}'`);switch(g.coordinateTransformMode){case"asymmetric":F=`
                    vec4 getSourceFracIndex(ivec4 coords) {
                        return vec4(coords) / scaleWHWH;
                    }
                `;break;case"half_pixel":F=`
                    vec4 getSourceFracIndex(ivec4 coords) {
                        return (vec4(coords) + 0.5) / scaleWHWH - 0.5;
                    }
                `;break;case"pytorch_half_pixel":F=`
                    vec4 getSourceFracIndex(ivec4 coords) {
                        vec4 fcoords = vec4(coords);
                        return vec4(
                            ${y}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0,
                            ${T}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0,
                            ${y}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0,
                            ${T}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0
                          );
                    }
                `;break;case"align_corners":F=`
                    vec4 getSourceFracIndex(ivec4 coords) {
                        vec4 resized = vec4(${y}.0 - 1.0, ${T}.0 - 1.0, ${y}.0 - 1.0,
                            ${T}.0 - 1.0);
                        vec4 original = vec4(${k}.0 - 1.0, ${w}.0 - 1.0, ${k}.0 - 1.0,
                            ${w}.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 C=(0,o.getCoordsDataType)(v),E=`
            const vec2 inputWH = vec2(${w}.0, ${k}.0);
            const vec4 scaleWHWH = vec4(float(${P}), float(${I}), float(${P}), float(${I}));
            ${(0,a.unpackFromChannel)()}
            ${F}
            float getAValue(int x10, int r, int c, int d) {
                return getChannel(getA(x10, r, c, d), vec2(c, d));
            }
            void main() {
                ${C} 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 < ${T-1};
                bool hasNextCol = rc.z < ${y-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({},d),{output:{dims:b,type:f[0].type,textureType:r.TextureType.packed},hasMain:!0,shaderSource:E})},p=(c,f)=>{const g=c[0].dims;let m,_=f.scales;if(_.length===0){const v=c[f.scalesInputIdx];if(v&&v.size!==0){if(c[f.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");_=l(v,f.mode,f.isResize)}else{const T=c[f.sizesInputIdx];if(!T||T.size===0)throw new Error("Either scales or sizes MUST be provided as input.");m=Array.from(T.integerData),_=i(m,g,f.mode,f.isResize)}}else if(c[f.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");const b=m||g.map((v,T)=>Math.floor(v*_[T]));return[_,b]},l=(c,f,g)=>{const m=Array.from(c.floatData);return(0,u.scalesValidation)(m,f,g),m},i=(c,f,g,m)=>{const _=f.length,b=new Array(_);for(let v=0,T=_;v<T;v++)if(f[v]===0){if(c[v]!==0)throw new Error("Input dim is zero but required output dim is non-zero.");b[v]=1}else b[v]=c[v]/f[v];return(0,u.scalesValidation)(b,g,m),b}},565:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.shape=void 0;const n=t(9240);e.shape=(o,a)=>(r(a),[new n.Tensor([a[0].dims.length],"int32",void 0,void 0,new Int32Array(a[0].dims))]);const r=o=>{if(!o||o.length!==1)throw new Error("Shape requires 1 input.")}},2444:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sliceV10=e.parseSliceAttributes=e.slice=void 0;const n=t(4910),r=t(6145),o=t(7273),a=t(5639),u={name:"Slice",inputNames:["A"],inputTypes:[a.TextureType.unpacked]};e.slice=(i,c,f)=>(h(c),[i.run(Object.assign(Object.assign({},u),{cacheHint:f.cacheKey,get:()=>d(i,c[0],f)}),c)]),e.parseSliceAttributes=i=>{const c=i.attributes.getInts("starts"),f=i.attributes.getInts("ends"),g=i.attributes.getInts("axes",[]);return(0,n.createAttributeWithCacheKey)({starts:c,ends:f,axes:g})};const d=(i,c,f)=>{const g=f.axes.length===0?c.dims.slice(0).map((S,w)=>w):f.axes,m=o.ShapeUtil.normalizeAxes(g,c.dims.length),_=f.starts.map((S,w)=>S>c.dims[m[w]]-1?c.dims[m[w]]:o.ShapeUtil.normalizeAxis(S,c.dims[m[w]])),b=f.ends.map((S,w)=>S>c.dims[m[w]]-1?c.dims[m[w]]:o.ShapeUtil.normalizeAxis(S,c.dims[m[w]])),v=c.dims.slice(),T=[];for(let S=0;S<m.length;S++)v[m[S]]=b[S]-_[S],_[S]>0&&T.push(`outputIdx[${m[S]}] += ${_[S]};`);const y=`
      float process(int outputIdx[${v.length}]) {
        ${T.join(`
      `)}
        return _A(outputIdx);
      }`;return Object.assign(Object.assign({},u),{output:{dims:v,type:c.type,textureType:a.TextureType.unpacked},shaderSource:y})},h=i=>{if(!i||i.length!==1)throw new Error("Slice requires 1 input.");if(r.NUMBER_TYPES.indexOf(i[0].type)===-1)throw new Error("Invalid input type.")};e.sliceV10=(i,c)=>{l(c);const f=p(i,c);return[i.run(Object.assign(Object.assign({},u),{cacheHint:f.cacheKey,get:()=>d(i,c[0],f)}),[c[0]])]};const p=(i,c)=>{if(!i.session.isInitializer(c[1].dataId)||!i.session.isInitializer(c[2].dataId)||c.length>=4&&!i.session.isInitializer(c[3].dataId)||c.length>=5&&!i.session.isInitializer(c[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(c.length>=5&&c[4].integerData.some(_=>_!==1))throw new Error("currently non-1 steps is not supported for Slice");const f=Array.from(c[1].integerData),g=Array.from(c[2].integerData),m=c.length>=4?Array.from(c[3].integerData):[];return{starts:f,ends:g,axes:m,cacheKey:`${m};${f};${g}`}},l=i=>{if(!i||i.length<3||i.length>5)throw new Error("Invalid input number.");if(i[1].type!=="int32"||i[1].dims.length!==1)throw new Error("Invalid input type.");if(i[2].type!=="int32"||i[2].dims.length!==1)throw new Error("Invalid input type.");if(i.length>=4&&(i[3].type!=="int32"||i[3].dims.length!==1))throw new Error("Invalid input type.");if(i.length>=5&&(i[4].type!=="int32"||i[4].dims.length!==1))throw new Error("Invalid input type.")}},815:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.softmaxV13=e.parseSoftmaxAttributesV13=e.parseSoftmaxAttributes=e.softmax=void 0;const n=t(4910),r=t(7273),o=t(6757),a=t(5639),u=t(5707),d={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 v=_[0].dims.slice(),T=r.ShapeUtil.normalizeAxis(b.axis,v.length),y=r.ShapeUtil.sizeToDimension(v,T),S=r.ShapeUtil.sizeFromDimension(v,T);return l(m,_,b,y,S)},e.parseSoftmaxAttributes=m=>(0,n.createAttributeWithCacheKey)({axis:m.attributes.getInt("axis",1)}),e.parseSoftmaxAttributesV13=m=>(0,n.createAttributeWithCacheKey)({axis:m.attributes.getInt("axis",-1)}),e.softmaxV13=(m,_,b)=>{g(_);const v=_[0].dims.slice(),T=r.ShapeUtil.normalizeAxis(b.axis,v.length),y=v.length,S=T!==y-1,w=[];let k,P=[],I=[];S&&(P=Array.from({length:y}).map(($,x)=>x),P[T]=y-1,P[y-1]=T,P.map($=>w.push(v[$])),k=(0,n.createAttributeWithCacheKey)({perm:P}),I=(0,u.transpose)(m,_,k));const F=S?r.ShapeUtil.sizeToDimension(w,y-1):r.ShapeUtil.sizeToDimension(v,y-1),C=S?r.ShapeUtil.sizeFromDimension(w,y-1):r.ShapeUtil.sizeFromDimension(v,y-1),E=l(m,S?I:_,b,F,C);return S?(0,u.transpose)(m,E,k):E};const l=(m,_,b,v,T)=>{const y=i(m,_[0],v,T,[v]),S=m.run(Object.assign(Object.assign({},d),{cacheHint:b.cacheKey,get:()=>y}),_),w=c(m,_[0],v,T,y.output.dims,[v]),k=m.run(Object.assign(Object.assign({},h),{cacheHint:b.cacheKey,get:()=>w}),[_[0],S]),P=f(m,_[0],v,T,y.output.dims,w.output.dims);return[m.run(Object.assign(Object.assign({},p),{cacheHint:b.cacheKey,get:()=>P}),[_[0],S,k])]},i=(m,_,b,v,T)=>{const[y,S]=m.calculateTextureWidthAndHeight(_.dims,a.TextureType.unpacked),w=T.length;if(b<1||v<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");const k=(0,o.getGlsl)(m.session.backend.glContext.version),P=`
      float process(int[${w}] indices) {
        int logical_row_start_offset = indices[0] * ${v};

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

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

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

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

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

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

      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:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseSplitAttributes=e.split=void 0;const n=t(4910),r=t(7273),o=t(5639),a={name:"Split",inputNames:["A"],inputTypes:[o.TextureType.unpacked]};e.split=(p,l,i)=>{h(l);const c=r.ShapeUtil.normalizeAxis(i.axis,l[0].dims.length),f=u(p,l,c,i),g=[];for(let m=0;m<f;++m)g.push(p.run(Object.assign(Object.assign({},a),{cacheHint:`${i.cacheKey};${m}`,get:()=>d(p,l[0],i,c,m)}),l));return g},e.parseSplitAttributes=p=>{const l=p.attributes.getInt("axis",0),i=p.attributes.getInts("split",[]),c=p.outputs.length;return(0,n.createAttributeWithCacheKey)({axis:l,split:i,numOutputs:c})};const u=(p,l,i,c)=>{const[,f]=r.SplitUtil.splitShape(l[0].dims,i,c.split,c.numOutputs);return f.length},d=(p,l,i,c,f)=>{const[g,m]=r.SplitUtil.splitShape(l.dims,c,i.split,i.numOutputs),_=m[f],b=g[f],v=`
      float process(int indices[${b.length}]) {
        indices[${c}] += ${_};
        return _A(indices);
      }
    `;return Object.assign(Object.assign({},a),{cacheHint:`${i.cacheKey}:${f}`,output:{dims:b,type:l.type,textureType:o.TextureType.unpacked},shaderSource:v})},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:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseSqueezeAttributes=e.squeezeV13=e.squeeze=void 0;const n=t(7273);e.squeeze=(a,u,d)=>{r(u);const h=n.ShapeUtil.squeezeShape(u[0].dims,d);return[a.reshapeUnpacked(u[0],h)]},e.squeezeV13=(a,u)=>(o(u),(0,e.squeeze)(a,[u[0]],Array.from(u[1].integerData))),e.parseSqueezeAttributes=a=>a.attributes.getInts("axes");const r=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:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sum=void 0;const n=t(6757),r=t(5639);e.sum=(u,d)=>{a(d);const h={name:"Sum",inputNames:d.map((p,l)=>`X${l}`),inputTypes:new Array(d.length).fill(r.TextureType.unpacked)};return[u.run(Object.assign(Object.assign({},h),{get:()=>o(u,d,h)}),d)]};const o=(u,d,h)=>{const p=(0,n.getGlsl)(u.session.backend.glContext.version),l=d[0].dims.slice(),i=`
      void main() {
        vec4 result = ${d.map((c,f)=>`${p.texture2D}(X${f},TexCoords)`).join(" + ")};
        ${p.output} = result;
      }
    `;return Object.assign(Object.assign({},h),{output:{dims:l,type:d[0].type,textureType:r.TextureType.unpacked},hasMain:!0,shaderSource:i})},a=u=>{if(!u||u.length===0)throw new Error("Sum requires inputs.");const d=u[0].dims.length;for(let h=1;h<u.length;h++){if(d!==u[h].dims.length)throw new Error("Input shapes are mismatched.");for(let p=0;p<d;p++)if(u[0].dims[p]!==u[h].dims[p])throw new Error("Input shapes are not matched.")}if(u[0].type!=="float32"&&u[0].type!=="float64")throw new Error("Invalid input type.");for(let h=1;h<u.length;h++)if(u[0].type!==u[h].type)throw new Error("Input types are not matched.")}},5944:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tile=void 0;const n=t(6145),r=t(5639);e.tile=(u,d)=>{a(d);const h={name:"Tile",inputNames:["A"],inputTypes:[r.TextureType.unpacked]};return[u.run(Object.assign(Object.assign({},h),{get:()=>o(u,d,h)}),d)]};const o=(u,d,h)=>{const p=d[0].dims.slice(),l=new Array(p.length),i=[];for(let g=0;g<p.length;g++)l[g]=p[g]*d[1].numberData[g],i.push(`inputIdx[${g}] = int(mod(float(outputIdx[${g}]), ${p[g]}.));`);const c=l.length,f=`
      float process(int outputIdx[${c}]) {
        int inputIdx[${c}];
        ${i.join(`
`)}
        return _A(inputIdx);
      }
    `;return Object.assign(Object.assign({},h),{output:{dims:l,type:d[0].type,textureType:r.TextureType.unpacked},shaderSource:f})},a=u=>{if(!u||u.length!==2)throw new Error("Tile requires 2 input.");if(u[1].dims.length!==1)throw new Error("The second input shape must 1 dimension.");if(u[1].dims[0]!==u[0].dims.length)throw new Error("Invalid input shape.");if(n.NUMBER_TYPES.indexOf(u[0].type)===-1)throw new Error("Invalid input type.");if(u[1].type!=="int32"&&u[1].type!=="int16")throw new Error("Invalid repeat type.")}},5707:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseTransposeAttributes=e.transpose=void 0;const n=t(4910),r=t(7273),o=t(5639),a={name:"Transpose",inputNames:["A"],inputTypes:[o.TextureType.unpacked]};e.transpose=(i,c,f)=>(l(c),[i.run(Object.assign(Object.assign({},a),{cacheHint:f.cacheKey,get:()=>u(i,c[0],f.perm)}),c)]),e.parseTransposeAttributes=i=>(0,n.createAttributeWithCacheKey)({perm:i.attributes.getInts("perm",[])});const u=(i,c,f)=>{const g=c.dims;f=d(g,f);const m=h(g,f),_=g.length,b=`
      ${p("perm",f,_)}
      float process(int indices[${_}]) {
        int a[${_}];
        perm(a, indices);
        return _A(a);
      }`;return Object.assign(Object.assign({},a),{output:{dims:m,type:c.type,textureType:o.TextureType.unpacked},shaderSource:b})},d=(i,c)=>(c&&c.length!==i.length&&(c=[...i.keys()].reverse()),c),h=(i,c)=>(c=d(i,c),r.ShapeUtil.sortBasedOnPerm(i,c)),p=(i,c,f)=>{const g=[];g.push(`void ${i}(out int a[${f}], int src[${f}]) {`);for(let m=0;m<f;++m)g.push(`	a[${c[m]}]=src[${m}];`);return g.push("	}"),g.join(`
`)},l=i=>{if(!i||i.length!==1)throw new Error("Transpose requires 1 input.");if(i[0].type!=="float32"&&i[0].type!=="float64")throw new Error("input should be float tensor")}},2488:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.encodeAsUint8=void 0;const n=t(6757),r=t(5639);e.encodeAsUint8=(o,a)=>{const u=a.shape,d=(0,n.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 = ${d.texture2D}(X,TexCoords).r;
      ${d.output} = encodeAsUint8(value);
    }`,p={name:"Uint8Encode",inputTypes:[r.TextureType.unpacked],inputNames:["X"],output:{dims:u,type:a.tensor.type,textureType:r.TextureType.downloadUint8AsFloat},shaderSource:h,hasMain:!0};return o.executeProgram(p,[a.tensor])}},9087:(s,e,t)=>{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 n=t(4910),r=t(7273),o=t(1997),a=t(6757),u=t(5639);function d(){return E("abs")}function h(){return E("acos")}function p(){return E("asin")}function l(){return E("atan")}function i(){return E("ceil")}function c(){return E("cos")}function f(A){const L="elu";return{body:`
  const float alpha = float(${A});

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

  float ${B}_(float a) {
    return clamp(a, min, max);
  }
  vec4 ${B}_(vec4 v) {
    return clamp(v, min, max);
  }
  `,name:B,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 v(A){const L="leakyRelu";return{body:`
  const float alpha = float(${A});

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

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

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

      ${T}

      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?`
    ${y}
    float process(int indices[4]) {
      int input_index = 0;
      int output_index = coordsToOffset(TexCoords, ${g}, ${m});

      ${T}

      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]);
    }`:`
    ${y}
    float process(int indices[2]) {
      int input_index = 0;
      int output_index = coordsToOffset(TexCoords, ${g}, ${m});

      ${T}

      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:f,type:h[0].type,textureType:o.TextureType.unpacked},shaderSource:S,variables:[{name:"scales",type:"int",arrayLength:p.scales.length,data:p.scales.map(w=>Math.ceil(w))}]})};e.validateInputs=(d,h)=>{if(!d||h.opset<9&&d.length!==1||h.opset>=9&&h.opset<11&&d.length!==2||h.opset>=11&&d.length<2)throw new Error("invalid inputs.");if(h.scales.length>0&&d[0].dims.length!==h.scales.length)throw new Error("Invalid input shape.");if(d[0].type==="string")throw new Error("Invalid input tensor types.")},e.scalesValidation=(d,h,p)=>{if(p){for(const l of d)if(l<=0)throw new Error("Scale value should be greater than 0.")}else for(const l of d)if(l<1)throw new Error("Scale value should be greater than or equal to 1.");if(!(h!=="linear"&&h!=="cubic"||d.length===2||d.length===4&&d[0]===1&&d[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:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ProgramManager=void 0;const n=t(2235),r=t(1315),o=t(8897),a=t(6757);e.ProgramManager=class{constructor(u,d,h){this.profiler=u,this.glContext=d,this.textureLayoutStrategy=h,this.repo=new Map,this.attributesBound=!1}getArtifact(u){return this.repo.get(u)}setArtifact(u,d){this.repo.set(u,d)}run(u,d,h){var p;this.profiler.event("op",`ProgramManager.run ${(p=u.programInfo.name)!==null&&p!==void 0?p:"unknown kernel"}`,()=>{var l;const i=this.glContext.gl,c=u.program;i.useProgram(c);try{this.bindOutput(h),this.attributesBound||this.bindAttributes(u.attribLocations),this.bindUniforms(u.uniformLocations,(l=u.programInfo.variables)!==null&&l!==void 0?l:[],d)}catch(f){throw r.Logger.error("ProgramManager",u.programInfo.shaderSource),f}this.profiler.event("backend","GlContext.draw()",()=>{this.glContext.draw()})},this.glContext)}dispose(){this.vertexShader&&this.glContext.deleteShader(this.vertexShader),this.repo.forEach(u=>this.glContext.deleteProgram(u.program))}build(u,d,h){return this.profiler.event("backend","ProgramManager.build",()=>{const p=new o.GlslPreprocessor(this.glContext,u,d,h),l=p.preprocess(),i=this.compile(l);return{programInfo:u,program:i,uniformLocations:this.getUniformLocations(i,p.context.programInfo.inputNames,p.context.programInfo.variables),attribLocations:this.getAttribLocations(i)}})}compile(u){if(!this.vertexShader){r.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)}n.env.debug&&r.Logger.verbose("ProrgramManager",`FragShader:
${u}
`);const d=this.glContext.compileShader(u,this.glContext.gl.FRAGMENT_SHADER),h=this.glContext.createProgram(this.vertexShader,d);return this.glContext.deleteShader(d),h}bindOutput(u){const d=u.width,h=u.height;r.Logger.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${d}/${h}, shape=${u.shape}, type=${u.tensor.type}`),this.glContext.attachFramebuffer(u.texture,d,h)}bindAttributes(u){const d=u.position,h=u.textureCoord;this.glContext.setVertexAttributes(d,h),this.attributesBound=!0}bindUniforms(u,d,h){var p;const l=this.glContext.gl;let i=0;for(const{name:c,type:f,location:g,arrayLength:m}of u){const _=(p=d.find(b=>b.name===c))===null||p===void 0?void 0:p.data;if(f!=="sampler2D"&&!_)throw new Error(`variable '${c}' does not have data defined in program info`);switch(f){case"sampler2D":this.bindTexture(h[i],g,i),i++;break;case"float":m?l.uniform1fv(g,_):l.uniform1f(g,_);break;case"int":m?l.uniform1iv(g,_):l.uniform1i(g,_);break;default:throw new Error(`Uniform not implemented: ${f}`)}}}bindTexture(u,d,h){this.glContext.bindTextureToUniform(u.texture,h,d)}getAttribLocations(u){return{position:this.getAttribLocation(u,"position"),textureCoord:this.getAttribLocation(u,"textureCoord")}}getUniformLocations(u,d,h){const p=[];if(d)for(const l of d)p.push({name:l,type:"sampler2D",location:this.getUniformLocation(u,l)});if(h)for(const l of h)p.push(Object.assign(Object.assign({},l),{location:this.getUniformLocation(u,l.name)}));return p}getUniformLocation(u,d){const h=this.glContext.gl.getUniformLocation(u,d);if(h===null)throw new Error(`Uniform ${d} not found.`);return h}getAttribLocation(u,d){return this.glContext.gl.getAttribLocation(u,d)}}},2171:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLSessionHandler=void 0;const n=t(1315),r=t(5881),o=t(7860),a=t(4110),u=t(2757),d=t(7618),h=t(5243);e.WebGLSessionHandler=class{constructor(p,l){this.backend=p,this.context=l,this.layoutStrategy=new d.PreferLogicalStrategy(p.glContext.maxTextureSize),this.programManager=new u.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 l=p.getValues().filter(i=>i.from===-1&&i.tensor).map(i=>i.tensor.dataId);this.initializers=new Set(l)}isInitializer(p){return!!this.initializers&&this.initializers.has(p)}addInitializer(p){this.initializers.add(p)}getTextureData(p,l){return l?this.packedTextureDataCache.get(p):this.unpackedTextureDataCache.get(p)}setTextureData(p,l,i=!1){n.Logger.verbose("WebGLSessionHandler","Storing Texture data in cache"),i?this.packedTextureDataCache.set(p,l):this.unpackedTextureDataCache.set(p,l)}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,l,i){const c=(0,r.resolveOperator)(p,l,a.WEBGL_OP_RESOLVE_RULES);return{impl:c.opImpl,context:c.opInit?c.opInit(p,i):p}}}},9622:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Uint8DataEncoder=e.RGBAFloatDataEncoder=e.RedFloat32DataEncoder=void 0;const n=t(1315);e.RedFloat32DataEncoder=class{constructor(r,o=1){if(o===1)this.internalFormat=r.R32F,this.format=r.RED,this.textureType=r.FLOAT,this.channelSize=o;else{if(o!==4)throw new Error(`Invalid number of channels: ${o}`);this.internalFormat=r.RGBA32F,this.format=r.RGBA,this.textureType=r.FLOAT,this.channelSize=o}}encode(r,o){let a,u;return r.constructor!==Float32Array&&(n.Logger.warning("Encoder","data was not of type Float32; creating new Float32Array"),u=new Float32Array(r)),o*this.channelSize>r.length?(n.Logger.warning("Encoder","Source data too small. Allocating larger array"),u=r,a=this.allocate(o*this.channelSize),u.forEach((d,h)=>a[h]=d)):(u=r,a=u),a}allocate(r){return new Float32Array(4*r)}decode(r,o){return this.channelSize===1?r.filter((a,u)=>u%4==0).subarray(0,o):r.subarray(0,o)}},e.RGBAFloatDataEncoder=class{constructor(r,o=1,a){if(o!==1&&o!==4)throw new Error(`Invalid number of channels: ${o}`);this.internalFormat=r.RGBA,this.format=r.RGBA,this.channelSize=o,this.textureType=a||r.FLOAT}encode(r,o){let a=r;return this.channelSize===1&&(n.Logger.verbose("Encoder","Exploding into a larger array"),a=this.allocate(o),r.forEach((u,d)=>a[4*d]=u)),a}allocate(r){return new Float32Array(4*r)}decode(r,o){return this.channelSize===1?r.filter((a,u)=>u%4==0).subarray(0,o):r.subarray(0,o)}},e.Uint8DataEncoder=class{constructor(r,o=1){if(this.channelSize=4,o===1)this.internalFormat=r.ALPHA,this.format=r.ALPHA,this.textureType=r.UNSIGNED_BYTE,this.channelSize=o;else{if(o!==4)throw new Error(`Invalid number of channels: ${o}`);this.internalFormat=r.RGBA,this.format=r.RGBA,this.textureType=r.UNSIGNED_BYTE,this.channelSize=o}}encode(r,o){return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}allocate(r){return new Uint8Array(r*this.channelSize)}decode(r,o){if(r instanceof Uint8Array)return r.subarray(0,o);throw new Error(`Invalid array type: ${r.constructor}`)}}},7618:(s,e,t)=>{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 n=t(1315),r=t(7273);function o(p,l){const i=[],c=[],f=l!=null&&Array.isArray(l)&&l.length===0,g=l==null||f?null:a(l,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&&(i.push(p[_]),c.push(_)),g[m]<=_&&m++}p[_]!==1&&(i.push(p[_]),c.push(_))}return{newShape:i,keptDims:c}}function a(p,l){const i=l.length;return p=p==null?l.map((c,f)=>f):[].concat(p),(0,r.assert)(p.every(c=>c>=-i&&c<i),()=>`All values in axis param must be in range [-${i}, ${i}) but got axis ${p}`),(0,r.assert)(p.every(u),()=>`All values in axis param must be integers but got axis ${p}`),p.map(c=>c<0?i+c:c)}function u(p){return p%1==0}function d(p){if(p.length===0)return 1;let l=p[0];for(let i=1;i<p.length;i++)l*=p[i];return l}function h(p){const l=Math.ceil(Math.sqrt(p));return[l,Math.ceil(p/l)]}e.AlwaysKeepOriginalSizeStrategy=class{constructor(p){this.maxTextureSize=p}computeTextureWH(p,l){if(p.length===0)return[1,1];const i=this.maxTextureSize;if(l&&l.breakAxis!==void 0){const g=l.breakAxis>=p.length?1:p.slice(l.breakAxis).reduce((_,b)=>_*b),m=l.breakAxis<=0?1:p.slice(0,l.breakAxis).reduce((_,b)=>_*b);if(!(g>i||m>i))return[g,m];n.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${p}, breakAxis:${l.breakAxis}`)}const c=p.reduce((g,m)=>g*m);let f=Math.floor(Math.sqrt(c));for(;f<i&&f<c&&c%f!=0;f++);if(f>=i||c%f!=0)throw new Error(`The given dimensions are outside this GPU's boundaries: ${p}`);return[f,c/f]}},e.PreferLogicalStrategy=class{constructor(p){this.maxTextureSize=p}computeTextureWH(p,l){const i=this.computeTexture(p,l);return l&&l.isPacked&&(i[0]/=2,i[1]/=2),l&&l.reverseWH?[i[1],i[0]]:i}computeTexture(p,l){const i=l&&l.isPacked;if(p.length===0)return i?[2,2]:[1,1];let c=this.maxTextureSize;if(l&&l.breakAxis!==void 0){const m=l.breakAxis>=p.length?1:p.slice(l.breakAxis).reduce((b,v)=>b*v),_=l.breakAxis<=0?1:p.slice(0,l.breakAxis).reduce((b,v)=>b*v);if(!(m>c||_>c))return[m,_];n.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${p}, breakAxis:${l.breakAxis}`)}let f=p.slice(0);i&&(c*=2,f=f.map((m,_)=>_>=f.length-2?f[_]%2==0?f[_]:f[_]+1:f[_]),f.length===1&&(f=[2,f[0]])),f.length!==2&&(f=o(f).newShape);const g=d(f);return f.length<=1&&g<=c?[1,g]:f.length===2&&f[0]<=c&&f[1]<=c?f:f.length===3&&f[0]*f[1]<=c&&f[2]<=c?[f[0]*f[1],f[2]]:f.length===3&&f[0]<=c&&f[1]*f[2]<=c?[f[0],f[1]*f[2]]:f.length===4&&f[0]*f[1]*f[2]<=c&&f[3]<=c?[f[0]*f[1]*f[2],f[3]]:f.length===4&&f[0]<=c&&f[1]*f[2]*f[3]<=c?[f[0],f[1]*f[2]*f[3]]:i?h(g/4).map(m=>2*m):h(g)}},e.squeezeShape=o,e.parseAxisParam=a,e.isInt=u,e.sizeFromShape=d,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,l=2){return d(p.slice(0,p.length-l))}},3314:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createTextureLayoutFromShape=e.calculateTextureWidthAndHeight=e.createTextureLayoutFromTextureType=void 0;const n=t(7273),r=t(5639);e.createTextureLayoutFromTextureType=(o,a,u)=>{const d=u===r.TextureType.unpacked||u===r.TextureType.unpackedReversed?1:4,h=u===r.TextureType.packed,p=u===r.TextureType.unpackedReversed||u===r.TextureType.packed,l=u===r.TextureType.packedLastDimension?a.length-1:void 0,i=u===r.TextureType.packedLastDimension?a.map((c,f)=>f===a.length-1?4*c:c):void 0;return(0,e.createTextureLayoutFromShape)(o,a,d,i,{isPacked:h,reverseWH:p,breakAxis:l})},e.calculateTextureWidthAndHeight=(o,a,u)=>{const d=(0,e.createTextureLayoutFromTextureType)(o,a,u);return[d.width,d.height]},e.createTextureLayoutFromShape=(o,a,u=1,d,h)=>{const p=!(!h||!h.isPacked),[l,i]=o.computeTextureWH(p&&d||a,h),c=a.length;let f=a.slice(0);if(c===0&&(f=[1]),u===1)d=a;else if(p){if(u!==4)throw new Error("a packed texture must be 4-channel");d=a,c>0&&(f[c-1]=Math.ceil(f[c-1]/2)),c>1&&(f[c-2]=Math.ceil(f[c-2]/2))}else if(!d)throw new Error("Unpacked shape is needed when using channels > 1");return{width:l,height:i,channels:u,isPacked:p,shape:f,strides:n.ShapeUtil.computeStrides(f),unpackedShape:d,reversedWH:h&&h.reverseWH}}},5243:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TextureManager=void 0;const n=t(1315);e.TextureManager=class{constructor(r,o,a,u){this.glContext=r,this.layoutStrategy=o,this.profiler=a,this.config=u,this.pendingRead=new Map,u.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(r,o,a,u){const d=this.toEncoderType(r),h=this.glContext.getEncoder(d,o.channels||1,u);if(o.isPacked&&u===1)throw new Error("not implemented");const p=o.width,l=o.height;let i,c;if(this.config.reuseTextures){i=`${p}x${l}_${h.format}_${h.internalFormat}_${h.textureType}`,c=this.inUseTextures.get(i),c||(c=[],this.inUseTextures.set(i,c));const g=this.idleTextures.get(i);if(g&&g.length>0){const m=g.pop();return c.push(m),u===1&&this.glContext.updateTexture(m,p,l,h,this.toTextureData(r,a)),m}}n.Logger.verbose("TextureManager",`Creating new texture of size ${o.width}x${o.height}`);const f=this.glContext.allocateTexture(p,l,h,this.toTextureData(r,a));return this.config.reuseTextures&&(c.push(f),this.textureLookup.set(f,i)),f}readTexture(r,o,a){return a||(a=1),this.profiler.event("backend","TextureManager.readTexture",()=>{const u=r.shape.reduce((h,p)=>h*p)*a,d=this.glContext.readTexture(r.texture,r.width,r.height,u,this.toEncoderType(o),a);return this.toTensorData(o,d)})}async readTextureAsync(r,o,a){const u=r.tensor.dataId;if(a||(a=1),this.pendingRead.has(u)){const d=this.pendingRead.get(u);return new Promise(h=>d==null?void 0:d.push(h))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(u,[]);const d=r.shape.reduce((i,c)=>i*c)*a;await this.glContext.createAndWaitForFence();const h=this.glContext.readTexture(r.texture,r.width,r.height,d,this.toEncoderType(o),a),p=this.toTensorData(o,h),l=this.pendingRead.get(u);return this.pendingRead.delete(u),l==null||l.forEach(i=>i(p)),p})}readUint8TextureAsFloat(r){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{const o=r.shape.reduce((u,d)=>u*d),a=this.glContext.readTexture(r.texture,r.width,r.height,4*o,"byte",4);return new Float32Array(a.buffer,a.byteOffset,o)})}releaseTexture(r,o){let a;if(this.config.reuseTextures&&(a=this.textureLookup.get(r.texture),a)){o&&this.textureLookup.delete(a);const u=this.inUseTextures.get(a);if(u){const d=u.indexOf(r.texture);if(d!==-1){u.splice(d,1);let h=this.idleTextures.get(a);h||(h=[],this.idleTextures.set(a,h)),h.push(r.texture)}}}a&&!o||(n.Logger.verbose("TextureManager",`Deleting texture of size ${r.width}x${r.height}`),this.glContext.deleteTexture(r.texture))}toTensorData(r,o){switch(r){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 ${r} is not supported`)}}toTextureData(r,o){if(o)return o instanceof Float32Array?o:new Float32Array(o)}toEncoderType(r){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}},5639:(s,e)=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.TextureType=void 0,(t=e.TextureType||(e.TextureType={}))[t.unpacked=0]="unpacked",t[t.unpackedReversed=1]="unpackedReversed",t[t.packed=2]="packed",t[t.downloadUint8AsFloat=3]="downloadUint8AsFloat",t[t.packedLastDimension=4]="packedLastDimension"},432:(s,e,t)=>{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 n=t(7273);e.getPackedShape=function(r){const o=r.length;return r.slice(0,o-1).concat(r[o-1]/4)},e.repeatedTry=async function(r,o=u=>0,a){return new Promise((u,d)=>{let h=0;const p=()=>{if(r())return void u();h++;const l=o(h);a!=null&&h>=a?d():setTimeout(p,l)};p()})},e.generateShaderFuncNameFromInputSamplerName=function(r){return(0,n.assert)(r!==void 0&&r.length!==0,()=>"empty string found for sampler name"),"get"+r.charAt(0).toUpperCase()+r.slice(1)},e.generateShaderFuncNameFromInputSamplerNameAtOutCoords=function(r){return(0,n.assert)(r!==void 0&&r.length!==0,()=>"empty string found for sampler name"),"get"+r.charAt(0).toUpperCase()+r.slice(1)+"AtOutCoords"},e.squeezeInputShape=function(r,o){let a=JSON.parse(JSON.stringify(r));return a=o,a},e.getSqueezedParams=function(r,o){return o.map(a=>r[a]).join(", ")},e.getCoordsDataType=function(r){if(r<=1)return"int";if(r===2)return"ivec2";if(r===3)return"ivec3";if(r===4)return"ivec4";if(r===5)return"ivec5";if(r===6)return"ivec6";throw Error(`GPU for rank ${r} is not yet supported`)},e.getGlChannels=function(r=6){return["x","y","z","w","u","v"].slice(0,r)}},3389:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createNewWebGLContext=e.createWebGLContext=void 0;const n=t(1315),r=t(3524),o={};function a(u,d){let h;const p={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1};if((!d||d==="webgl2")&&(h=u.getContext("webgl2",p),h))try{return new r.WebGLContext(h,2)}catch(l){n.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${l}`)}if((!d||d==="webgl")&&(h=u.getContext("webgl",p)||u.getContext("experimental-webgl",p),h))try{return new r.WebGLContext(h,1)}catch(l){n.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${l}`)}throw new Error("WebGL is not supported")}e.createWebGLContext=function u(d){let h;if(d&&d!=="webgl2"||!("webgl2"in o)?d&&d!=="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)}(),d)}catch{h=a(function(){if(typeof document>"u")throw new TypeError("failed to create canvas: document is not supported");const i=document.createElement("canvas");return i.width=1,i.height=1,i}(),d)}d=d||h.version===1?"webgl":"webgl2";const p=h.gl;return o[d]=h,p.isContextLost()?(delete o[d],u(d)):(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(s,e,t){var n=this&&this.__createBinding||(Object.create?function(p,l,i,c){c===void 0&&(c=i);var f=Object.getOwnPropertyDescriptor(l,i);f&&!("get"in f?!l.__esModule:f.writable||f.configurable)||(f={enumerable:!0,get:function(){return l[i]}}),Object.defineProperty(p,c,f)}:function(p,l,i,c){c===void 0&&(c=i),p[c]=l[i]}),r=this&&this.__setModuleDefault||(Object.create?function(p,l){Object.defineProperty(p,"default",{enumerable:!0,value:l})}:function(p,l){p.default=l}),o=this&&this.__importStar||function(p){if(p&&p.__esModule)return p;var l={};if(p!=null)for(var i in p)i!=="default"&&Object.prototype.hasOwnProperty.call(p,i)&&n(l,p,i);return r(l,p),l};Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLContext=e.linearSearchLastTrue=void 0;const a=t(2235),u=o(t(9622)),d=t(432);function h(p){let l=0;for(;l<p.length&&p[l]();++l);return l-1}e.linearSearchLastTrue=h,e.WebGLContext=class{constructor(p,l){this.frameBufferBound=!1,this.itemsToPoll=[],this.gl=p,this.version=l,this.getExtensions(),this.vertexbuffer=this.createVertexbuffer(),this.framebuffer=this.createFramebuffer(),this.queryVitalParameters()}allocateTexture(p,l,i,c){const f=this.gl,g=f.createTexture();f.bindTexture(f.TEXTURE_2D,g),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,f.NEAREST),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,f.NEAREST),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);const m=c?i.encode(c,p*l):null;return f.texImage2D(f.TEXTURE_2D,0,i.internalFormat,p,l,0,i.format,i.textureType,m),this.checkError(),g}updateTexture(p,l,i,c,f){const g=this.gl;g.bindTexture(g.TEXTURE_2D,p);const m=c.encode(f,l*i);g.texSubImage2D(g.TEXTURE_2D,0,0,0,l,i,c.format,c.textureType,m),this.checkError()}attachFramebuffer(p,l,i){const c=this.gl;c.bindTexture(c.TEXTURE_2D,p),c.bindFramebuffer(c.FRAMEBUFFER,this.framebuffer),c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,p,0),this.checkError(),c.viewport(0,0,l,i),c.scissor(0,0,l,i)}readTexture(p,l,i,c,f,g){const m=this.gl;g||(g=1),this.frameBufferBound||this.attachFramebuffer(p,l,i);const _=this.getEncoder(f,g),b=_.allocate(l*i);return m.bindTexture(m.TEXTURE_2D,p),m.framebufferTexture2D(m.FRAMEBUFFER,m.COLOR_ATTACHMENT0,m.TEXTURE_2D,p,0),m.readPixels(0,0,l,i,m.RGBA,_.textureType,b),this.checkError(),_.decode(b,c)}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,l){const i=this.gl;i.vertexAttribPointer(p,3,i.FLOAT,!1,20,0),i.enableVertexAttribArray(p),l!==-1&&(i.vertexAttribPointer(l,2,i.FLOAT,!1,20,12),i.enableVertexAttribArray(l)),this.checkError()}createProgram(p,l){const i=this.gl,c=i.createProgram();return i.attachShader(c,p),i.attachShader(c,l),i.linkProgram(c),c}compileShader(p,l){const i=this.gl,c=i.createShader(l);if(!c)throw new Error(`createShader() returned null with type ${l}`);if(i.shaderSource(c,p),i.compileShader(c),i.getShaderParameter(c,i.COMPILE_STATUS)===!1)throw new Error(`Failed to compile shader: ${i.getShaderInfoLog(c)}
Shader source:
${p}`);return c}deleteShader(p){this.gl.deleteShader(p)}bindTextureToUniform(p,l,i){const c=this.gl;c.activeTexture(c.TEXTURE0+l),this.checkError(),c.bindTexture(c.TEXTURE_2D,p),this.checkError(),c.uniform1i(i,l),this.checkError()}draw(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.checkError()}checkError(){if(a.env.debug){const p=this.gl,l=p.getError();let i="";switch(l){case p.NO_ERROR:return;case p.INVALID_ENUM:i="INVALID_ENUM";break;case p.INVALID_VALUE:i="INVALID_VALUE";break;case p.INVALID_OPERATION:i="INVALID_OPERATION";break;case p.INVALID_FRAMEBUFFER_OPERATION:i="INVALID_FRAMEBUFFER_OPERATION";break;case p.OUT_OF_MEMORY:i="OUT_OF_MEMORY";break;case p.CONTEXT_LOST_WEBGL:i="CONTEXT_LOST_WEBGL";break;default:i=`Unknown WebGL Error: ${l.toString(16)}`}throw new Error(i)}}deleteTexture(p){this.gl.deleteTexture(p)}deleteProgram(p){this.gl.deleteProgram(p)}getEncoder(p,l,i=0){if(this.version===2)return new u.RedFloat32DataEncoder(this.gl,l);switch(p){case"float":return i===1||this.isRenderFloat32Supported?new u.RGBAFloatDataEncoder(this.gl,l):new u.RGBAFloatDataEncoder(this.gl,l,this.textureHalfFloatExtension.HALF_FLOAT_OES);case"int":throw new Error("not implemented");case"byte":return new u.Uint8DataEncoder(this.gl,l);default:throw new Error(`Invalid dataType: ${p}`)}}clearActiveTextures(){const p=this.gl;for(let l=0;l<this.maxTextureImageUnits;++l)p.activeTexture(p.TEXTURE0+l),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,l=p.createBuffer();if(!l)throw new Error("createBuffer() returned null");const i=this.createDefaultGeometry();return p.bindBuffer(p.ARRAY_BUFFER,l),p.bufferData(p.ARRAY_BUFFER,i,p.STATIC_DRAW),this.checkError(),l}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,l=p.createTexture();p.bindTexture(p.TEXTURE_2D,l);const i=this.version===2?p.RGBA32F:p.RGBA;p.texImage2D(p.TEXTURE_2D,0,i,1,1,0,p.RGBA,p.FLOAT,null);const c=p.createFramebuffer();p.bindFramebuffer(p.FRAMEBUFFER,c),p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,l,0);const f=p.checkFramebufferStatus(p.FRAMEBUFFER)===p.FRAMEBUFFER_COMPLETE;return p.bindTexture(p.TEXTURE_2D,null),p.bindFramebuffer(p.FRAMEBUFFER,null),p.deleteTexture(l),p.deleteFramebuffer(c),f}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 l,i,c,f,g;try{l=p.createTexture(),i=p.createFramebuffer(),p.bindTexture(p.TEXTURE_2D,l);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,i),p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,l,0),p.enable(p.BLEND),c=p.createShader(p.VERTEX_SHADER),!!c&&(p.shaderSource(c,"void main(){}"),p.compileShader(c),f=p.createShader(p.FRAGMENT_SHADER),!!f&&(p.shaderSource(f,"precision highp float;void main(){gl_FragColor=vec4(0.5);}"),p.compileShader(f),g=p.createProgram(),!!g&&(p.attachShader(g,c),p.attachShader(g,f),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),c&&p.deleteShader(c),f&&p.deleteShader(f),i&&(p.bindFramebuffer(p.FRAMEBUFFER,null),p.deleteFramebuffer(i)),l&&(p.bindTexture(p.TEXTURE_2D,null),p.deleteTexture(l))}}beginTimer(){if(this.version===2&&this.disjointTimerQueryWebgl2Extension){const p=this.gl,l=this.disjointTimerQueryWebgl2Extension,i=p.createQuery();return p.beginQuery(l.TIME_ELAPSED_EXT,i),i}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,l=this.disjointTimerQueryWebgl2Extension;p.endQuery(l.TIME_ELAPSED_EXT)}}isTimerResultAvailable(p){let l=!1,i=!1;if(this.version!==2||!this.disjointTimerQueryWebgl2Extension)throw new Error("WebGL1 profiling currently not supported");{const c=this.gl,f=this.disjointTimerQueryWebgl2Extension;l=c.getQueryParameter(p,c.QUERY_RESULT_AVAILABLE),i=c.getParameter(f.GPU_DISJOINT_EXT)}return l&&!i}getTimerResult(p){let l=0;if(this.version!==2)throw new Error("WebGL1 profiling currently not supported");{const i=this.gl;l=i.getQueryParameter(p,i.QUERY_RESULT),i.deleteQuery(p)}return l/1e6}async waitForQueryAndGetTime(p){return await(0,d.repeatedTry)(()=>this.isTimerResultAvailable(p)),this.getTimerResult(p)}async createAndWaitForFence(){const p=this.createFence(this.gl);return this.pollFence(p)}createFence(p){let l;const i=p,c=i.fenceSync(i.SYNC_GPU_COMMANDS_COMPLETE,0);return p.flush(),l=c===null?()=>!0:()=>{const f=i.clientWaitSync(c,0,0);return f===i.ALREADY_SIGNALED||f===i.CONDITION_SATISFIED},{query:c,isFencePassed:l}}async pollFence(p){return new Promise(l=>{this.addItemToPoll(()=>p.isFencePassed(),()=>l())})}pollItems(){const p=h(this.itemsToPoll.map(l=>l.isDoneFn));for(let l=0;l<=p;++l){const{resolveFn:i}=this.itemsToPoll[l];i()}this.itemsToPoll=this.itemsToPoll.slice(p+1)}async addItemToPoll(p,l){this.itemsToPoll.push({isDoneFn:p,resolveFn:l}),this.itemsToPoll.length>1||await(0,d.repeatedTry)(()=>(this.pollItems(),this.itemsToPoll.length===0))}}},6496:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ExecutionPlan=void 0;const n=t(1315);class r{constructor(a,u){this.op=a,this.node=u}}e.ExecutionPlan=class{constructor(o,a,u){this.graph=o,this.profiler=u,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((u,d)=>new r(u,a[d])),this.reset(),this._starter=[],this._ops.forEach((u,d)=>{let h=!0;for(const p of u.node.inputs)if(!this._values[p]&&this.graph.getInputIndices().indexOf(p)===-1){h=!1;break}h&&this._starter.push(d)})})}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 u=o.createInferenceHandler(),d=this.graph.getInputIndices();if(a.length!==d.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${a.length} expected: ${d.length}`);a.forEach((f,g)=>{const m=d[g];this._values[m]=f});const h=this._starter.slice(0),p=this.graph.getValues(),l=this.graph.getNodes();let i=0;for(;i<h.length;){const f=h[i++],g=this._ops[f],m=g.node.inputs.map(T=>this._values[T]);if(m.indexOf(void 0)!==-1)throw new Error(`unresolved input detected: op: ${g.node}`);const _=m;n.Logger.verbose("ExecPlan",`Runing op:${g.node.name} (${_.map((T,y)=>`'${g.node.inputs[y]}': ${T.type}[${T.dims.join(",")}]`).join(", ")})`);const b=await this.profiler.event("node",g.node.name,async()=>g.op.impl(u,_,g.op.context));if(b.length!==g.node.outputs.length)throw new Error("the size of output does not match model definition.");b.forEach((T,y)=>{const S=g.node.outputs[y];if(this._values[S])throw new Error(`output [${S}] already has value: op:${g.node.name}`);this._values[S]=T});const v=new Set;b.forEach((T,y)=>{const S=g.node.outputs[y];for(const w of p[S].to){const k=l[w];let P=!0;for(const I of k.inputs)if(!this._values[I]){P=!1;break}P&&v.add(w)}}),h.push(...v)}const c=[];for(let f=0;f<this.graph.getOutputIndices().length;f++){const g=this.graph.getOutputIndices()[f],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,c.push(m)}return n.Logger.verbose("ExecPlan","disposing of inferenceHandler"),u.dispose(),c})}}},4662:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Graph=void 0;const n=t(6874),r=t(5127),o=t(2446),a=t(9240),u=t(7273);var d=r.onnxruntime.experimental.fbs;e.Graph={from:(i,c)=>new l(i,c)};class h{constructor(c){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,c&&(this.type=u.ProtoUtil.tensorValueTypeFromProto(c.type.tensorType))}get from(){return this._from}get to(){return this._to}}class p{constructor(c,f){c instanceof o.onnx.NodeProto?(this.name=c.name,this.opType=c.opType,this.attributes=new n.Attribute(c.attribute)):c instanceof d.Node&&(this.name=f??c.name(),this.opType=c.opType(),this.attributes=new n.Attribute(u.ProtoUtil.tensorAttributesFromORTFormat(c))),this.inputs=[],this.outputs=[],this.executeNode=!0}}class l{constructor(c,f){if(!c)throw new TypeError("graph is empty");this.buildGraph(c),this.transformGraph(f),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(c){if(c instanceof o.onnx.GraphProto)this.buildGraphFromOnnxFormat(c);else{if(!(c instanceof d.Graph))throw new TypeError("Graph type is not supported.");this.buildGraphFromOrtFormat(c)}}buildGraphFromOnnxFormat(c){const f=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];const g=new Map;if(!c.input)throw new Error("missing information in graph: input");const m=[];for(const _ of c.input){if(f.has(_.name))throw new Error(`duplicated input name: ${_.name}`);const b=this._allData.push(new h(_))-1;f.set(_.name,b),m.push(_.name)}if(!c.initializer)throw new Error("missing information in graph: initializer");for(const _ of c.initializer){let b=f.get(_.name);if(b===void 0){const v=new h;v.type={shape:{dims:u.ProtoUtil.tensorDimsFromProto(_.dims)},tensorType:u.ProtoUtil.tensorDataTypeFromProto(_.dataType)},b=this._allData.push(v)-1,f.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(!c.output)throw new Error("missing information in graph: output");for(const _ of c.output){if(f.has(_.name))throw new Error(`duplicated output name: ${_.name}`);const b=this._allData.push(new h(_))-1;f.set(_.name,b),this._allOutputIndices.push(b),this._allOutputNames.push(_.name)}if(!c.node)throw new Error("missing information in graph: node");for(const _ of c.node){if(!_.name)for(let v=0;;v++){const T=`unnamed_${_.opType}_${v}`;if(!g.has(T)){_.name=T;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[_],v=c.node[_];if(!v.output)throw new Error(`missing output for node: ${v.name}`);for(const T of v.output){let y=f.get(T);if(y===void 0&&(y=this._allData.push(new h)-1,f.set(T,y)),b.outputs.push(y),this._allData[y]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${y}`);if(this._allData[y]._from=_,v.opType==="Constant"){if(!v.attribute||v.attribute.length!==1||!v.attribute[0].t)throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(!v.output||v.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[y]._from=-1,this._allData[y].tensor=a.Tensor.fromProto(v.attribute[0].t)}}}for(let _=0;_<this._nodes.length;_++){const b=this._nodes[_],v=c.node[_];if(!v.input)throw new Error(`missing input for node: ${v.name}`);for(const T of v.input){const y=f.get(T);if(y===void 0){if(T===""&&(v.input.length===3||v.input.length===4)&&v.opType==="Resize")continue;throw new Error(`unrecognized input '${T}' for node: ${v.name}`)}b.inputs.push(y),this._allData[y]._to.push(_)}}return!0}buildGraphFromOrtFormat(c){var f,g,m;const _=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];const b=new Map,v=[];for(let T=0;T<c.inputsLength();T++){const y=c.inputs(T);if(_.has(y))throw new Error(`duplicated input name: ${y}`);for(let S=0;S<c.nodeArgsLength();S++)if(((f=c.nodeArgs(S))===null||f===void 0?void 0:f.name())===y){const w=new h;if(((m=(g=c.nodeArgs(S))===null||g===void 0?void 0:g.type())===null||m===void 0?void 0:m.valueType())!==d.TypeInfoValue.tensor_type)throw new Error("Unexpected value type for the nodeArg.");const k=c.nodeArgs(S).type().value(new d.TensorTypeAndShape),P=u.ProtoUtil.tensorDataTypeFromProto(k.elemType()),I=k.shape(),F=[];for(let E=0;E<I.dimLength();E++)F.push(u.LongUtil.longToNumber(I.dim(E).value().dimValue()));w.type={shape:{dims:F},tensorType:P};const C=this._allData.push(w)-1;_.set(y,C),v.push(y)}}for(let T=0;T<c.initializersLength();T++){const y=c.initializers(T);let S=_.get(y.name());if(S===void 0){const w=new h,k=u.ProtoUtil.tensorDimsFromORTFormat(y),P=u.ProtoUtil.tensorDataTypeFromProto(y.dataType());w.type={shape:{dims:k},tensorType:P},S=this._allData.push(w)-1,_.set(y.name(),S)}this._allData[S]._from=-1,this._allData[S].tensor=a.Tensor.fromOrtTensor(y)}for(let T=0;T<this._allData.length;T++)this._allData[T].tensor||(this._allInputIndices.push(T),this._allInputNames.push(v[T]));for(let T=0;T<c.outputsLength();T++){const y=c.outputs(T);if(_.has(y))throw new Error(`duplicated output name: ${y}`);const S=this._allData.push(new h)-1;_.set(y,S),this._allOutputIndices.push(S),this._allOutputNames.push(y)}if(!c.nodes)throw new Error("missing information in graph: node");for(let T=0;T<c.nodesLength();T++){const y=c.nodes(T);let S=y.name();if(!S)for(let k=0;S=`unnamed_${y.opType()}_${k}`,b.has(S);k++);if(b.has(S))throw new Error(`duplicated node name: ${S}`);const w=this._nodes.push(new p(y,S))-1;b.set(S,w)}for(let T=0;T<this._nodes.length;T++){const y=this._nodes[T],S=c.nodes(T);if(S==null)throw new Error(`No node exists at index ${T}`);if((S==null?void 0:S.outputsLength())===0)throw new Error(`missing output for node: ${S.name}`);for(let w=0;w<(S==null?void 0:S.outputsLength());w++){const k=S==null?void 0:S.outputs(w);let P=_.get(k);if(P===void 0&&(P=this._allData.push(new h)-1,_.set(k,P)),y.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=T,S.opType()==="Constant"){if(S.attributesLength()!==1||!S.attributes(0).t())throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(S.outputsLength()!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");y.outputs.pop(),y.executeNode=!1,this._allData[P]._from=-1,this._allData[P].tensor=a.Tensor.fromOrtTensor(S.attributes(0).t())}}}for(let T=0;T<this._nodes.length;T++){const y=this._nodes[T],S=c.nodes(T);if(S.inputsLength()===0)throw new Error(`missing input for node: ${S.name}`);for(let w=0;w<S.inputsLength();w++){const k=S.inputs(w),P=_.get(k);if(P===void 0)throw new Error(`unrecognized input '${k}' for node: ${S.name()}`);y.inputs.push(P),this._allData[P]._to.push(T)}}}checkIsAcyclic(){const c=new Set;this._allInputIndices.forEach(m=>{this._allData[m]._to.forEach(_=>{c.add(_)})});const f=Array.from(c),g=new Array(this._nodes.length).fill("white");for(;f.length>0;){const m=f.pop();g[m]==="gray"?g[m]="black":(f.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(v=>{if(g[v]==="gray")throw new Error("model graph is cyclic");g[v]==="white"&&f.push(v)})}))}}transformGraph(c){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),c&&c.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let c=0;const f=new Array(this._nodes.length,0);let g=0;for(let m=0;m<this._nodes.length;m++)f[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=f[_._from]);for(let b=0;b<_._to.length;b++){if(!(_._to[b]>=0))throw new Error("Trying to update a removed node");_._to[b]=f[_._to[b]]}}c=0;for(let m=0;m<this._allData.length;m++)if(this._allData[m].from!==-2||this._allOutputIndices.indexOf(m+c)!==-1){if(c>0){let _=-1;this._allData[m].from!==void 0&&this._allData[m].from!==-1?(_=this._nodes[this._allData[m].from].outputs.indexOf(m+c),_!==-1&&(this._nodes[this._allData[m].from].outputs[_]=m)):(_=this._allInputIndices.indexOf(m+c),_!==-1&&(this._allInputIndices[_]=m)),this._allData[m].to.forEach(b=>{_=this._nodes[b].inputs.indexOf(m+c),_!==-1&&(this._nodes[b].inputs[_]=m)}),this._allData[m].to.length===0&&(_=this._allOutputIndices.indexOf(m+c),_!==-1&&(this._allOutputIndices[_]=m))}}else c++,this._allData.splice(m,1),m--}deleteNode(c){const f=this._nodes[c];if(f.outputs.length>1){for(let v=1;v<f.outputs.length;v++)if(this._allData[f.outputs[v]].to.length>0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ")}f.executeNode=!1;const g=f.inputs[0],m=f.outputs[0],_=this._allData[m].to;for(let v=0;v<f.inputs.length;v++){const T=this._allData[f.inputs[v]].to.indexOf(c);if(T===-1)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[f.inputs[v]].to.splice(T,1)}this._allData[m]._to=[];const b=this._allOutputIndices.indexOf(m);if(b!==-1&&(this._allOutputIndices[b]=g),_&&_.length>0)for(const v of _){const T=this._nodes[v].inputs.indexOf(m);if(T===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[v].inputs[T]=g,this._allData[g].to.push(v)}}removeAllDropoutNodes(){let c=0;for(const f of this._nodes){if(f.opType==="Dropout"){if(f.inputs.length!==1)throw new Error("Dropout nodes should only contain one input. ");if(f.outputs.length!==1&&f.outputs.length!==2)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(f.outputs.length===2&&this._allData[f.outputs[1]]._to.length!==0)throw new Error("Dropout nodes's second output should not be referenced by other nodes");this.deleteNode(c)}c++}}removeAllIdentityNodes(){let c=0;for(const f of this._nodes)f.opType==="Identity"&&this.deleteNode(c),c++}isActivation(c){switch(c.opType){case"Relu":case"Sigmoid":case"Clip":return!0;default:return!1}}fuseConvActivationNodes(){for(const c of this._nodes)if(c.opType==="Conv"){const f=this._allData[c.outputs[0]]._to;if(f.length===1&&this.isActivation(this._nodes[f[0]])){const g=this._nodes[f[0]];if(g.opType==="Clip")if(g.inputs.length===1)try{c.attributes.set("activation_params","floats",[g.attributes.getFloat("min"),g.attributes.getFloat("max")])}catch{c.attributes.set("activation_params","floats",[u.MIN_CLIP,u.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;c.attributes.set("activation_params","floats",[this._allData[g.inputs[1]].tensor.floatData[0],this._allData[g.inputs[2]].tensor.floatData[0]])}c.attributes.set("activation","string",g.opType),this.deleteNode(f[0])}}}}},1315:(s,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.now=e.Profiler=e.Logger=void 0;const t={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},n={none:new class{log(p,l,i){}},console:new class{log(p,l,i){console.log(`${this.color(p)} ${i?"\x1B[35m"+i+"\x1B[0m ":""}${l}`)}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}`)}}}},r={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1};let o={"":r};function a(p,l,i,c){if(l===void 0)return f=p,{verbose:a.verbose.bind(null,f),info:a.info.bind(null,f),warning:a.warning.bind(null,f),error:a.error.bind(null,f),fatal:a.fatal.bind(null,f)};if(i===void 0)u(p,l);else if(typeof i=="number"&&c===void 0)u(p,l);else if(typeof i=="string"&&c===void 0)u(p,i,0,l);else{if(typeof i!="string"||typeof c!="number")throw new TypeError("input is valid");u(p,i,0,l)}var f}function u(p,l,i,c){const f=o[c||""]||o[""];t[p]<t[f.minimalSeverity]||(f.logDateTime&&(l=`${new Date().toISOString()}|${l}`),f.logSourceLocation,n[f.provider].log(p,l,c))}(function(p){function l(c){o={},i("",c||{})}function i(c,f){if(c==="*")l(f);else{const g=o[c]||r;o[c]={provider:f.provider||g.provider,minimalSeverity:f.minimalSeverity||g.minimalSeverity,logDateTime:f.logDateTime===void 0?g.logDateTime:f.logDateTime,logSourceLocation:f.logSourceLocation===void 0?g.logSourceLocation:f.logSourceLocation}}}p.verbose=function(c,f){p("verbose",c,f)},p.info=function(c,f){p("info",c,f)},p.warning=function(c,f){p("warning",c,f)},p.error=function(c,f){p("error",c,f)},p.fatal=function(c,f){p("fatal",c,f)},p.reset=l,p.set=i,p.setWithEnv=function(c){const f={};c.logLevel&&(f.minimalSeverity=c.logLevel),i("",f)}})(a||(a={})),e.Logger=a;class d{constructor(l,i,c,f,g,m){this.category=l,this.name=i,this.startTime=c,this.endCallback=f,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(l,i,c,f){this.category=l,this.name=i,this.startTime=c,this.endTime=f}}e.Profiler=class{static create(p){return p===void 0?new this:new this(p.maxNumberEvents,p.flushBatchSize,p.flushIntervalInMilliseconds)}constructor(p,l,i){this._started=!1,this._flushPointer=0,this._started=!1,this._maxNumberEvents=p===void 0?1e4:p,this._flushBatchSize=l===void 0?10:l,this._flushIntervalInMilliseconds=i===void 0?5e3:i}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,l,i,c){const f=this._started?this.begin(p,l,c):void 0;let g=!1;const m=i();if(m&&typeof m.then=="function")return g=!0,new Promise((_,b)=>{m.then(async v=>{f&&await f.end(),_(v)},async v=>{f&&await f.end(),b(v)})});if(!g&&f){const _=f.end();if(_&&typeof _.then=="function")return new Promise((b,v)=>{_.then(()=>{b(m)},T=>{v(T)})})}return m}begin(p,l,i){if(!this._started)throw new Error("profiler is not started yet");if(i===void 0){const c=(0,e.now)();return this.flush(c),new d(p,l,c,f=>this.endSync(f))}{const c=i.beginTimer();return new d(p,l,0,async f=>this.end(f),c,i)}}async end(p){const l=await p.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new h(p.category,p.name,p.startTime,l)),this.flush(l))}endSync(p){const l=(0,e.now)();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new h(p.category,p.name,p.startTime,l)),this.flush(l))}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 l=this._flushPointer;this._flushPointer<l+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:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Model=void 0;const n=t(5686),r=t(4662),o=t(5127),a=t(2446),u=t(7273);var d=o.onnxruntime.experimental.fbs;e.Model=class{constructor(){}load(h,p,l){if(!l)try{return void this.loadFromOnnxFormat(h,p)}catch(i){if(l!==void 0)throw i}this.loadFromOrtFormat(h,p)}loadFromOnnxFormat(h,p){const l=a.onnx.ModelProto.decode(h);if(u.LongUtil.longToNumber(l.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=l.opsetImport.map(i=>({domain:i.domain,version:u.LongUtil.longToNumber(i.version)})),this._graph=r.Graph.from(l.graph,p)}loadFromOrtFormat(h,p){const l=new n.flatbuffers.ByteBuffer(h),i=d.InferenceSession.getRootAsInferenceSession(l).model();if(u.LongUtil.longToNumber(i.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let c=0;c<i.opsetImportLength();c++){const f=i.opsetImport(c);this._opsets.push({domain:f==null?void 0:f.domain(),version:u.LongUtil.longToNumber(f.version())})}this._graph=r.Graph.from(i.graph(),p)}get graph(){return this._graph}get opsets(){return this._opsets}}},6145:(s,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:(s,e)=>{function t(n,r){if(r.endsWith("+")){const o=Number.parseInt(r.substring(0,r.length-1),10);return!isNaN(o)&&o<=n}if(r.split("-").length===2){const o=r.split("-"),a=Number.parseInt(o[0],10),u=Number.parseInt(o[1],10);return!isNaN(a)&&!isNaN(u)&&a<=n&&n<=u}return Number.parseInt(r,10)===n}Object.defineProperty(e,"__esModule",{value:!0}),e.resolveOperator=void 0,e.resolveOperator=function(n,r,o){for(const a of o){const u=a[0],d=a[1],h=a[2],p=a[3],l=a[4];if(n.opType===u){for(const i of r)if((i.domain===d||i.domain==="ai.onnx"&&d==="")&&t(i.version,h))return{opImpl:p,opInit:l}}}throw new TypeError(`cannot resolve operator '${n.opType}' with opsets: ${r.map(a=>`${a.domain||"ai.onnx"} v${a.version}`).join(", ")}`)}},5127:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.onnxruntime=void 0;const n=t(5686);var r,o;r=e.onnxruntime||(e.onnxruntime={}),function(a){(function(u){u[u.UNDEFINED=0]="UNDEFINED",u[u.FLOAT=1]="FLOAT",u[u.INT=2]="INT",u[u.STRING=3]="STRING",u[u.TENSOR=4]="TENSOR",u[u.GRAPH=5]="GRAPH",u[u.FLOATS=6]="FLOATS",u[u.INTS=7]="INTS",u[u.STRINGS=8]="STRINGS",u[u.TENSORS=9]="TENSORS",u[u.GRAPHS=10]="GRAPHS",u[u.SPARSE_TENSOR=11]="SPARSE_TENSOR",u[u.SPARSE_TENSORS=12]="SPARSE_TENSORS"})(a.AttributeType||(a.AttributeType={}))}((o=r.experimental||(r.experimental={})).fbs||(o.fbs={})),function(a){(function(u){(function(d){(function(h){h[h.UNKNOWN=0]="UNKNOWN",h[h.VALUE=1]="VALUE",h[h.PARAM=2]="PARAM"})(d.DimensionValueType||(d.DimensionValueType={}))})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){(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"})(d.TensorDataType||(d.TensorDataType={}))})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){(function(h){h[h.Primitive=0]="Primitive",h[h.Fused=1]="Fused"})(d.NodeType||(d.NodeType={}))})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){(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"})(d.TypeInfoValue||(d.TypeInfoValue={}))})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsShape(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsShape(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}dim(l,i){let c=this.bb.__offset(this.bb_pos,4);return c?(i||new a.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+4*l),this.bb):null}dimLength(){let l=this.bb.__offset(this.bb_pos,4);return l?this.bb.__vector_len(this.bb_pos+l):0}static startShape(l){l.startObject(1)}static addDim(l,i){l.addFieldOffset(0,i,0)}static createDimVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addOffset(i[c]);return l.endVector()}static startDimVector(l,i){l.startVector(4,i,4)}static endShape(l){return l.endObject()}static createShape(l,i){return h.startShape(l),h.addDim(l,i),h.endShape(l)}}d.Shape=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsDimension(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsDimension(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}value(l){let i=this.bb.__offset(this.bb_pos,4);return i?(l||new a.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}denotation(l){let i=this.bb.__offset(this.bb_pos,6);return i?this.bb.__string(this.bb_pos+i,l):null}static startDimension(l){l.startObject(2)}static addValue(l,i){l.addFieldOffset(0,i,0)}static addDenotation(l,i){l.addFieldOffset(1,i,0)}static endDimension(l){return l.endObject()}static createDimension(l,i,c){return h.startDimension(l),h.addValue(l,i),h.addDenotation(l,c),h.endDimension(l)}}d.Dimension=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsDimensionValue(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsDimensionValue(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}dimType(){let l=this.bb.__offset(this.bb_pos,4);return l?this.bb.readInt8(this.bb_pos+l):a.experimental.fbs.DimensionValueType.UNKNOWN}dimValue(){let l=this.bb.__offset(this.bb_pos,6);return l?this.bb.readInt64(this.bb_pos+l):this.bb.createLong(0,0)}dimParam(l){let i=this.bb.__offset(this.bb_pos,8);return i?this.bb.__string(this.bb_pos+i,l):null}static startDimensionValue(l){l.startObject(3)}static addDimType(l,i){l.addFieldInt8(0,i,a.experimental.fbs.DimensionValueType.UNKNOWN)}static addDimValue(l,i){l.addFieldInt64(1,i,l.createLong(0,0))}static addDimParam(l,i){l.addFieldOffset(2,i,0)}static endDimensionValue(l){return l.endObject()}static createDimensionValue(l,i,c,f){return h.startDimensionValue(l),h.addDimType(l,i),h.addDimValue(l,c),h.addDimParam(l,f),h.endDimensionValue(l)}}d.DimensionValue=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsTensorTypeAndShape(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsTensorTypeAndShape(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}elemType(){let l=this.bb.__offset(this.bb_pos,4);return l?this.bb.readInt32(this.bb_pos+l):a.experimental.fbs.TensorDataType.UNDEFINED}shape(l){let i=this.bb.__offset(this.bb_pos,6);return i?(l||new a.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}static startTensorTypeAndShape(l){l.startObject(2)}static addElemType(l,i){l.addFieldInt32(0,i,a.experimental.fbs.TensorDataType.UNDEFINED)}static addShape(l,i){l.addFieldOffset(1,i,0)}static endTensorTypeAndShape(l){return l.endObject()}static createTensorTypeAndShape(l,i,c){return h.startTensorTypeAndShape(l),h.addElemType(l,i),h.addShape(l,c),h.endTensorTypeAndShape(l)}}d.TensorTypeAndShape=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsMapType(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsMapType(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}keyType(){let l=this.bb.__offset(this.bb_pos,4);return l?this.bb.readInt32(this.bb_pos+l):a.experimental.fbs.TensorDataType.UNDEFINED}valueType(l){let i=this.bb.__offset(this.bb_pos,6);return i?(l||new a.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}static startMapType(l){l.startObject(2)}static addKeyType(l,i){l.addFieldInt32(0,i,a.experimental.fbs.TensorDataType.UNDEFINED)}static addValueType(l,i){l.addFieldOffset(1,i,0)}static endMapType(l){return l.endObject()}static createMapType(l,i,c){return h.startMapType(l),h.addKeyType(l,i),h.addValueType(l,c),h.endMapType(l)}}d.MapType=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsSequenceType(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsSequenceType(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}elemType(l){let i=this.bb.__offset(this.bb_pos,4);return i?(l||new a.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}static startSequenceType(l){l.startObject(1)}static addElemType(l,i){l.addFieldOffset(0,i,0)}static endSequenceType(l){return l.endObject()}static createSequenceType(l,i){return h.startSequenceType(l),h.addElemType(l,i),h.endSequenceType(l)}}d.SequenceType=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(u.fbs||(u.fbs={})).EdgeEnd=class{constructor(){this.bb=null,this.bb_pos=0}__init(d,h){return this.bb_pos=d,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(d,h,p,l){return d.prep(4,12),d.writeInt32(l),d.writeInt32(p),d.writeInt32(h),d.offset()}}})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsNodeEdge(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsNodeEdge(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}nodeIndex(){let l=this.bb.__offset(this.bb_pos,4);return l?this.bb.readUint32(this.bb_pos+l):0}inputEdges(l,i){let c=this.bb.__offset(this.bb_pos,6);return c?(i||new a.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+c)+12*l,this.bb):null}inputEdgesLength(){let l=this.bb.__offset(this.bb_pos,6);return l?this.bb.__vector_len(this.bb_pos+l):0}outputEdges(l,i){let c=this.bb.__offset(this.bb_pos,8);return c?(i||new a.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+c)+12*l,this.bb):null}outputEdgesLength(){let l=this.bb.__offset(this.bb_pos,8);return l?this.bb.__vector_len(this.bb_pos+l):0}static startNodeEdge(l){l.startObject(3)}static addNodeIndex(l,i){l.addFieldInt32(0,i,0)}static addInputEdges(l,i){l.addFieldOffset(1,i,0)}static startInputEdgesVector(l,i){l.startVector(12,i,4)}static addOutputEdges(l,i){l.addFieldOffset(2,i,0)}static startOutputEdgesVector(l,i){l.startVector(12,i,4)}static endNodeEdge(l){return l.endObject()}static createNodeEdge(l,i,c,f){return h.startNodeEdge(l),h.addNodeIndex(l,i),h.addInputEdges(l,c),h.addOutputEdges(l,f),h.endNodeEdge(l)}}d.NodeEdge=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsNode(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsNode(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}name(l){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.__string(this.bb_pos+i,l):null}docString(l){let i=this.bb.__offset(this.bb_pos,6);return i?this.bb.__string(this.bb_pos+i,l):null}domain(l){let i=this.bb.__offset(this.bb_pos,8);return i?this.bb.__string(this.bb_pos+i,l):null}sinceVersion(){let l=this.bb.__offset(this.bb_pos,10);return l?this.bb.readInt32(this.bb_pos+l):0}index(){let l=this.bb.__offset(this.bb_pos,12);return l?this.bb.readUint32(this.bb_pos+l):0}opType(l){let i=this.bb.__offset(this.bb_pos,14);return i?this.bb.__string(this.bb_pos+i,l):null}type(){let l=this.bb.__offset(this.bb_pos,16);return l?this.bb.readInt32(this.bb_pos+l):a.experimental.fbs.NodeType.Primitive}executionProviderType(l){let i=this.bb.__offset(this.bb_pos,18);return i?this.bb.__string(this.bb_pos+i,l):null}inputs(l,i){let c=this.bb.__offset(this.bb_pos,20);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+4*l,i):null}inputsLength(){let l=this.bb.__offset(this.bb_pos,20);return l?this.bb.__vector_len(this.bb_pos+l):0}outputs(l,i){let c=this.bb.__offset(this.bb_pos,22);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+4*l,i):null}outputsLength(){let l=this.bb.__offset(this.bb_pos,22);return l?this.bb.__vector_len(this.bb_pos+l):0}attributes(l,i){let c=this.bb.__offset(this.bb_pos,24);return c?(i||new a.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+4*l),this.bb):null}attributesLength(){let l=this.bb.__offset(this.bb_pos,24);return l?this.bb.__vector_len(this.bb_pos+l):0}inputArgCounts(l){let i=this.bb.__offset(this.bb_pos,26);return i?this.bb.readInt32(this.bb.__vector(this.bb_pos+i)+4*l):0}inputArgCountsLength(){let l=this.bb.__offset(this.bb_pos,26);return l?this.bb.__vector_len(this.bb_pos+l):0}inputArgCountsArray(){let l=this.bb.__offset(this.bb_pos,26);return l?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+l),this.bb.__vector_len(this.bb_pos+l)):null}implicitInputs(l,i){let c=this.bb.__offset(this.bb_pos,28);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+4*l,i):null}implicitInputsLength(){let l=this.bb.__offset(this.bb_pos,28);return l?this.bb.__vector_len(this.bb_pos+l):0}static startNode(l){l.startObject(13)}static addName(l,i){l.addFieldOffset(0,i,0)}static addDocString(l,i){l.addFieldOffset(1,i,0)}static addDomain(l,i){l.addFieldOffset(2,i,0)}static addSinceVersion(l,i){l.addFieldInt32(3,i,0)}static addIndex(l,i){l.addFieldInt32(4,i,0)}static addOpType(l,i){l.addFieldOffset(5,i,0)}static addType(l,i){l.addFieldInt32(6,i,a.experimental.fbs.NodeType.Primitive)}static addExecutionProviderType(l,i){l.addFieldOffset(7,i,0)}static addInputs(l,i){l.addFieldOffset(8,i,0)}static createInputsVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addOffset(i[c]);return l.endVector()}static startInputsVector(l,i){l.startVector(4,i,4)}static addOutputs(l,i){l.addFieldOffset(9,i,0)}static createOutputsVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addOffset(i[c]);return l.endVector()}static startOutputsVector(l,i){l.startVector(4,i,4)}static addAttributes(l,i){l.addFieldOffset(10,i,0)}static createAttributesVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addOffset(i[c]);return l.endVector()}static startAttributesVector(l,i){l.startVector(4,i,4)}static addInputArgCounts(l,i){l.addFieldOffset(11,i,0)}static createInputArgCountsVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addInt32(i[c]);return l.endVector()}static startInputArgCountsVector(l,i){l.startVector(4,i,4)}static addImplicitInputs(l,i){l.addFieldOffset(12,i,0)}static createImplicitInputsVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addOffset(i[c]);return l.endVector()}static startImplicitInputsVector(l,i){l.startVector(4,i,4)}static endNode(l){return l.endObject()}static createNode(l,i,c,f,g,m,_,b,v,T,y,S,w,k){return h.startNode(l),h.addName(l,i),h.addDocString(l,c),h.addDomain(l,f),h.addSinceVersion(l,g),h.addIndex(l,m),h.addOpType(l,_),h.addType(l,b),h.addExecutionProviderType(l,v),h.addInputs(l,T),h.addOutputs(l,y),h.addAttributes(l,S),h.addInputArgCounts(l,w),h.addImplicitInputs(l,k),h.endNode(l)}}d.Node=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsValueInfo(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsValueInfo(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}name(l){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.__string(this.bb_pos+i,l):null}docString(l){let i=this.bb.__offset(this.bb_pos,6);return i?this.bb.__string(this.bb_pos+i,l):null}type(l){let i=this.bb.__offset(this.bb_pos,8);return i?(l||new a.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}static startValueInfo(l){l.startObject(3)}static addName(l,i){l.addFieldOffset(0,i,0)}static addDocString(l,i){l.addFieldOffset(1,i,0)}static addType(l,i){l.addFieldOffset(2,i,0)}static endValueInfo(l){return l.endObject()}static createValueInfo(l,i,c,f){return h.startValueInfo(l),h.addName(l,i),h.addDocString(l,c),h.addType(l,f),h.endValueInfo(l)}}d.ValueInfo=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsTypeInfo(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsTypeInfo(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}denotation(l){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.__string(this.bb_pos+i,l):null}valueType(){let l=this.bb.__offset(this.bb_pos,6);return l?this.bb.readUint8(this.bb_pos+l):a.experimental.fbs.TypeInfoValue.NONE}value(l){let i=this.bb.__offset(this.bb_pos,8);return i?this.bb.__union(l,this.bb_pos+i):null}static startTypeInfo(l){l.startObject(3)}static addDenotation(l,i){l.addFieldOffset(0,i,0)}static addValueType(l,i){l.addFieldInt8(1,i,a.experimental.fbs.TypeInfoValue.NONE)}static addValue(l,i){l.addFieldOffset(2,i,0)}static endTypeInfo(l){return l.endObject()}static createTypeInfo(l,i,c,f){return h.startTypeInfo(l),h.addDenotation(l,i),h.addValueType(l,c),h.addValue(l,f),h.endTypeInfo(l)}}d.TypeInfo=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsOperatorSetId(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsOperatorSetId(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}domain(l){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.__string(this.bb_pos+i,l):null}version(){let l=this.bb.__offset(this.bb_pos,6);return l?this.bb.readInt64(this.bb_pos+l):this.bb.createLong(0,0)}static startOperatorSetId(l){l.startObject(2)}static addDomain(l,i){l.addFieldOffset(0,i,0)}static addVersion(l,i){l.addFieldInt64(1,i,l.createLong(0,0))}static endOperatorSetId(l){return l.endObject()}static createOperatorSetId(l,i,c){return h.startOperatorSetId(l),h.addDomain(l,i),h.addVersion(l,c),h.endOperatorSetId(l)}}d.OperatorSetId=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsTensor(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsTensor(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}name(l){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.__string(this.bb_pos+i,l):null}docString(l){let i=this.bb.__offset(this.bb_pos,6);return i?this.bb.__string(this.bb_pos+i,l):null}dims(l){let i=this.bb.__offset(this.bb_pos,8);return i?this.bb.readInt64(this.bb.__vector(this.bb_pos+i)+8*l):this.bb.createLong(0,0)}dimsLength(){let l=this.bb.__offset(this.bb_pos,8);return l?this.bb.__vector_len(this.bb_pos+l):0}dataType(){let l=this.bb.__offset(this.bb_pos,10);return l?this.bb.readInt32(this.bb_pos+l):a.experimental.fbs.TensorDataType.UNDEFINED}rawData(l){let i=this.bb.__offset(this.bb_pos,12);return i?this.bb.readUint8(this.bb.__vector(this.bb_pos+i)+l):0}rawDataLength(){let l=this.bb.__offset(this.bb_pos,12);return l?this.bb.__vector_len(this.bb_pos+l):0}rawDataArray(){let l=this.bb.__offset(this.bb_pos,12);return l?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+l),this.bb.__vector_len(this.bb_pos+l)):null}stringData(l,i){let c=this.bb.__offset(this.bb_pos,14);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+4*l,i):null}stringDataLength(){let l=this.bb.__offset(this.bb_pos,14);return l?this.bb.__vector_len(this.bb_pos+l):0}static startTensor(l){l.startObject(6)}static addName(l,i){l.addFieldOffset(0,i,0)}static addDocString(l,i){l.addFieldOffset(1,i,0)}static addDims(l,i){l.addFieldOffset(2,i,0)}static createDimsVector(l,i){l.startVector(8,i.length,8);for(let c=i.length-1;c>=0;c--)l.addInt64(i[c]);return l.endVector()}static startDimsVector(l,i){l.startVector(8,i,8)}static addDataType(l,i){l.addFieldInt32(3,i,a.experimental.fbs.TensorDataType.UNDEFINED)}static addRawData(l,i){l.addFieldOffset(4,i,0)}static createRawDataVector(l,i){l.startVector(1,i.length,1);for(let c=i.length-1;c>=0;c--)l.addInt8(i[c]);return l.endVector()}static startRawDataVector(l,i){l.startVector(1,i,1)}static addStringData(l,i){l.addFieldOffset(5,i,0)}static createStringDataVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addOffset(i[c]);return l.endVector()}static startStringDataVector(l,i){l.startVector(4,i,4)}static endTensor(l){return l.endObject()}static createTensor(l,i,c,f,g,m,_){return h.startTensor(l),h.addName(l,i),h.addDocString(l,c),h.addDims(l,f),h.addDataType(l,g),h.addRawData(l,m),h.addStringData(l,_),h.endTensor(l)}}d.Tensor=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsSparseTensor(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsSparseTensor(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}values(l){let i=this.bb.__offset(this.bb_pos,4);return i?(l||new a.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}indices(l){let i=this.bb.__offset(this.bb_pos,6);return i?(l||new a.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}dims(l){let i=this.bb.__offset(this.bb_pos,8);return i?this.bb.readInt64(this.bb.__vector(this.bb_pos+i)+8*l):this.bb.createLong(0,0)}dimsLength(){let l=this.bb.__offset(this.bb_pos,8);return l?this.bb.__vector_len(this.bb_pos+l):0}static startSparseTensor(l){l.startObject(3)}static addValues(l,i){l.addFieldOffset(0,i,0)}static addIndices(l,i){l.addFieldOffset(1,i,0)}static addDims(l,i){l.addFieldOffset(2,i,0)}static createDimsVector(l,i){l.startVector(8,i.length,8);for(let c=i.length-1;c>=0;c--)l.addInt64(i[c]);return l.endVector()}static startDimsVector(l,i){l.startVector(8,i,8)}static endSparseTensor(l){return l.endObject()}static createSparseTensor(l,i,c,f){return h.startSparseTensor(l),h.addValues(l,i),h.addIndices(l,c),h.addDims(l,f),h.endSparseTensor(l)}}d.SparseTensor=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsAttribute(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsAttribute(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}name(l){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.__string(this.bb_pos+i,l):null}docString(l){let i=this.bb.__offset(this.bb_pos,6);return i?this.bb.__string(this.bb_pos+i,l):null}type(){let l=this.bb.__offset(this.bb_pos,8);return l?this.bb.readInt32(this.bb_pos+l):a.experimental.fbs.AttributeType.UNDEFINED}f(){let l=this.bb.__offset(this.bb_pos,10);return l?this.bb.readFloat32(this.bb_pos+l):0}i(){let l=this.bb.__offset(this.bb_pos,12);return l?this.bb.readInt64(this.bb_pos+l):this.bb.createLong(0,0)}s(l){let i=this.bb.__offset(this.bb_pos,14);return i?this.bb.__string(this.bb_pos+i,l):null}t(l){let i=this.bb.__offset(this.bb_pos,16);return i?(l||new a.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}g(l){let i=this.bb.__offset(this.bb_pos,18);return i?(l||new a.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}floats(l){let i=this.bb.__offset(this.bb_pos,20);return i?this.bb.readFloat32(this.bb.__vector(this.bb_pos+i)+4*l):0}floatsLength(){let l=this.bb.__offset(this.bb_pos,20);return l?this.bb.__vector_len(this.bb_pos+l):0}floatsArray(){let l=this.bb.__offset(this.bb_pos,20);return l?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+l),this.bb.__vector_len(this.bb_pos+l)):null}ints(l){let i=this.bb.__offset(this.bb_pos,22);return i?this.bb.readInt64(this.bb.__vector(this.bb_pos+i)+8*l):this.bb.createLong(0,0)}intsLength(){let l=this.bb.__offset(this.bb_pos,22);return l?this.bb.__vector_len(this.bb_pos+l):0}strings(l,i){let c=this.bb.__offset(this.bb_pos,24);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+4*l,i):null}stringsLength(){let l=this.bb.__offset(this.bb_pos,24);return l?this.bb.__vector_len(this.bb_pos+l):0}tensors(l,i){let c=this.bb.__offset(this.bb_pos,26);return c?(i||new a.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+4*l),this.bb):null}tensorsLength(){let l=this.bb.__offset(this.bb_pos,26);return l?this.bb.__vector_len(this.bb_pos+l):0}graphs(l,i){let c=this.bb.__offset(this.bb_pos,28);return c?(i||new a.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+4*l),this.bb):null}graphsLength(){let l=this.bb.__offset(this.bb_pos,28);return l?this.bb.__vector_len(this.bb_pos+l):0}static startAttribute(l){l.startObject(13)}static addName(l,i){l.addFieldOffset(0,i,0)}static addDocString(l,i){l.addFieldOffset(1,i,0)}static addType(l,i){l.addFieldInt32(2,i,a.experimental.fbs.AttributeType.UNDEFINED)}static addF(l,i){l.addFieldFloat32(3,i,0)}static addI(l,i){l.addFieldInt64(4,i,l.createLong(0,0))}static addS(l,i){l.addFieldOffset(5,i,0)}static addT(l,i){l.addFieldOffset(6,i,0)}static addG(l,i){l.addFieldOffset(7,i,0)}static addFloats(l,i){l.addFieldOffset(8,i,0)}static createFloatsVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addFloat32(i[c]);return l.endVector()}static startFloatsVector(l,i){l.startVector(4,i,4)}static addInts(l,i){l.addFieldOffset(9,i,0)}static createIntsVector(l,i){l.startVector(8,i.length,8);for(let c=i.length-1;c>=0;c--)l.addInt64(i[c]);return l.endVector()}static startIntsVector(l,i){l.startVector(8,i,8)}static addStrings(l,i){l.addFieldOffset(10,i,0)}static createStringsVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addOffset(i[c]);return l.endVector()}static startStringsVector(l,i){l.startVector(4,i,4)}static addTensors(l,i){l.addFieldOffset(11,i,0)}static createTensorsVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addOffset(i[c]);return l.endVector()}static startTensorsVector(l,i){l.startVector(4,i,4)}static addGraphs(l,i){l.addFieldOffset(12,i,0)}static createGraphsVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addOffset(i[c]);return l.endVector()}static startGraphsVector(l,i){l.startVector(4,i,4)}static endAttribute(l){return l.endObject()}static createAttribute(l,i,c,f,g,m,_,b,v,T,y,S,w,k){return h.startAttribute(l),h.addName(l,i),h.addDocString(l,c),h.addType(l,f),h.addF(l,g),h.addI(l,m),h.addS(l,_),h.addT(l,b),h.addG(l,v),h.addFloats(l,T),h.addInts(l,y),h.addStrings(l,S),h.addTensors(l,w),h.addGraphs(l,k),h.endAttribute(l)}}d.Attribute=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsGraph(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsGraph(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}initializers(l,i){let c=this.bb.__offset(this.bb_pos,4);return c?(i||new a.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+4*l),this.bb):null}initializersLength(){let l=this.bb.__offset(this.bb_pos,4);return l?this.bb.__vector_len(this.bb_pos+l):0}nodeArgs(l,i){let c=this.bb.__offset(this.bb_pos,6);return c?(i||new a.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+4*l),this.bb):null}nodeArgsLength(){let l=this.bb.__offset(this.bb_pos,6);return l?this.bb.__vector_len(this.bb_pos+l):0}nodes(l,i){let c=this.bb.__offset(this.bb_pos,8);return c?(i||new a.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+4*l),this.bb):null}nodesLength(){let l=this.bb.__offset(this.bb_pos,8);return l?this.bb.__vector_len(this.bb_pos+l):0}maxNodeIndex(){let l=this.bb.__offset(this.bb_pos,10);return l?this.bb.readUint32(this.bb_pos+l):0}nodeEdges(l,i){let c=this.bb.__offset(this.bb_pos,12);return c?(i||new a.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+4*l),this.bb):null}nodeEdgesLength(){let l=this.bb.__offset(this.bb_pos,12);return l?this.bb.__vector_len(this.bb_pos+l):0}inputs(l,i){let c=this.bb.__offset(this.bb_pos,14);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+4*l,i):null}inputsLength(){let l=this.bb.__offset(this.bb_pos,14);return l?this.bb.__vector_len(this.bb_pos+l):0}outputs(l,i){let c=this.bb.__offset(this.bb_pos,16);return c?this.bb.__string(this.bb.__vector(this.bb_pos+c)+4*l,i):null}outputsLength(){let l=this.bb.__offset(this.bb_pos,16);return l?this.bb.__vector_len(this.bb_pos+l):0}sparseInitializers(l,i){let c=this.bb.__offset(this.bb_pos,18);return c?(i||new a.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+4*l),this.bb):null}sparseInitializersLength(){let l=this.bb.__offset(this.bb_pos,18);return l?this.bb.__vector_len(this.bb_pos+l):0}static startGraph(l){l.startObject(8)}static addInitializers(l,i){l.addFieldOffset(0,i,0)}static createInitializersVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addOffset(i[c]);return l.endVector()}static startInitializersVector(l,i){l.startVector(4,i,4)}static addNodeArgs(l,i){l.addFieldOffset(1,i,0)}static createNodeArgsVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addOffset(i[c]);return l.endVector()}static startNodeArgsVector(l,i){l.startVector(4,i,4)}static addNodes(l,i){l.addFieldOffset(2,i,0)}static createNodesVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addOffset(i[c]);return l.endVector()}static startNodesVector(l,i){l.startVector(4,i,4)}static addMaxNodeIndex(l,i){l.addFieldInt32(3,i,0)}static addNodeEdges(l,i){l.addFieldOffset(4,i,0)}static createNodeEdgesVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addOffset(i[c]);return l.endVector()}static startNodeEdgesVector(l,i){l.startVector(4,i,4)}static addInputs(l,i){l.addFieldOffset(5,i,0)}static createInputsVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addOffset(i[c]);return l.endVector()}static startInputsVector(l,i){l.startVector(4,i,4)}static addOutputs(l,i){l.addFieldOffset(6,i,0)}static createOutputsVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addOffset(i[c]);return l.endVector()}static startOutputsVector(l,i){l.startVector(4,i,4)}static addSparseInitializers(l,i){l.addFieldOffset(7,i,0)}static createSparseInitializersVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addOffset(i[c]);return l.endVector()}static startSparseInitializersVector(l,i){l.startVector(4,i,4)}static endGraph(l){return l.endObject()}static createGraph(l,i,c,f,g,m,_,b,v){return h.startGraph(l),h.addInitializers(l,i),h.addNodeArgs(l,c),h.addNodes(l,f),h.addMaxNodeIndex(l,g),h.addNodeEdges(l,m),h.addInputs(l,_),h.addOutputs(l,b),h.addSparseInitializers(l,v),h.endGraph(l)}}d.Graph=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsModel(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsModel(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}irVersion(){let l=this.bb.__offset(this.bb_pos,4);return l?this.bb.readInt64(this.bb_pos+l):this.bb.createLong(0,0)}opsetImport(l,i){let c=this.bb.__offset(this.bb_pos,6);return c?(i||new a.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+4*l),this.bb):null}opsetImportLength(){let l=this.bb.__offset(this.bb_pos,6);return l?this.bb.__vector_len(this.bb_pos+l):0}producerName(l){let i=this.bb.__offset(this.bb_pos,8);return i?this.bb.__string(this.bb_pos+i,l):null}producerVersion(l){let i=this.bb.__offset(this.bb_pos,10);return i?this.bb.__string(this.bb_pos+i,l):null}domain(l){let i=this.bb.__offset(this.bb_pos,12);return i?this.bb.__string(this.bb_pos+i,l):null}modelVersion(){let l=this.bb.__offset(this.bb_pos,14);return l?this.bb.readInt64(this.bb_pos+l):this.bb.createLong(0,0)}docString(l){let i=this.bb.__offset(this.bb_pos,16);return i?this.bb.__string(this.bb_pos+i,l):null}graph(l){let i=this.bb.__offset(this.bb_pos,18);return i?(l||new a.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}graphDocString(l){let i=this.bb.__offset(this.bb_pos,20);return i?this.bb.__string(this.bb_pos+i,l):null}static startModel(l){l.startObject(9)}static addIrVersion(l,i){l.addFieldInt64(0,i,l.createLong(0,0))}static addOpsetImport(l,i){l.addFieldOffset(1,i,0)}static createOpsetImportVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addOffset(i[c]);return l.endVector()}static startOpsetImportVector(l,i){l.startVector(4,i,4)}static addProducerName(l,i){l.addFieldOffset(2,i,0)}static addProducerVersion(l,i){l.addFieldOffset(3,i,0)}static addDomain(l,i){l.addFieldOffset(4,i,0)}static addModelVersion(l,i){l.addFieldInt64(5,i,l.createLong(0,0))}static addDocString(l,i){l.addFieldOffset(6,i,0)}static addGraph(l,i){l.addFieldOffset(7,i,0)}static addGraphDocString(l,i){l.addFieldOffset(8,i,0)}static endModel(l){return l.endObject()}static createModel(l,i,c,f,g,m,_,b,v,T){return h.startModel(l),h.addIrVersion(l,i),h.addOpsetImport(l,c),h.addProducerName(l,f),h.addProducerVersion(l,g),h.addDomain(l,m),h.addModelVersion(l,_),h.addDocString(l,b),h.addGraph(l,v),h.addGraphDocString(l,T),h.endModel(l)}}d.Model=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsKernelCreateInfos(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsKernelCreateInfos(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}nodeIndices(l){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.readUint32(this.bb.__vector(this.bb_pos+i)+4*l):0}nodeIndicesLength(){let l=this.bb.__offset(this.bb_pos,4);return l?this.bb.__vector_len(this.bb_pos+l):0}nodeIndicesArray(){let l=this.bb.__offset(this.bb_pos,4);return l?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+l),this.bb.__vector_len(this.bb_pos+l)):null}kernelDefHashes(l){let i=this.bb.__offset(this.bb_pos,6);return i?this.bb.readUint64(this.bb.__vector(this.bb_pos+i)+8*l):this.bb.createLong(0,0)}kernelDefHashesLength(){let l=this.bb.__offset(this.bb_pos,6);return l?this.bb.__vector_len(this.bb_pos+l):0}static startKernelCreateInfos(l){l.startObject(2)}static addNodeIndices(l,i){l.addFieldOffset(0,i,0)}static createNodeIndicesVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addInt32(i[c]);return l.endVector()}static startNodeIndicesVector(l,i){l.startVector(4,i,4)}static addKernelDefHashes(l,i){l.addFieldOffset(1,i,0)}static createKernelDefHashesVector(l,i){l.startVector(8,i.length,8);for(let c=i.length-1;c>=0;c--)l.addInt64(i[c]);return l.endVector()}static startKernelDefHashesVector(l,i){l.startVector(8,i,8)}static endKernelCreateInfos(l){return l.endObject()}static createKernelCreateInfos(l,i,c){return h.startKernelCreateInfos(l),h.addNodeIndices(l,i),h.addKernelDefHashes(l,c),h.endKernelCreateInfos(l)}}d.KernelCreateInfos=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsSubGraphSessionState(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsSubGraphSessionState(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}graphId(l){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.__string(this.bb_pos+i,l):null}sessionState(l){let i=this.bb.__offset(this.bb_pos,6);return i?(l||new a.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}static startSubGraphSessionState(l){l.startObject(2)}static addGraphId(l,i){l.addFieldOffset(0,i,0)}static addSessionState(l,i){l.addFieldOffset(1,i,0)}static endSubGraphSessionState(l){let i=l.endObject();return l.requiredField(i,4),i}static createSubGraphSessionState(l,i,c){return h.startSubGraphSessionState(l),h.addGraphId(l,i),h.addSessionState(l,c),h.endSubGraphSessionState(l)}}d.SubGraphSessionState=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsSessionState(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsSessionState(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}kernels(l){let i=this.bb.__offset(this.bb_pos,4);return i?(l||new a.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}subGraphSessionStates(l,i){let c=this.bb.__offset(this.bb_pos,6);return c?(i||new a.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+c)+4*l),this.bb):null}subGraphSessionStatesLength(){let l=this.bb.__offset(this.bb_pos,6);return l?this.bb.__vector_len(this.bb_pos+l):0}static startSessionState(l){l.startObject(2)}static addKernels(l,i){l.addFieldOffset(0,i,0)}static addSubGraphSessionStates(l,i){l.addFieldOffset(1,i,0)}static createSubGraphSessionStatesVector(l,i){l.startVector(4,i.length,4);for(let c=i.length-1;c>=0;c--)l.addOffset(i[c]);return l.endVector()}static startSubGraphSessionStatesVector(l,i){l.startVector(4,i,4)}static endSessionState(l){return l.endObject()}static createSessionState(l,i,c){return h.startSessionState(l),h.addKernels(l,i),h.addSubGraphSessionStates(l,c),h.endSessionState(l)}}d.SessionState=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(a){(function(u){(function(d){class h{constructor(){this.bb=null,this.bb_pos=0}__init(l,i){return this.bb_pos=l,this.bb=i,this}static getRootAsInferenceSession(l,i){return(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static getSizePrefixedRootAsInferenceSession(l,i){return l.setPosition(l.position()+n.flatbuffers.SIZE_PREFIX_LENGTH),(i||new h).__init(l.readInt32(l.position())+l.position(),l)}static bufferHasIdentifier(l){return l.__has_identifier("ORTM")}ortVersion(l){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.__string(this.bb_pos+i,l):null}model(l){let i=this.bb.__offset(this.bb_pos,6);return i?(l||new a.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}sessionState(l){let i=this.bb.__offset(this.bb_pos,8);return i?(l||new a.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}static startInferenceSession(l){l.startObject(3)}static addOrtVersion(l,i){l.addFieldOffset(0,i,0)}static addModel(l,i){l.addFieldOffset(1,i,0)}static addSessionState(l,i){l.addFieldOffset(2,i,0)}static endInferenceSession(l){return l.endObject()}static finishInferenceSessionBuffer(l,i){l.finish(i,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(l,i){l.finish(i,"ORTM",!0)}static createInferenceSession(l,i,c,f){return h.startInferenceSession(l),h.addOrtVersion(l,i),h.addModel(l,c),h.addSessionState(l,f),h.endInferenceSession(l)}}d.InferenceSession=h})(u.fbs||(u.fbs={}))})(a.experimental||(a.experimental={}))}(e.onnxruntime||(e.onnxruntime={}))},1723:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OnnxjsSessionHandler=void 0;const n=t(2235),r=t(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,u){const d=new Map;for(const l in o)if(Object.hasOwnProperty.call(o,l)){const i=o[l];d.set(l,new r.Tensor(i.dims,i.type,void 0,void 0,i.data))}const h=await this.session.run(d),p={};return h.forEach((l,i)=>{p[i]=new n.Tensor(l.type,l.data,l.dims)}),p}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}},6027:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Session=void 0;const n=t(7067),r=t(1296),o=t(1975),a=t(6496),u=t(1315),d=t(1745);e.Session=class{constructor(h={}){this._initialized=!1,this.backendHint=h.backendHint,this.profiler=u.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,l){await this.profiler.event("session","Session.loadModel",async()=>{const i=await(0,o.resolveBackend)(this.backendHint);if(this.sessionHandler=i.createSessionHandler(this.context),this._model=new d.Model,typeof h=="string"){const c=h.endsWith(".ort");if(typeof process<"u"&&process.versions&&process.versions.node){const f=await(0,r.promisify)(n.readFile)(h);this.initialize(f,c)}else{const f=await fetch(h),g=await f.arrayBuffer();this.initialize(new Uint8Array(g),c)}}else if(ArrayBuffer.isView(h))this.initialize(h);else{const c=new Uint8Array(h,p||0,l||h.byteLength);this.initialize(c)}})}initialize(h,p){if(this._initialized)throw new Error("already initialized");this.profiler.event("session","Session.initialize",()=>{const l=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(h,l,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),l=await this._executionPlan.execute(this.sessionHandler,p);return this.createOutput(l)})}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 l=new Array(h.size);let i=0;for(let c=0;c<p.length;++c){const f=h.get(p[c]);if(!f)throw new Error(`missing input tensor for: '${name}'`);l[i++]=f}h=l}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 l=this._model.graph.getInputIndices(),i=this._model.graph.getValues(),c=new Array(l.length);for(let f=0;f<l.length;++f){const g=i[l[f]];c[f]=g.type.shape.dims,this.context.graphInputTypes.push(g.type.tensorType),this.context.graphInputDims.push(h[f].dims)}this.validateInputTensorDims(c,h,!0)}return this.validateInputTensorTypes(this.context.graphInputTypes,h),h}validateInputTensorTypes(h,p){for(let l=0;l<p.length;l++){const i=h[l],c=p[l].type;if(i!==c)throw new Error(`input tensor[${l}] check failed: expected type '${i}' but got ${c}`)}}validateInputTensorDims(h,p,l){for(let i=0;i<p.length;i++){const c=h[i],f=p[i].dims;if(!this.compareTensorDims(c,f,l))throw new Error(`input tensor[${i}] check failed: expected shape '[${c.join(",")}]' but got [${f.join(",")}]`)}}compareTensorDims(h,p,l){if(h.length!==p.length)return!1;for(let i=0;i<h.length;++i)if(h[i]!==p[i]&&(!l||h[i]!==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 l=new Map;for(let i=0;i<p.length;++i)l.set(p[i],h[i]);return l}initializeOps(h){const p=h.getNodes();this._ops=new Array(p.length);for(let l=0;l<p.length;l++)this._ops[l]=this.sessionHandler.resolve(p[l],this._model.opsets,h)}}},9240:function(s,e,t){var n=this&&this.__importDefault||function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(e,"__esModule",{value:!0}),e.Tensor=void 0;const r=t(3442),o=n(t(1583)),a=t(5127),u=t(2446),d=t(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[d.ShapeUtil.indicesToOffset(m,this.strides)]}set(m,_){this.data[d.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=d.ShapeUtil.computeStrides(this.dims)),this._strides}constructor(m,_,b,v,T,y=r.Guid.create()){this.dims=m,this.type=_,this.dataProvider=b,this.asyncDataProvider=v,this.cache=T,this.dataId=y,this.size=d.ShapeUtil.validateDimsAndCalcSize(m);const S=this.size,w=b===void 0&&v===void 0&&T===void 0;if(T!==void 0&&T.length!==S)throw new RangeError("Input dims doesn't match data length.");if(_==="string"){if(!(T===void 0||Array.isArray(T)&&T.every(k=>typeof k=="string")))throw new TypeError("cache should be a string array");w&&(this.cache=new Array(S))}else{if(T!==void 0){const k=i(_);if(!(T instanceof k))throw new TypeError(`cache should be type ${k.name}`)}if(w){const k=new ArrayBuffer(S*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(i(I))(P)}(k,_)}}}static fromProto(m){if(!m)throw new Error("cannot construct Value from an empty tensor");const _=d.ProtoUtil.tensorDataTypeFromProto(m.dataType),b=d.ProtoUtil.tensorDimsFromProto(m.dims),v=new p(b,_);if(_==="string")m.stringData.forEach((T,y)=>{v.data[y]=(0,d.decodeUtf8String)(T)});else if(m.rawData&&typeof m.rawData.byteLength=="number"&&m.rawData.byteLength>0){const T=v.data,y=new DataView(m.rawData.buffer,m.rawData.byteOffset,m.rawData.byteLength),S=l(m.dataType),w=m.rawData.byteLength/S;if(m.rawData.byteLength%S!=0)throw new Error("invalid buffer length");if(T.length!==w)throw new Error("buffer length mismatch");for(let k=0;k<w;k++){const P=f(y,m.dataType,k*S);T[k]=P}}else{let T;switch(m.dataType){case u.onnx.TensorProto.DataType.FLOAT:T=m.floatData;break;case u.onnx.TensorProto.DataType.INT32:case u.onnx.TensorProto.DataType.INT16:case u.onnx.TensorProto.DataType.UINT16:case u.onnx.TensorProto.DataType.INT8:case u.onnx.TensorProto.DataType.UINT8:case u.onnx.TensorProto.DataType.BOOL:T=m.int32Data;break;case u.onnx.TensorProto.DataType.INT64:T=m.int64Data;break;case u.onnx.TensorProto.DataType.DOUBLE:T=m.doubleData;break;case u.onnx.TensorProto.DataType.UINT32:case u.onnx.TensorProto.DataType.UINT64:T=m.uint64Data;break;default:throw new Error("unspecific error")}if(T==null)throw new Error("failed to populate data from a tensorproto value");const y=v.data;if(y.length!==T.length)throw new Error("array length mismatch");for(let S=0;S<T.length;S++){const w=T[S];o.default.isLong(w)?y[S]=c(w,m.dataType):y[S]=w}}return v}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 _=d.ProtoUtil.tensorDimsFromORTFormat(m),b=d.ProtoUtil.tensorDataTypeFromProto(m.dataType()),v=new p(_,b);if(b==="string")for(let T=0;T<m.stringDataLength();T++)v.data[T]=m.stringData(T);else if(m.rawDataArray()&&typeof m.rawDataLength()=="number"&&m.rawDataLength()>0){const T=v.data,y=new DataView(m.rawDataArray().buffer,m.rawDataArray().byteOffset,m.rawDataLength()),S=l(m.dataType()),w=m.rawDataLength()/S;if(m.rawDataLength()%S!=0)throw new Error("invalid buffer length");if(T.length!==w)throw new Error("buffer length mismatch");for(let k=0;k<w;k++){const P=f(y,m.dataType(),k*S);T[k]=P}}return v}}function l(g){switch(g){case u.onnx.TensorProto.DataType.UINT8:case u.onnx.TensorProto.DataType.INT8:case u.onnx.TensorProto.DataType.BOOL:return 1;case u.onnx.TensorProto.DataType.UINT16:case u.onnx.TensorProto.DataType.INT16:return 2;case u.onnx.TensorProto.DataType.FLOAT:case u.onnx.TensorProto.DataType.INT32:case u.onnx.TensorProto.DataType.UINT32:return 4;case u.onnx.TensorProto.DataType.INT64:case u.onnx.TensorProto.DataType.DOUBLE:case u.onnx.TensorProto.DataType.UINT64:return 8;default:throw new Error(`cannot calculate sizeof() on type ${u.onnx.TensorProto.DataType[g]}`)}}function i(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 c(g,m){if(m===u.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!==u.onnx.TensorProto.DataType.UINT32&&m!==h.TensorDataType.UINT32&&m!==u.onnx.TensorProto.DataType.UINT64&&m!==h.TensorDataType.UINT64)throw new TypeError(`not a LONG type: ${u.onnx.TensorProto.DataType[m]}`);if(g.greaterThanOrEqual(4294967296)||g.lessThan(0))throw new TypeError("uint64 is not supported")}return g.toNumber()}function f(g,m,_){switch(m){case u.onnx.TensorProto.DataType.BOOL:case u.onnx.TensorProto.DataType.UINT8:return g.getUint8(_);case u.onnx.TensorProto.DataType.INT8:return g.getInt8(_);case u.onnx.TensorProto.DataType.UINT16:return g.getUint16(_,!0);case u.onnx.TensorProto.DataType.INT16:return g.getInt16(_,!0);case u.onnx.TensorProto.DataType.FLOAT:return g.getFloat32(_,!0);case u.onnx.TensorProto.DataType.INT32:return g.getInt32(_,!0);case u.onnx.TensorProto.DataType.UINT32:return g.getUint32(_,!0);case u.onnx.TensorProto.DataType.INT64:return c(o.default.fromBits(g.getUint32(_,!0),g.getUint32(_+4,!0),!1),m);case u.onnx.TensorProto.DataType.DOUBLE:return g.getFloat64(_,!0);case u.onnx.TensorProto.DataType.UINT64:return c(o.default.fromBits(g.getUint32(_,!0),g.getUint32(_+4,!0),!0),m);default:throw new Error(`cannot read from DataView for type ${u.onnx.TensorProto.DataType[m]}`)}}e.Tensor=p},7273:function(s,e,t){var n=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 r=t(5686),o=n(t(1583)),a=t(2446),u=t(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 d{static preprocessInputShapes(_,b){return[_.length===1?[1,_[0]]:_,b.length===1?[b[0],1]:b]}static postprocessOutputShape(_,b,v){b===1&&_.splice(_.length-2,1),v===1&&_.pop()}static calcMatMulShape(_,b){return _[1]!==b[0]?void 0:[_[0],b[1]]}}e.MatMulUtil=d;class h{static calcShape(_,b,v=!1){const T=_.length,y=b.length;if(T===0)return b;if(y===0)return _;const S=Math.max(_.length,b.length),w=new Array(S);if(v){if(T<2||y<2)return;const k=d.calcMatMulShape([_[T-2],_[T-1]],[b[y-2],b[y-1]]);if(k===void 0)return;[w[S-2],w[S-1]]=k}for(let k=v?3:1;k<=S;k++){const P=T-k<0?1:_[T-k],I=y-k<0?1:b[y-k];if(P!==I&&P>1&&I>1)return;w[S-k]=Math.max(P,I)}return w}static index(_,b){const v=new Array(b.length);return h.fillIndex(_,b,v),v}static fillIndex(_,b,v){const T=_.length-b.length;for(let y=0;y<b.length;y++)v[y]=_[T+y]%b[y]}static calc(_,b,v,T,y){const S=h.calcShape(_.dims,b.dims);if(S){if(T&&!i.areEqual(S,_.dims))return;const w=i.size(S),k=T?_:new u.Tensor(S,y||_.type);if(S.length===0)k.set([],v(_.get([]),b.get([])));else{const P=new Array(S.length),I=new Array(_.dims.length),F=new Array(b.dims.length);let C,E=0,$=0,x=!1,A=!1;_.dims.length===0&&(E=_.get([]),x=!0),b.dims.length===0&&($=b.get([]),A=!0);for(let L=0;L<w;L++){C=L;for(let B=S.length-1;B>=0;B--)P[B]=C%S[B],C=Math.floor(C/S[B]);x||(h.fillIndex(P,_.dims,I),E=_.get(I)),A||(h.fillIndex(P,b.dims,F),$=b.get(F)),k.set(P,v(E,$))}}return k}}static isValidBroadcast(_,b){const v=_.length,T=b.length;if(v>T)return!1;for(let y=1;y<=v;y++)if(_[v-y]!==1&&_[v-y]!==b[T-y])return!1;return!0}static getBroadcastDims(_,b){const v=_.length,T=[];for(let y=0;y<v;y++){const S=v-1-y,w=_[S]||1;(b[b.length-1-y]||1)>1&&w===1&&T.unshift(S)}return T}}e.BroadcastUtil=h,e.arrayCopyHelper=function(m,_,b,v,T){if(v<0||v>=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(v+T>_.length)throw new Error("source indices to be copied are outside bounds");if(b+T>m.length)throw new Error("target array is too small to hold result");for(let y=0;y<T;y++)m[b+y]=_[v+y]},e.GemmUtil=class{static getShapeOfGemmResult(m,_,b,v,T){if(m.length!==2||b.length!==2)throw new Error("shape need to be of size 2");let y,S,w;_?(y=m[1],S=m[0]):(y=m[0],S=m[1]);let k=-1;if(v?(w=b[0],k=1):(w=b[1],k=0),b[k]!==S)throw new Error("dimension mismatch");if(y<=0||w<=0||S<=0)throw new Error("invalid shape specified");if(T&&!h.isValidBroadcast(T,[y,w]))throw new Error("gemm: invalid bias shape for broadcast");return[y,w,S]}};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 v=0;v<_.dimsLength();v++)b.push(l.longToNumber(_.dims(v)));return b}static tensorAttributesFromORTFormat(_){const b=[];for(let v=0;v<_.attributesLength();v++)b.push(_.attributes(v));return b}}e.ProtoUtil=p;class l{static longToNumber(_,b){return o.default.isLong(_)?_.toNumber():_ instanceof r.flatbuffers.Long?o.default.fromValue({low:_.low,high:_.high,unsigned:b!=null&&b}).toNumber():_}static isLong(_){return o.default.isLong(_)||_ instanceof r.flatbuffers.Long}}e.LongUtil=l;class i{static size(_){return i.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 i.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 i.getSizeFromDimensionRange(_,0,b)}static getSizeFromDimensionRange(_,b,v){let T=1;for(let y=b;y<v;y++){if(_[y]<=0)throw new Error("cannot get valid size from specified dimension range. Most likely the range contains 0 or negative values in them.");T*=_[y]}return T}static computeStrides(_){const b=_.length;if(b===0)return[];if(b===1)return[1];const v=new Array(b);v[b-1]=1,v[b-2]=_[b-1];for(let T=b-3;T>=0;--T)v[T]=v[T+1]*_[T+1];return v}static transpose(_){return _.slice().reverse()}static indicesToOffset(_,b,v){v===void 0&&(v=_.length);let T=0;for(let y=0;y<v;++y)T+=b[y]*_[y];return T}static offsetToIndices(_,b){const v=b.length;if(v===0)return[];if(v===1)return[_*b[0]];const T=new Array(b.length);for(let y=0;y<T.length-1;++y)T[y]=Math.floor(_/b[y]),_-=T[y]*b[y];return T[T.length-1]=_,T}static normalizeAxis(_,b){if(_<-b&&_>=b)throw new Error("unsupported axis for this operation.");return _<0?_+b:_}static normalizeAxes(_,b){return _.map(v=>this.normalizeAxis(v,b))}static incrementIndex(_,b,v){if(b.length===0||_.length===0)throw new Error("Index incrementing unsupported for scalar Tensor");if(v===void 0)v=b.length;else if(v<=0||v>b.length)throw new Error("Incorrect axis to increment on");for(let T=v-1;T>=0&&(_[T]++,!(_[T]<b[T]));--T)_[T]=0}static calculateReshapedDims(_,b){if(b.length===0){if(_.length===0||i.size(_)===1)return[];throw new Error("cannot reshape to a scalar Tensor")}const v=b.length,T=new Array(v);let y=-1,S=1;for(let k=0;k<v;k++){if(b[k]<-1)throw new Error("a dimension in shape hints cannot be less than -1");if(b[k]===-1){if(y!==-1)throw new Error("at most one dimension in shape hints can be -1");y=k}else{if(b[k]===0){if(k>=_.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");T[k]=_[k]}else T[k]=b[k];S*=T[k]}}const w=i.size(_);if(y!==-1){if(w%S!=0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${_}] Output shape: [${b}]`);T[y]=w/S}else if(S!==w)throw new Error("reshapedDims and originalDims don't have matching sizes");return T}static sortBasedOnPerm(_,b){return b?b.map(v=>_[v]):_.slice().reverse()}static padShape(_,b){const v=_.length;return _.map((T,y)=>T+b[y]+b[y+v])}static areEqual(_,b){return _.length===b.length&&_.every((v,T)=>v===b[T])}static validateDimsAndCalcSize(_){if(_.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let b=1;for(const v of _){if(!Number.isInteger(v))throw new TypeError(`Invalid shape: ${v} is not an integer`);if(v<0||v>2147483647)throw new TypeError(`Invalid shape: length ${v} is not allowed`);b*=v}return b}static flattenShape(_,b){b<0&&(b+=_.length);const v=_.reduce((y,S)=>y*S,1),T=_.slice(b).reduce((y,S)=>y*S,1);return[v/T,T]}static squeezeShape(_,b){const v=new Array;b=i.normalizeAxes(b,_.length);for(let T=0;T<_.length;T++){const y=b.indexOf(T)>=0;if(y&&_[T]!==1)throw new Error("squeeze an axis of size different than 1");(b.length===0&&_[T]>1||b.length>0&&!y)&&v.push(_[T])}return v}static unsqueezeShape(_,b){const v=new Array(_.length+b.length);v.fill(0);for(let y=0;y<b.length;y++){const S=i.normalizeAxis(b[y],v.length);if(S>=v.length)throw new Error("'axes' has an out of range axis");if(v[S]!==0)throw new Error("'axes' has a duplicate axis");v[S]=1}let T=0;for(let y=0;y<v.length;y++)v[y]===0&&(v[y]=_[T++]);if(T!==_.length)throw new Error("the unsqueezed dimension could not be established");return v}}e.ShapeUtil=i,e.MathUtil=class{static sqr(m,_,b,v,T){if(v<0||v>=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(v+T>_.length)throw new Error("source indices to be copied are outside bounds");if(b+T>m.length)throw new Error("target array is too small to hold result");for(let y=0;y<T;y++)m[b+y]+=Math.pow(_[v+y],2)}static axpy(m,_,b,v,T,y){if(v<0||v>=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(v+T>_.length)throw new Error("source indices to be copied are outside bounds");if(b+T>m.length)throw new Error("target array is too small to hold result");for(let S=0;S<T;S++)m[b+S]+=y*_[v+S]}static powx(m,_,b,v,T,y){if(v<0||v>=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(v+T>_.length)throw new Error("source indices to be copied are outside bounds");if(b+T>m.length)throw new Error("target array is too small to hold result");for(let S=0;S<T;S++)m[b+S]=Math.pow(_[v+S],y)}static mul(m,_,b,v,T){if(v<0||v>=_.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(v+T>_.length)throw new Error("source indices to be copied are outside bounds");if(b+T>m.length)throw new Error("target array is too small to hold result");for(let y=0;y<T;y++)m[b+y]=_[v+y]*m[b+y]}};class c{static splitShape(_,b,v,T){if(v.length===0){if(!T)throw new Error("need to know number of outputs when the 'split' attribute is not specified");c.determineSplit(_[b],T,v)}const y=[],S=[0];for(let w=0;w<v.length;++w){w!==0&&S.push(S[w-1]+v[w-1]);const k=_.slice();k[b]=v[w],y.push(k)}return[y,S]}static determineSplit(_,b,v){if(_%b!=0)throw new Error("cannot split tensor to equal sized parts");for(let T=0;T<b;++T)v.push(_/b)}}e.SplitUtil=c;class f{static calcReduce(_,b,v,T,y){const S=_.dims.slice(0);b.length===0&&S.forEach((E,$)=>b.push($));const w=f.calcReduceShape(S,b,!0),k=i.size(w),P=new u.Tensor(w,_.type),I=i.computeStrides(w),F=i.computeStrides(S),C=new Array(S.length);for(let E=0;E<k;E++){const $=i.offsetToIndices(E,I);h.fillIndex($,S,C),P.set($,f.calcReduceByAxis(_.numberData,b,S,0,i.indicesToOffset(C,F),T,y))}return v?P:new u.Tensor(f.calcReduceShape(S,b,v),P.type,void 0,void 0,P.data,P.dataId)}static calcReduceByAxis(_,b,v,T,y,S,w){let k=0;if(T>=b.length)return S(_[y]);const P=b[T],I=P>=v.length?1:i.size(v.slice(P+1));for(let F=0;F<v[P];F++)k=F===0?f.calcReduceByAxis(_,b,v,T+1,y,S,w):w(k,f.calcReduceByAxis(_,b,v,T+1,y,S,w)),y+=I;return k}static calcReduceShape(_,b,v){const T=_.slice();for(let y=0;y<b.length;y++)T[b[y]]=v?1:0;return T.filter(y=>y!==0)}}e.ReduceUtil=f;class g{static adjustPoolAttributes(_,b,v,T,y,S){if(!_&&v.length!==b.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(_)for(let w=0;w<b.length-2;w++)w>=v.length?v.push(b[w+2]):v[w]=b[w+2];for(let w=0;w<v.length;w++)if(w<T.length){if(T[w]<0)throw new Error("strides should be greater than or equal to 1")}else T.push(1);for(let w=0;w<v.length;w++)if(w<y.length){if(y[w]<0)throw new Error("dilations should be greater than or equal to 1")}else y.push(1);for(let w=0;w<2*v.length;w++)if(w<S.length){if(S[w]<0)throw new Error("pad should be greater than or equal to 1")}else S.push(0);for(let w=0;w<v.length;w++){if(v[w]<=0)throw new Error("kernel shapes need to be greater than 0");if(S[w]>=v[w]||S[w+v.length]>=v[w])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(_,b,v,T,y,S){if(S){if(y.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(T.length!==_.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let w=0;w<_.length-2;w++)g.adjustPadAndReturnShape(_[w+2],b[w],v[w],T[w],y,w,w+_.length-2,S)}}static computePoolOutputShape(_,b,v,T,y,S,w){if(b.length<=0)throw new Error("input shape must be of size greater than 0");const k=[b[0],b[1]];return g.computeShapeHelper(_,b,k,v,T,y,S,w),k}static computeConvOutputShape(_,b,v,T,y,S,w){if(_.length<=0||b.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");const k=[_[0],b[0]];return g.computeShapeHelper(!1,_,k,v,T,y,S,w),k}static computeShapeHelper(_,b,v,T,y,S,w,k){if(_)for(let P=0;P<b.length-2;P++)v.push(1);else for(let P=0;P<b.length-2;P++)v.push(g.adjustPadAndReturnShape(b[P+2],T[P],y[P],S[P],w,P,P+b.length-2,k))}static adjustPadAndReturnShape(_,b,v,T,y,S,w,k){const P=v*(T-1)+1;if(!k||k==="NOTSET")return Math.floor((_+y[S]+y[w]-P)/b+1);switch(k){case"VALID":return y[S]=0,y[w]=0,Math.floor((_-P)/b+1);case"SAME_LOWER":case"SAME_UPPER":if(v!==1)throw new Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{const I=((_+b-1)/b-1)*b+T-_;return y[S]=Math.floor(k==="SAME_LOWER"?(I+1)/2:I/2),y[w]=I-y[S],Math.floor((_+I-T)/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:(s,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.version=void 0,e.version="1.16.3"},9544:function(s,e,t){var n,r=this&&this.__createBinding||(Object.create?function(I,F,C,E){E===void 0&&(E=C);var $=Object.getOwnPropertyDescriptor(F,C);$&&!("get"in $?!F.__esModule:$.writable||$.configurable)||($={enumerable:!0,get:function(){return F[C]}}),Object.defineProperty(I,E,$)}:function(I,F,C,E){E===void 0&&(E=C),I[E]=F[C]}),o=this&&this.__setModuleDefault||(Object.create?function(I,F){Object.defineProperty(I,"default",{enumerable:!0,value:F})}:function(I,F){I.default=F}),a=this&&this.__importStar||function(I){if(I&&I.__esModule)return I;var F={};if(I!=null)for(var C in I)C!=="default"&&Object.prototype.hasOwnProperty.call(I,C)&&r(F,I,C);return o(F,I),F};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 u=t(2235),d=a(t(1259)),h=t(263),p=()=>!!u.env.wasm.proxy&&typeof document<"u";let l,i,c,f=!1,g=!1,m=!1;const _=[],b=[],v=[],T=[],y=[],S=[],w=()=>{if(f||!g||m||!l)throw new Error("worker not ready")},k=I=>{switch(I.data.type){case"init-wasm":f=!1,I.data.err?(m=!0,i[1](I.data.err)):(g=!0,i[0]());break;case"init-ort":I.data.err?c[1](I.data.err):c[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?v.shift()[1](I.data.err):v.shift()[0](I.data.out);break;case"release":I.data.err?T.shift()[1](I.data.err):T.shift()[0]();break;case"run":I.data.err?y.shift()[1](I.data.err):y.shift()[0](I.data.out);break;case"end-profiling":I.data.err?S.shift()[1](I.data.err):S.shift()[0]()}},P=typeof document<"u"?(n=document==null?void 0:document.currentScript)===null||n===void 0?void 0:n.src:void 0;e.initializeWebAssemblyInstance=async()=>{if(p()){if(g)return;if(f)throw new Error("multiple calls to 'initWasm()' detected.");if(m)throw new Error("previous call to 'initWasm()' failed.");return f=!0,u.env.wasm.wasmPaths===void 0&&P&&P.indexOf("blob:")!==0&&(u.env.wasm.wasmPaths=P.substr(0,+P.lastIndexOf("/")+1)),new Promise((I,F)=>{l==null||l.terminate(),l=t(8050).Z(),l.onmessage=k,i=[I,F];const C={type:"init-wasm",in:u.env.wasm};l.postMessage(C)})}return(0,h.initializeWebAssembly)(u.env.wasm)},e.initializeRuntime=async I=>{if(p())return w(),new Promise((F,C)=>{c=[F,C];const E={type:"init-ort",in:I};l.postMessage(E)});await d.initRuntime(I)},e.createSessionAllocate=async I=>p()?(w(),new Promise((F,C)=>{_.push([F,C]);const E={type:"create_allocate",in:{model:I}};l.postMessage(E,[I.buffer])})):d.createSessionAllocate(I),e.createSessionFinalize=async(I,F)=>p()?(w(),new Promise((C,E)=>{b.push([C,E]);const $={type:"create_finalize",in:{modeldata:I,options:F}};l.postMessage($)})):d.createSessionFinalize(I,F),e.createSession=async(I,F)=>p()?(w(),new Promise((C,E)=>{v.push([C,E]);const $={type:"create",in:{model:I,options:F}};l.postMessage($,[I.buffer])})):d.createSession(I,F),e.releaseSession=async I=>{if(p())return w(),new Promise((F,C)=>{T.push([F,C]);const E={type:"release",in:I};l.postMessage(E)});d.releaseSession(I)},e.run=async(I,F,C,E,$)=>p()?(w(),new Promise((x,A)=>{y.push([x,A]);const L={type:"run",in:{sessionId:I,inputIndices:F,inputs:C,outputIndices:E,options:$}};l.postMessage(L,d.extractTransferableBuffers(C))})):d.run(I,F,C,E,$),e.endProfiling=async I=>{if(p())return w(),new Promise((F,C)=>{S.push([F,C]);const E={type:"end-profiling",in:I};l.postMessage(E)});d.endProfiling(I)}},7918:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.setRunOptions=void 0;const n=t(263),r=t(1497);e.setRunOptions=o=>{const a=(0,n.getInstance)();let u=0;const d=[],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,r.allocWasmString)(o.tag,d)),u=a._OrtCreateRunOptions(h.logSeverityLevel,h.logVerbosityLevel,!!h.terminate,p),u===0&&(0,r.checkLastError)("Can't create run options."),(o==null?void 0:o.extra)!==void 0&&(0,r.iterateExtraOptions)(o.extra,"",new WeakSet,(l,i)=>{const c=(0,r.allocWasmString)(l,d),f=(0,r.allocWasmString)(i,d);a._OrtAddRunConfigEntry(u,c,f)!==0&&(0,r.checkLastError)(`Can't set a run config entry: ${l} - ${i}.`)}),[u,d]}catch(p){throw u!==0&&a._OrtReleaseRunOptions(u),d.forEach(l=>a._free(l)),p}}},6640:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OnnxruntimeWebAssemblySessionHandler=void 0;const n=t(2806),r=t(2235),o=t(2850),a=t(9544);let u;e.OnnxruntimeWebAssemblySessionHandler=class{async createSessionAllocate(d){const h=await fetch(d);if(h.status!==200)throw new Error(`failed to load model: ${d}`);const p=await h.arrayBuffer();return(0,a.createSessionAllocate)(new Uint8Array(p))}async loadModel(d,h){if(u||(await(0,a.initializeRuntime)(r.env),u=!0),typeof d=="string")if(typeof process<"u"&&process.versions&&process.versions.node){const p=await(0,o.promisify)(n.readFile)(d);[this.sessionId,this.inputNames,this.outputNames]=await(0,a.createSession)(p,h)}else{const p=await this.createSessionAllocate(d);[this.sessionId,this.inputNames,this.outputNames]=await(0,a.createSessionFinalize)(p,h)}else[this.sessionId,this.inputNames,this.outputNames]=await(0,a.createSession)(d,h)}async dispose(){return(0,a.releaseSession)(this.sessionId)}async run(d,h,p){const l=[],i=[];Object.entries(d).forEach(m=>{const _=m[0],b=m[1],v=this.inputNames.indexOf(_);if(v===-1)throw new Error(`invalid input '${_}'`);l.push(b),i.push(v)});const c=[];Object.entries(h).forEach(m=>{const _=m[0],b=this.outputNames.indexOf(_);if(b===-1)throw new Error(`invalid output '${_}'`);c.push(b)});const f=await(0,a.run)(this.sessionId,i,l.map(m=>[m.type,m.dims,m.data]),c,p),g={};for(let m=0;m<f.length;m++)g[this.outputNames[c[m]]]=new r.Tensor(f[m][0],f[m][2],f[m][1]);return g}startProfiling(){}endProfiling(){(0,a.endProfiling)(this.sessionId)}}},7622:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.setSessionOptions=void 0;const n=t(263),r=t(1497);e.setSessionOptions=o=>{var a,u,d,h;const p=(0,n.getInstance)();let l=0;const i=[],c=o||{};(f=>{f.extra||(f.extra={}),f.extra.session||(f.extra.session={});const g=f.extra.session;g.use_ort_model_bytes_directly||(g.use_ort_model_bytes_directly="1"),f.executionProviders&&f.executionProviders.some(m=>(typeof m=="string"?m:m.name)==="webgpu")&&(f.enableMemPattern=!1)})(c);try{const f=(T=>{switch(T){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${T}`)}})((a=c.graphOptimizationLevel)!==null&&a!==void 0?a:"all"),g=(T=>{switch(T){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${T}`)}})((u=c.executionMode)!==null&&u!==void 0?u:"sequential"),m=typeof c.logId=="string"?(0,r.allocWasmString)(c.logId,i):0,_=(d=c.logSeverityLevel)!==null&&d!==void 0?d:2;if(!Number.isInteger(_)||_<0||_>4)throw new Error(`log serverity level is not valid: ${_}`);const b=(h=c.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 v=typeof c.optimizedModelFilePath=="string"?(0,r.allocWasmString)(c.optimizedModelFilePath,i):0;return l=p._OrtCreateSessionOptions(f,!!c.enableCpuMemArena,!!c.enableMemPattern,g,!!c.enableProfiling,0,m,_,b,v),l===0&&(0,r.checkLastError)("Can't create session options."),c.executionProviders&&((T,y,S)=>{for(const w of y){let k=typeof w=="string"?w:w.name;switch(k){case"xnnpack":k="XNNPACK";break;case"webnn":if(k="WEBNN",typeof w!="string"){const I=w;if(I!=null&&I.deviceType){const F=(0,r.allocWasmString)("deviceType",S),C=(0,r.allocWasmString)(I.deviceType,S);(0,n.getInstance)()._OrtAddSessionConfigEntry(T,F,C)!==0&&(0,r.checkLastError)(`Can't set a session config entry: 'deviceType' - ${I.deviceType}.`)}if(I!=null&&I.powerPreference){const F=(0,r.allocWasmString)("powerPreference",S),C=(0,r.allocWasmString)(I.powerPreference,S);(0,n.getInstance)()._OrtAddSessionConfigEntry(T,F,C)!==0&&(0,r.checkLastError)(`Can't set a session config entry: 'powerPreference' - ${I.powerPreference}.`)}}break;case"webgpu":k="JS";break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${k}`)}const P=(0,r.allocWasmString)(k,S);(0,n.getInstance)()._OrtAppendExecutionProvider(T,P)!==0&&(0,r.checkLastError)(`Can't append execution provider: ${k}.`)}})(l,c.executionProviders,i),c.extra!==void 0&&(0,r.iterateExtraOptions)(c.extra,"",new WeakSet,(T,y)=>{const S=(0,r.allocWasmString)(T,i),w=(0,r.allocWasmString)(y,i);p._OrtAddSessionConfigEntry(l,S,w)!==0&&(0,r.checkLastError)(`Can't set a session config entry: ${T} - ${y}.`)}),[l,i]}catch(f){throw l!==0&&p._OrtReleaseSessionOptions(l),i.forEach(g=>p._free(g)),f}}},7917:(s,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.logLevelStringToEnum=e.tensorTypeToTypedArrayConstructor=e.getTensorElementSize=e.tensorDataTypeEnumToString=e.tensorDataTypeStringToEnum=void 0,e.tensorDataTypeStringToEnum=t=>{switch(t){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: ${t}`)}},e.tensorDataTypeEnumToString=t=>{switch(t){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: ${t}`)}},e.getTensorElementSize=t=>[void 0,4,1,1,2,2,4,8,void 0,1,2,8,4,8,void 0,void 0,void 0][t],e.tensorTypeToTypedArrayConstructor=t=>{switch(t){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: ${t}`)}},e.logLevelStringToEnum=t=>{switch(t){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: ${t}`)}}},1259:(s,e,t)=>{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 n=t(7918),r=t(7622),o=t(7917),a=t(263),u=t(1497);e.initRuntime=async h=>{var p,l;p=h.wasm.numThreads,l=(0,o.logLevelStringToEnum)(h.logLevel),(0,a.getInstance)()._OrtInit(p,l)!==0&&(0,u.checkLastError)("Can't initialize onnxruntime.")};const d=new Map;e.createSessionAllocate=h=>{const p=(0,a.getInstance)(),l=p._malloc(h.byteLength);if(l===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${h.byteLength}.`);return p.HEAPU8.set(h,l),[l,h.byteLength]},e.createSessionFinalize=(h,p)=>{const l=(0,a.getInstance)();let i=0,c=0,f=[];const g=[],m=[];try{[c,f]=(0,r.setSessionOptions)(p),i=l._OrtCreateSession(h[0],h[1],c),i===0&&(0,u.checkLastError)("Can't create a session.");const[_,b]=(y=>{const S=(0,a.getInstance)(),w=S.stackSave();try{const k=S.stackAlloc(8);return S._OrtGetInputOutputCount(y,k,k+4)!==0&&(0,u.checkLastError)("Can't get session input/output count."),[S.HEAP32[k/4],S.HEAP32[k/4+1]]}finally{S.stackRestore(w)}})(i),v=[],T=[];for(let y=0;y<_;y++){const S=l._OrtGetInputName(i,y);S===0&&(0,u.checkLastError)("Can't get an input name."),g.push(S),v.push(l.UTF8ToString(S))}for(let y=0;y<b;y++){const S=l._OrtGetOutputName(i,y);S===0&&(0,u.checkLastError)("Can't get an output name."),m.push(S),T.push(l.UTF8ToString(S))}return d.set(i,[i,g,m]),[i,v,T]}catch(_){throw g.forEach(b=>l._OrtFree(b)),m.forEach(b=>l._OrtFree(b)),i!==0&&l._OrtReleaseSession(i),_}finally{l._free(h[0]),c!==0&&l._OrtReleaseSessionOptions(c),f.forEach(_=>l._free(_))}},e.createSession=(h,p)=>{const l=(0,e.createSessionAllocate)(h);return(0,e.createSessionFinalize)(l,p)},e.releaseSession=h=>{const p=(0,a.getInstance)(),l=d.get(h);if(!l)throw new Error(`cannot release session. invalid session id: ${h}`);const[i,c,f]=l;c.forEach(g=>p._OrtFree(g)),f.forEach(g=>p._OrtFree(g)),p._OrtReleaseSession(i),d.delete(h)},e.run=async(h,p,l,i,c)=>{const f=(0,a.getInstance)(),g=d.get(h);if(!g)throw new Error(`cannot run inference. invalid session id: ${h}`);const[m,_,b]=g,v=p.length,T=i.length;let y=0,S=[];const w=[],k=[];try{[y,S]=(0,n.setRunOptions)(c);for(let $=0;$<v;$++){const x=l[$][0],A=l[$][1],L=l[$][2];let B,H;if(Array.isArray(L)){H=4*L.length,B=f._malloc(H),k.push(B);let ee=B/4;for(let Q=0;Q<L.length;Q++){if(typeof L[Q]!="string")throw new TypeError(`tensor data at index ${Q} is not a string`);f.HEAPU32[ee++]=(0,u.allocWasmString)(L[Q],k)}}else H=L.byteLength,B=f._malloc(H),k.push(B),f.HEAPU8.set(new Uint8Array(L.buffer,L.byteOffset,H),B);const J=f.stackSave(),X=f.stackAlloc(4*A.length);try{let ee=X/4;A.forEach(re=>f.HEAP32[ee++]=re);const Q=f._OrtCreateTensor((0,o.tensorDataTypeStringToEnum)(x),B,H,X,A.length);Q===0&&(0,u.checkLastError)(`Can't create tensor for input[${$}].`),w.push(Q)}finally{f.stackRestore(J)}}const P=f.stackSave(),I=f.stackAlloc(4*v),F=f.stackAlloc(4*v),C=f.stackAlloc(4*T),E=f.stackAlloc(4*T);try{let $=I/4,x=F/4,A=C/4,L=E/4;for(let X=0;X<v;X++)f.HEAPU32[$++]=w[X],f.HEAPU32[x++]=_[p[X]];for(let X=0;X<T;X++)f.HEAPU32[A++]=0,f.HEAPU32[L++]=b[i[X]];let B=f._OrtRun(m,F,I,v,E,T,C,y);const H=f.jsepRunPromise;H&&H.then!==void 0&&(B=await H);const J=[];B!==0&&(0,u.checkLastError)("failed to call OrtRun().");for(let X=0;X<T;X++){const ee=f.HEAPU32[C/4+X],Q=f.stackSave(),re=f.stackAlloc(16);let oe,ce=0;try{B=f._OrtGetTensorData(ee,re,re+4,re+8,re+12),B!==0&&(0,u.checkLastError)(`Can't access output tensor data on index ${X}.`);let fe=re/4;const ge=f.HEAPU32[fe++];ce=f.HEAPU32[fe++];const we=f.HEAPU32[fe++],xe=f.HEAPU32[fe++],_e=[];for(let pe=0;pe<xe;pe++)_e.push(f.HEAPU32[we/4+pe]);f._OrtFree(we);const ye=_e.length===0?1:_e.reduce((pe,Se)=>pe*Se);if(oe=(0,o.tensorDataTypeEnumToString)(ge),oe==="string"){const pe=[];let Se=ce/4;for(let Ie=0;Ie<ye;Ie++){const Oe=f.HEAPU32[Se++],Pe=Ie===ye-1?void 0:f.HEAPU32[Se]-Oe;pe.push(f.UTF8ToString(Oe,Pe))}J.push([oe,_e,pe])}else{const pe=new((0,o.tensorTypeToTypedArrayConstructor)(oe))(ye);new Uint8Array(pe.buffer,pe.byteOffset,pe.byteLength).set(f.HEAPU8.subarray(ce,ce+pe.byteLength)),J.push([oe,_e,pe])}}finally{f.stackRestore(Q),oe==="string"&&ce&&f._free(ce),f._OrtReleaseTensor(ee)}}return J}finally{f.stackRestore(P)}}finally{w.forEach(P=>f._OrtReleaseTensor(P)),k.forEach(P=>f._free(P)),y!==0&&f._OrtReleaseRunOptions(y),S.forEach(P=>f._free(P))}},e.endProfiling=h=>{const p=(0,a.getInstance)(),l=d.get(h);if(!l)throw new Error("invalid session id");const i=l[0],c=p._OrtEndProfiling(i);c===0&&(0,u.checkLastError)("Can't get an profile file name."),p._OrtFree(c)},e.extractTransferableBuffers=h=>{const p=[];for(const l of h){const i=l[2];!Array.isArray(i)&&i.buffer&&p.push(i.buffer)}return p}},263:function(s,e,t){var n=this&&this.__createBinding||(Object.create?function(c,f,g,m){m===void 0&&(m=g);var _=Object.getOwnPropertyDescriptor(f,g);_&&!("get"in _?!f.__esModule:_.writable||_.configurable)||(_={enumerable:!0,get:function(){return f[g]}}),Object.defineProperty(c,m,_)}:function(c,f,g,m){m===void 0&&(m=g),c[m]=f[g]}),r=this&&this.__setModuleDefault||(Object.create?function(c,f){Object.defineProperty(c,"default",{enumerable:!0,value:f})}:function(c,f){c.default=f}),o=this&&this.__importStar||function(c){if(c&&c.__esModule)return c;var f={};if(c!=null)for(var g in c)g!=="default"&&Object.prototype.hasOwnProperty.call(c,g)&&n(f,c,g);return r(f,c),f};Object.defineProperty(e,"__esModule",{value:!0}),e.dispose=e.getInstance=e.initializeWebAssembly=void 0;const a=o(t(6449)),u=t(932),d=t(3474);let h,p=!1,l=!1,i=!1;e.initializeWebAssembly=async c=>{if(p)return Promise.resolve();if(l)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(i)throw new Error("previous call to 'initializeWebAssembly()' failed.");l=!0;const f=c.initTimeout,g=c.numThreads,m=c.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}})(),v=c.wasmPaths,T=typeof v=="string"?v:void 0,y=((P,I)=>I?P?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":P?"ort-wasm-simd.wasm":"ort-wasm.wasm")(b,_),S=typeof v=="object"?v[y]:void 0;let w=!1;const k=[];if(f>0&&k.push(new Promise(P=>{setTimeout(()=>{w=!0,P()},f)})),k.push(new Promise((P,I)=>{const F=_?d:u,C={locateFile:(E,$)=>_&&E.endsWith(".worker.js")&&typeof Blob<"u"?URL.createObjectURL(new Blob([t(4154)],{type:"text/javascript"})):E.endsWith(".wasm")?S||(T??$)+y:$+E};if(_)if(typeof Blob>"u")C.mainScriptUrlOrBlob=a.join(__dirname,"ort-wasm-threaded.js");else{const E=`var ortWasmThreaded=(function(){var _scriptDir;return ${F.toString()}})();`;C.mainScriptUrlOrBlob=new Blob([E],{type:"text/javascript"})}F(C).then(E=>{l=!1,p=!0,h=E,P()},E=>{l=!1,i=!0,I(E)})})),await Promise.race(k),w)throw new Error(`WebAssembly backend initializing failed due to timeout: ${f}ms`)},e.getInstance=()=>{if(p&&h)return h;throw new Error("WebAssembly is not initialized yet.")},e.dispose=()=>{var c;!p||l||i||(l=!0,(c=h.PThread)===null||c===void 0||c.terminateAllThreads(),h=void 0,l=!1,p=!1,i=!0)}},1497:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.checkLastError=e.iterateExtraOptions=e.allocWasmString=void 0;const n=t(263);e.allocWasmString=(r,o)=>{const a=(0,n.getInstance)(),u=a.lengthBytesUTF8(r)+1,d=a._malloc(u);return a.stringToUTF8(r,d,u),o.push(d),d},e.iterateExtraOptions=(r,o,a,u)=>{if(typeof r=="object"&&r!==null){if(a.has(r))throw new Error("Circular reference in options");a.add(r)}Object.entries(r).forEach(([d,h])=>{const p=o?o+d:d;if(typeof h=="object")(0,e.iterateExtraOptions)(h,p+".",a,u);else if(typeof h=="string"||typeof h=="number")u(p,h.toString());else{if(typeof h!="boolean")throw new Error("Can't handle extra config type: "+typeof h);u(p,h?"1":"0")}})},e.checkLastError=r=>{const o=(0,n.getInstance)(),a=o.stackSave();try{const u=o.stackAlloc(8);o._OrtGetLastError(u,u+4);const d=o.HEAP32[u/4],h=o.HEAPU32[u/4+1],p=h?o.UTF8ToString(h):"";throw new Error(`${r} ERROR_CODE: ${d}, ERROR_MESSAGE: ${p}`)}finally{o.stackRestore(a)}}},8050:(s,e,t)=>{t.d(e,{Z:()=>o});var n=t(6614),r=t.n(n);function o(){return r()('/*!\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:s=>{s.exports=function(e,t,n,r){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 u=o.URL||o.webkitURL,d=u.createObjectURL(a),h=new o[t](d,n);return u.revokeObjectURL(d),h}catch{return new o[t]("data:application/javascript,".concat(encodeURIComponent(e)),n)}}catch{if(!r)throw Error("Inline worker is not supported");return new o[t](r,n)}}},2446:(s,e,t)=>{var n,r,o,a=t(2100),u=a.Reader,d=a.Writer,h=a.util,p=a.roots.default||(a.roots.default={});p.onnx=((o={}).Version=(n={},(r=Object.create(n))[n[0]="_START_VERSION"]=0,r[n[1]="IR_VERSION_2017_10_10"]=1,r[n[2]="IR_VERSION_2017_10_30"]=2,r[n[3]="IR_VERSION_2017_11_3"]=3,r[n[4]="IR_VERSION_2019_1_22"]=4,r[n[5]="IR_VERSION_2019_3_18"]=5,r[n[6]="IR_VERSION_2019_9_19"]=6,r[n[7]="IR_VERSION_2020_5_8"]=7,r[n[8]="IR_VERSION_2021_7_30"]=8,r[n[9]="IR_VERSION"]=9,r),o.AttributeProto=function(){function l(i){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],this.sparseTensors=[],this.typeProtos=[],i)for(var c=Object.keys(i),f=0;f<c.length;++f)i[c[f]]!=null&&(this[c[f]]=i[c[f]])}return l.prototype.name="",l.prototype.refAttrName="",l.prototype.docString="",l.prototype.type=0,l.prototype.f=0,l.prototype.i=h.Long?h.Long.fromBits(0,0,!1):0,l.prototype.s=h.newBuffer([]),l.prototype.t=null,l.prototype.g=null,l.prototype.sparseTensor=null,l.prototype.tp=null,l.prototype.floats=h.emptyArray,l.prototype.ints=h.emptyArray,l.prototype.strings=h.emptyArray,l.prototype.tensors=h.emptyArray,l.prototype.graphs=h.emptyArray,l.prototype.sparseTensors=h.emptyArray,l.prototype.typeProtos=h.emptyArray,l.create=function(i){return new l(i)},l.encode=function(i,c){if(c||(c=d.create()),i.name!=null&&Object.hasOwnProperty.call(i,"name")&&c.uint32(10).string(i.name),i.f!=null&&Object.hasOwnProperty.call(i,"f")&&c.uint32(21).float(i.f),i.i!=null&&Object.hasOwnProperty.call(i,"i")&&c.uint32(24).int64(i.i),i.s!=null&&Object.hasOwnProperty.call(i,"s")&&c.uint32(34).bytes(i.s),i.t!=null&&Object.hasOwnProperty.call(i,"t")&&p.onnx.TensorProto.encode(i.t,c.uint32(42).fork()).ldelim(),i.g!=null&&Object.hasOwnProperty.call(i,"g")&&p.onnx.GraphProto.encode(i.g,c.uint32(50).fork()).ldelim(),i.floats!=null&&i.floats.length){c.uint32(58).fork();for(var f=0;f<i.floats.length;++f)c.float(i.floats[f]);c.ldelim()}if(i.ints!=null&&i.ints.length){for(c.uint32(66).fork(),f=0;f<i.ints.length;++f)c.int64(i.ints[f]);c.ldelim()}if(i.strings!=null&&i.strings.length)for(f=0;f<i.strings.length;++f)c.uint32(74).bytes(i.strings[f]);if(i.tensors!=null&&i.tensors.length)for(f=0;f<i.tensors.length;++f)p.onnx.TensorProto.encode(i.tensors[f],c.uint32(82).fork()).ldelim();if(i.graphs!=null&&i.graphs.length)for(f=0;f<i.graphs.length;++f)p.onnx.GraphProto.encode(i.graphs[f],c.uint32(90).fork()).ldelim();if(i.docString!=null&&Object.hasOwnProperty.call(i,"docString")&&c.uint32(106).string(i.docString),i.tp!=null&&Object.hasOwnProperty.call(i,"tp")&&p.onnx.TypeProto.encode(i.tp,c.uint32(114).fork()).ldelim(),i.typeProtos!=null&&i.typeProtos.length)for(f=0;f<i.typeProtos.length;++f)p.onnx.TypeProto.encode(i.typeProtos[f],c.uint32(122).fork()).ldelim();if(i.type!=null&&Object.hasOwnProperty.call(i,"type")&&c.uint32(160).int32(i.type),i.refAttrName!=null&&Object.hasOwnProperty.call(i,"refAttrName")&&c.uint32(170).string(i.refAttrName),i.sparseTensor!=null&&Object.hasOwnProperty.call(i,"sparseTensor")&&p.onnx.SparseTensorProto.encode(i.sparseTensor,c.uint32(178).fork()).ldelim(),i.sparseTensors!=null&&i.sparseTensors.length)for(f=0;f<i.sparseTensors.length;++f)p.onnx.SparseTensorProto.encode(i.sparseTensors[f],c.uint32(186).fork()).ldelim();return c},l.encodeDelimited=function(i,c){return this.encode(i,c).ldelim()},l.decode=function(i,c){i instanceof u||(i=u.create(i));for(var f=c===void 0?i.len:i.pos+c,g=new p.onnx.AttributeProto;i.pos<f;){var m=i.uint32();switch(m>>>3){case 1:g.name=i.string();break;case 21:g.refAttrName=i.string();break;case 13:g.docString=i.string();break;case 20:g.type=i.int32();break;case 2:g.f=i.float();break;case 3:g.i=i.int64();break;case 4:g.s=i.bytes();break;case 5:g.t=p.onnx.TensorProto.decode(i,i.uint32());break;case 6:g.g=p.onnx.GraphProto.decode(i,i.uint32());break;case 22:g.sparseTensor=p.onnx.SparseTensorProto.decode(i,i.uint32());break;case 14:g.tp=p.onnx.TypeProto.decode(i,i.uint32());break;case 7:if(g.floats&&g.floats.length||(g.floats=[]),(7&m)==2)for(var _=i.uint32()+i.pos;i.pos<_;)g.floats.push(i.float());else g.floats.push(i.float());break;case 8:if(g.ints&&g.ints.length||(g.ints=[]),(7&m)==2)for(_=i.uint32()+i.pos;i.pos<_;)g.ints.push(i.int64());else g.ints.push(i.int64());break;case 9:g.strings&&g.strings.length||(g.strings=[]),g.strings.push(i.bytes());break;case 10:g.tensors&&g.tensors.length||(g.tensors=[]),g.tensors.push(p.onnx.TensorProto.decode(i,i.uint32()));break;case 11:g.graphs&&g.graphs.length||(g.graphs=[]),g.graphs.push(p.onnx.GraphProto.decode(i,i.uint32()));break;case 23:g.sparseTensors&&g.sparseTensors.length||(g.sparseTensors=[]),g.sparseTensors.push(p.onnx.SparseTensorProto.decode(i,i.uint32()));break;case 15:g.typeProtos&&g.typeProtos.length||(g.typeProtos=[]),g.typeProtos.push(p.onnx.TypeProto.decode(i,i.uint32()));break;default:i.skipType(7&m)}}return g},l.decodeDelimited=function(i){return i instanceof u||(i=new u(i)),this.decode(i,i.uint32())},l.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.name!=null&&i.hasOwnProperty("name")&&!h.isString(i.name))return"name: string expected";if(i.refAttrName!=null&&i.hasOwnProperty("refAttrName")&&!h.isString(i.refAttrName))return"refAttrName: string expected";if(i.docString!=null&&i.hasOwnProperty("docString")&&!h.isString(i.docString))return"docString: string expected";if(i.type!=null&&i.hasOwnProperty("type"))switch(i.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(i.f!=null&&i.hasOwnProperty("f")&&typeof i.f!="number")return"f: number expected";if(i.i!=null&&i.hasOwnProperty("i")&&!(h.isInteger(i.i)||i.i&&h.isInteger(i.i.low)&&h.isInteger(i.i.high)))return"i: integer|Long expected";if(i.s!=null&&i.hasOwnProperty("s")&&!(i.s&&typeof i.s.length=="number"||h.isString(i.s)))return"s: buffer expected";if(i.t!=null&&i.hasOwnProperty("t")&&(f=p.onnx.TensorProto.verify(i.t)))return"t."+f;if(i.g!=null&&i.hasOwnProperty("g")&&(f=p.onnx.GraphProto.verify(i.g)))return"g."+f;if(i.sparseTensor!=null&&i.hasOwnProperty("sparseTensor")&&(f=p.onnx.SparseTensorProto.verify(i.sparseTensor)))return"sparseTensor."+f;if(i.tp!=null&&i.hasOwnProperty("tp")&&(f=p.onnx.TypeProto.verify(i.tp)))return"tp."+f;if(i.floats!=null&&i.hasOwnProperty("floats")){if(!Array.isArray(i.floats))return"floats: array expected";for(var c=0;c<i.floats.length;++c)if(typeof i.floats[c]!="number")return"floats: number[] expected"}if(i.ints!=null&&i.hasOwnProperty("ints")){if(!Array.isArray(i.ints))return"ints: array expected";for(c=0;c<i.ints.length;++c)if(!(h.isInteger(i.ints[c])||i.ints[c]&&h.isInteger(i.ints[c].low)&&h.isInteger(i.ints[c].high)))return"ints: integer|Long[] expected"}if(i.strings!=null&&i.hasOwnProperty("strings")){if(!Array.isArray(i.strings))return"strings: array expected";for(c=0;c<i.strings.length;++c)if(!(i.strings[c]&&typeof i.strings[c].length=="number"||h.isString(i.strings[c])))return"strings: buffer[] expected"}if(i.tensors!=null&&i.hasOwnProperty("tensors")){if(!Array.isArray(i.tensors))return"tensors: array expected";for(c=0;c<i.tensors.length;++c)if(f=p.onnx.TensorProto.verify(i.tensors[c]))return"tensors."+f}if(i.graphs!=null&&i.hasOwnProperty("graphs")){if(!Array.isArray(i.graphs))return"graphs: array expected";for(c=0;c<i.graphs.length;++c)if(f=p.onnx.GraphProto.verify(i.graphs[c]))return"graphs."+f}if(i.sparseTensors!=null&&i.hasOwnProperty("sparseTensors")){if(!Array.isArray(i.sparseTensors))return"sparseTensors: array expected";for(c=0;c<i.sparseTensors.length;++c)if(f=p.onnx.SparseTensorProto.verify(i.sparseTensors[c]))return"sparseTensors."+f}if(i.typeProtos!=null&&i.hasOwnProperty("typeProtos")){if(!Array.isArray(i.typeProtos))return"typeProtos: array expected";for(c=0;c<i.typeProtos.length;++c){var f;if(f=p.onnx.TypeProto.verify(i.typeProtos[c]))return"typeProtos."+f}}return null},l.fromObject=function(i){if(i instanceof p.onnx.AttributeProto)return i;var c=new p.onnx.AttributeProto;switch(i.name!=null&&(c.name=String(i.name)),i.refAttrName!=null&&(c.refAttrName=String(i.refAttrName)),i.docString!=null&&(c.docString=String(i.docString)),i.type){default:if(typeof i.type=="number"){c.type=i.type;break}break;case"UNDEFINED":case 0:c.type=0;break;case"FLOAT":case 1:c.type=1;break;case"INT":case 2:c.type=2;break;case"STRING":case 3:c.type=3;break;case"TENSOR":case 4:c.type=4;break;case"GRAPH":case 5:c.type=5;break;case"SPARSE_TENSOR":case 11:c.type=11;break;case"TYPE_PROTO":case 13:c.type=13;break;case"FLOATS":case 6:c.type=6;break;case"INTS":case 7:c.type=7;break;case"STRINGS":case 8:c.type=8;break;case"TENSORS":case 9:c.type=9;break;case"GRAPHS":case 10:c.type=10;break;case"SPARSE_TENSORS":case 12:c.type=12;break;case"TYPE_PROTOS":case 14:c.type=14}if(i.f!=null&&(c.f=Number(i.f)),i.i!=null&&(h.Long?(c.i=h.Long.fromValue(i.i)).unsigned=!1:typeof i.i=="string"?c.i=parseInt(i.i,10):typeof i.i=="number"?c.i=i.i:typeof i.i=="object"&&(c.i=new h.LongBits(i.i.low>>>0,i.i.high>>>0).toNumber())),i.s!=null&&(typeof i.s=="string"?h.base64.decode(i.s,c.s=h.newBuffer(h.base64.length(i.s)),0):i.s.length>=0&&(c.s=i.s)),i.t!=null){if(typeof i.t!="object")throw TypeError(".onnx.AttributeProto.t: object expected");c.t=p.onnx.TensorProto.fromObject(i.t)}if(i.g!=null){if(typeof i.g!="object")throw TypeError(".onnx.AttributeProto.g: object expected");c.g=p.onnx.GraphProto.fromObject(i.g)}if(i.sparseTensor!=null){if(typeof i.sparseTensor!="object")throw TypeError(".onnx.AttributeProto.sparseTensor: object expected");c.sparseTensor=p.onnx.SparseTensorProto.fromObject(i.sparseTensor)}if(i.tp!=null){if(typeof i.tp!="object")throw TypeError(".onnx.AttributeProto.tp: object expected");c.tp=p.onnx.TypeProto.fromObject(i.tp)}if(i.floats){if(!Array.isArray(i.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");c.floats=[];for(var f=0;f<i.floats.length;++f)c.floats[f]=Number(i.floats[f])}if(i.ints){if(!Array.isArray(i.ints))throw TypeError(".onnx.AttributeProto.ints: array expected");for(c.ints=[],f=0;f<i.ints.length;++f)h.Long?(c.ints[f]=h.Long.fromValue(i.ints[f])).unsigned=!1:typeof i.ints[f]=="string"?c.ints[f]=parseInt(i.ints[f],10):typeof i.ints[f]=="number"?c.ints[f]=i.ints[f]:typeof i.ints[f]=="object"&&(c.ints[f]=new h.LongBits(i.ints[f].low>>>0,i.ints[f].high>>>0).toNumber())}if(i.strings){if(!Array.isArray(i.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");for(c.strings=[],f=0;f<i.strings.length;++f)typeof i.strings[f]=="string"?h.base64.decode(i.strings[f],c.strings[f]=h.newBuffer(h.base64.length(i.strings[f])),0):i.strings[f].length>=0&&(c.strings[f]=i.strings[f])}if(i.tensors){if(!Array.isArray(i.tensors))throw TypeError(".onnx.AttributeProto.tensors: array expected");for(c.tensors=[],f=0;f<i.tensors.length;++f){if(typeof i.tensors[f]!="object")throw TypeError(".onnx.AttributeProto.tensors: object expected");c.tensors[f]=p.onnx.TensorProto.fromObject(i.tensors[f])}}if(i.graphs){if(!Array.isArray(i.graphs))throw TypeError(".onnx.AttributeProto.graphs: array expected");for(c.graphs=[],f=0;f<i.graphs.length;++f){if(typeof i.graphs[f]!="object")throw TypeError(".onnx.AttributeProto.graphs: object expected");c.graphs[f]=p.onnx.GraphProto.fromObject(i.graphs[f])}}if(i.sparseTensors){if(!Array.isArray(i.sparseTensors))throw TypeError(".onnx.AttributeProto.sparseTensors: array expected");for(c.sparseTensors=[],f=0;f<i.sparseTensors.length;++f){if(typeof i.sparseTensors[f]!="object")throw TypeError(".onnx.AttributeProto.sparseTensors: object expected");c.sparseTensors[f]=p.onnx.SparseTensorProto.fromObject(i.sparseTensors[f])}}if(i.typeProtos){if(!Array.isArray(i.typeProtos))throw TypeError(".onnx.AttributeProto.typeProtos: array expected");for(c.typeProtos=[],f=0;f<i.typeProtos.length;++f){if(typeof i.typeProtos[f]!="object")throw TypeError(".onnx.AttributeProto.typeProtos: object expected");c.typeProtos[f]=p.onnx.TypeProto.fromObject(i.typeProtos[f])}}return c},l.toObject=function(i,c){c||(c={});var f={};if((c.arrays||c.defaults)&&(f.floats=[],f.ints=[],f.strings=[],f.tensors=[],f.graphs=[],f.typeProtos=[],f.sparseTensors=[]),c.defaults){if(f.name="",f.f=0,h.Long){var g=new h.Long(0,0,!1);f.i=c.longs===String?g.toString():c.longs===Number?g.toNumber():g}else f.i=c.longs===String?"0":0;c.bytes===String?f.s="":(f.s=[],c.bytes!==Array&&(f.s=h.newBuffer(f.s))),f.t=null,f.g=null,f.docString="",f.tp=null,f.type=c.enums===String?"UNDEFINED":0,f.refAttrName="",f.sparseTensor=null}if(i.name!=null&&i.hasOwnProperty("name")&&(f.name=i.name),i.f!=null&&i.hasOwnProperty("f")&&(f.f=c.json&&!isFinite(i.f)?String(i.f):i.f),i.i!=null&&i.hasOwnProperty("i")&&(typeof i.i=="number"?f.i=c.longs===String?String(i.i):i.i:f.i=c.longs===String?h.Long.prototype.toString.call(i.i):c.longs===Number?new h.LongBits(i.i.low>>>0,i.i.high>>>0).toNumber():i.i),i.s!=null&&i.hasOwnProperty("s")&&(f.s=c.bytes===String?h.base64.encode(i.s,0,i.s.length):c.bytes===Array?Array.prototype.slice.call(i.s):i.s),i.t!=null&&i.hasOwnProperty("t")&&(f.t=p.onnx.TensorProto.toObject(i.t,c)),i.g!=null&&i.hasOwnProperty("g")&&(f.g=p.onnx.GraphProto.toObject(i.g,c)),i.floats&&i.floats.length){f.floats=[];for(var m=0;m<i.floats.length;++m)f.floats[m]=c.json&&!isFinite(i.floats[m])?String(i.floats[m]):i.floats[m]}if(i.ints&&i.ints.length)for(f.ints=[],m=0;m<i.ints.length;++m)typeof i.ints[m]=="number"?f.ints[m]=c.longs===String?String(i.ints[m]):i.ints[m]:f.ints[m]=c.longs===String?h.Long.prototype.toString.call(i.ints[m]):c.longs===Number?new h.LongBits(i.ints[m].low>>>0,i.ints[m].high>>>0).toNumber():i.ints[m];if(i.strings&&i.strings.length)for(f.strings=[],m=0;m<i.strings.length;++m)f.strings[m]=c.bytes===String?h.base64.encode(i.strings[m],0,i.strings[m].length):c.bytes===Array?Array.prototype.slice.call(i.strings[m]):i.strings[m];if(i.tensors&&i.tensors.length)for(f.tensors=[],m=0;m<i.tensors.length;++m)f.tensors[m]=p.onnx.TensorProto.toObject(i.tensors[m],c);if(i.graphs&&i.graphs.length)for(f.graphs=[],m=0;m<i.graphs.length;++m)f.graphs[m]=p.onnx.GraphProto.toObject(i.graphs[m],c);if(i.docString!=null&&i.hasOwnProperty("docString")&&(f.docString=i.docString),i.tp!=null&&i.hasOwnProperty("tp")&&(f.tp=p.onnx.TypeProto.toObject(i.tp,c)),i.typeProtos&&i.typeProtos.length)for(f.typeProtos=[],m=0;m<i.typeProtos.length;++m)f.typeProtos[m]=p.onnx.TypeProto.toObject(i.typeProtos[m],c);if(i.type!=null&&i.hasOwnProperty("type")&&(f.type=c.enums===String?p.onnx.AttributeProto.AttributeType[i.type]===void 0?i.type:p.onnx.AttributeProto.AttributeType[i.type]:i.type),i.refAttrName!=null&&i.hasOwnProperty("refAttrName")&&(f.refAttrName=i.refAttrName),i.sparseTensor!=null&&i.hasOwnProperty("sparseTensor")&&(f.sparseTensor=p.onnx.SparseTensorProto.toObject(i.sparseTensor,c)),i.sparseTensors&&i.sparseTensors.length)for(f.sparseTensors=[],m=0;m<i.sparseTensors.length;++m)f.sparseTensors[m]=p.onnx.SparseTensorProto.toObject(i.sparseTensors[m],c);return f},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.AttributeProto"},l.AttributeType=function(){var i={},c=Object.create(i);return c[i[0]="UNDEFINED"]=0,c[i[1]="FLOAT"]=1,c[i[2]="INT"]=2,c[i[3]="STRING"]=3,c[i[4]="TENSOR"]=4,c[i[5]="GRAPH"]=5,c[i[11]="SPARSE_TENSOR"]=11,c[i[13]="TYPE_PROTO"]=13,c[i[6]="FLOATS"]=6,c[i[7]="INTS"]=7,c[i[8]="STRINGS"]=8,c[i[9]="TENSORS"]=9,c[i[10]="GRAPHS"]=10,c[i[12]="SPARSE_TENSORS"]=12,c[i[14]="TYPE_PROTOS"]=14,c}(),l}(),o.ValueInfoProto=function(){function l(i){if(i)for(var c=Object.keys(i),f=0;f<c.length;++f)i[c[f]]!=null&&(this[c[f]]=i[c[f]])}return l.prototype.name="",l.prototype.type=null,l.prototype.docString="",l.create=function(i){return new l(i)},l.encode=function(i,c){return c||(c=d.create()),i.name!=null&&Object.hasOwnProperty.call(i,"name")&&c.uint32(10).string(i.name),i.type!=null&&Object.hasOwnProperty.call(i,"type")&&p.onnx.TypeProto.encode(i.type,c.uint32(18).fork()).ldelim(),i.docString!=null&&Object.hasOwnProperty.call(i,"docString")&&c.uint32(26).string(i.docString),c},l.encodeDelimited=function(i,c){return this.encode(i,c).ldelim()},l.decode=function(i,c){i instanceof u||(i=u.create(i));for(var f=c===void 0?i.len:i.pos+c,g=new p.onnx.ValueInfoProto;i.pos<f;){var m=i.uint32();switch(m>>>3){case 1:g.name=i.string();break;case 2:g.type=p.onnx.TypeProto.decode(i,i.uint32());break;case 3:g.docString=i.string();break;default:i.skipType(7&m)}}return g},l.decodeDelimited=function(i){return i instanceof u||(i=new u(i)),this.decode(i,i.uint32())},l.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.name!=null&&i.hasOwnProperty("name")&&!h.isString(i.name))return"name: string expected";if(i.type!=null&&i.hasOwnProperty("type")){var c=p.onnx.TypeProto.verify(i.type);if(c)return"type."+c}return i.docString!=null&&i.hasOwnProperty("docString")&&!h.isString(i.docString)?"docString: string expected":null},l.fromObject=function(i){if(i instanceof p.onnx.ValueInfoProto)return i;var c=new p.onnx.ValueInfoProto;if(i.name!=null&&(c.name=String(i.name)),i.type!=null){if(typeof i.type!="object")throw TypeError(".onnx.ValueInfoProto.type: object expected");c.type=p.onnx.TypeProto.fromObject(i.type)}return i.docString!=null&&(c.docString=String(i.docString)),c},l.toObject=function(i,c){c||(c={});var f={};return c.defaults&&(f.name="",f.type=null,f.docString=""),i.name!=null&&i.hasOwnProperty("name")&&(f.name=i.name),i.type!=null&&i.hasOwnProperty("type")&&(f.type=p.onnx.TypeProto.toObject(i.type,c)),i.docString!=null&&i.hasOwnProperty("docString")&&(f.docString=i.docString),f},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.ValueInfoProto"},l}(),o.NodeProto=function(){function l(i){if(this.input=[],this.output=[],this.attribute=[],i)for(var c=Object.keys(i),f=0;f<c.length;++f)i[c[f]]!=null&&(this[c[f]]=i[c[f]])}return l.prototype.input=h.emptyArray,l.prototype.output=h.emptyArray,l.prototype.name="",l.prototype.opType="",l.prototype.domain="",l.prototype.attribute=h.emptyArray,l.prototype.docString="",l.create=function(i){return new l(i)},l.encode=function(i,c){if(c||(c=d.create()),i.input!=null&&i.input.length)for(var f=0;f<i.input.length;++f)c.uint32(10).string(i.input[f]);if(i.output!=null&&i.output.length)for(f=0;f<i.output.length;++f)c.uint32(18).string(i.output[f]);if(i.name!=null&&Object.hasOwnProperty.call(i,"name")&&c.uint32(26).string(i.name),i.opType!=null&&Object.hasOwnProperty.call(i,"opType")&&c.uint32(34).string(i.opType),i.attribute!=null&&i.attribute.length)for(f=0;f<i.attribute.length;++f)p.onnx.AttributeProto.encode(i.attribute[f],c.uint32(42).fork()).ldelim();return i.docString!=null&&Object.hasOwnProperty.call(i,"docString")&&c.uint32(50).string(i.docString),i.domain!=null&&Object.hasOwnProperty.call(i,"domain")&&c.uint32(58).string(i.domain),c},l.encodeDelimited=function(i,c){return this.encode(i,c).ldelim()},l.decode=function(i,c){i instanceof u||(i=u.create(i));for(var f=c===void 0?i.len:i.pos+c,g=new p.onnx.NodeProto;i.pos<f;){var m=i.uint32();switch(m>>>3){case 1:g.input&&g.input.length||(g.input=[]),g.input.push(i.string());break;case 2:g.output&&g.output.length||(g.output=[]),g.output.push(i.string());break;case 3:g.name=i.string();break;case 4:g.opType=i.string();break;case 7:g.domain=i.string();break;case 5:g.attribute&&g.attribute.length||(g.attribute=[]),g.attribute.push(p.onnx.AttributeProto.decode(i,i.uint32()));break;case 6:g.docString=i.string();break;default:i.skipType(7&m)}}return g},l.decodeDelimited=function(i){return i instanceof u||(i=new u(i)),this.decode(i,i.uint32())},l.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.input!=null&&i.hasOwnProperty("input")){if(!Array.isArray(i.input))return"input: array expected";for(var c=0;c<i.input.length;++c)if(!h.isString(i.input[c]))return"input: string[] expected"}if(i.output!=null&&i.hasOwnProperty("output")){if(!Array.isArray(i.output))return"output: array expected";for(c=0;c<i.output.length;++c)if(!h.isString(i.output[c]))return"output: string[] expected"}if(i.name!=null&&i.hasOwnProperty("name")&&!h.isString(i.name))return"name: string expected";if(i.opType!=null&&i.hasOwnProperty("opType")&&!h.isString(i.opType))return"opType: string expected";if(i.domain!=null&&i.hasOwnProperty("domain")&&!h.isString(i.domain))return"domain: string expected";if(i.attribute!=null&&i.hasOwnProperty("attribute")){if(!Array.isArray(i.attribute))return"attribute: array expected";for(c=0;c<i.attribute.length;++c){var f=p.onnx.AttributeProto.verify(i.attribute[c]);if(f)return"attribute."+f}}return i.docString!=null&&i.hasOwnProperty("docString")&&!h.isString(i.docString)?"docString: string expected":null},l.fromObject=function(i){if(i instanceof p.onnx.NodeProto)return i;var c=new p.onnx.NodeProto;if(i.input){if(!Array.isArray(i.input))throw TypeError(".onnx.NodeProto.input: array expected");c.input=[];for(var f=0;f<i.input.length;++f)c.input[f]=String(i.input[f])}if(i.output){if(!Array.isArray(i.output))throw TypeError(".onnx.NodeProto.output: array expected");for(c.output=[],f=0;f<i.output.length;++f)c.output[f]=String(i.output[f])}if(i.name!=null&&(c.name=String(i.name)),i.opType!=null&&(c.opType=String(i.opType)),i.domain!=null&&(c.domain=String(i.domain)),i.attribute){if(!Array.isArray(i.attribute))throw TypeError(".onnx.NodeProto.attribute: array expected");for(c.attribute=[],f=0;f<i.attribute.length;++f){if(typeof i.attribute[f]!="object")throw TypeError(".onnx.NodeProto.attribute: object expected");c.attribute[f]=p.onnx.AttributeProto.fromObject(i.attribute[f])}}return i.docString!=null&&(c.docString=String(i.docString)),c},l.toObject=function(i,c){c||(c={});var f={};if((c.arrays||c.defaults)&&(f.input=[],f.output=[],f.attribute=[]),c.defaults&&(f.name="",f.opType="",f.docString="",f.domain=""),i.input&&i.input.length){f.input=[];for(var g=0;g<i.input.length;++g)f.input[g]=i.input[g]}if(i.output&&i.output.length)for(f.output=[],g=0;g<i.output.length;++g)f.output[g]=i.output[g];if(i.name!=null&&i.hasOwnProperty("name")&&(f.name=i.name),i.opType!=null&&i.hasOwnProperty("opType")&&(f.opType=i.opType),i.attribute&&i.attribute.length)for(f.attribute=[],g=0;g<i.attribute.length;++g)f.attribute[g]=p.onnx.AttributeProto.toObject(i.attribute[g],c);return i.docString!=null&&i.hasOwnProperty("docString")&&(f.docString=i.docString),i.domain!=null&&i.hasOwnProperty("domain")&&(f.domain=i.domain),f},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.NodeProto"},l}(),o.TrainingInfoProto=function(){function l(i){if(this.initializationBinding=[],this.updateBinding=[],i)for(var c=Object.keys(i),f=0;f<c.length;++f)i[c[f]]!=null&&(this[c[f]]=i[c[f]])}return l.prototype.initialization=null,l.prototype.algorithm=null,l.prototype.initializationBinding=h.emptyArray,l.prototype.updateBinding=h.emptyArray,l.create=function(i){return new l(i)},l.encode=function(i,c){if(c||(c=d.create()),i.initialization!=null&&Object.hasOwnProperty.call(i,"initialization")&&p.onnx.GraphProto.encode(i.initialization,c.uint32(10).fork()).ldelim(),i.algorithm!=null&&Object.hasOwnProperty.call(i,"algorithm")&&p.onnx.GraphProto.encode(i.algorithm,c.uint32(18).fork()).ldelim(),i.initializationBinding!=null&&i.initializationBinding.length)for(var f=0;f<i.initializationBinding.length;++f)p.onnx.StringStringEntryProto.encode(i.initializationBinding[f],c.uint32(26).fork()).ldelim();if(i.updateBinding!=null&&i.updateBinding.length)for(f=0;f<i.updateBinding.length;++f)p.onnx.StringStringEntryProto.encode(i.updateBinding[f],c.uint32(34).fork()).ldelim();return c},l.encodeDelimited=function(i,c){return this.encode(i,c).ldelim()},l.decode=function(i,c){i instanceof u||(i=u.create(i));for(var f=c===void 0?i.len:i.pos+c,g=new p.onnx.TrainingInfoProto;i.pos<f;){var m=i.uint32();switch(m>>>3){case 1:g.initialization=p.onnx.GraphProto.decode(i,i.uint32());break;case 2:g.algorithm=p.onnx.GraphProto.decode(i,i.uint32());break;case 3:g.initializationBinding&&g.initializationBinding.length||(g.initializationBinding=[]),g.initializationBinding.push(p.onnx.StringStringEntryProto.decode(i,i.uint32()));break;case 4:g.updateBinding&&g.updateBinding.length||(g.updateBinding=[]),g.updateBinding.push(p.onnx.StringStringEntryProto.decode(i,i.uint32()));break;default:i.skipType(7&m)}}return g},l.decodeDelimited=function(i){return i instanceof u||(i=new u(i)),this.decode(i,i.uint32())},l.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.initialization!=null&&i.hasOwnProperty("initialization")&&(f=p.onnx.GraphProto.verify(i.initialization)))return"initialization."+f;if(i.algorithm!=null&&i.hasOwnProperty("algorithm")&&(f=p.onnx.GraphProto.verify(i.algorithm)))return"algorithm."+f;if(i.initializationBinding!=null&&i.hasOwnProperty("initializationBinding")){if(!Array.isArray(i.initializationBinding))return"initializationBinding: array expected";for(var c=0;c<i.initializationBinding.length;++c)if(f=p.onnx.StringStringEntryProto.verify(i.initializationBinding[c]))return"initializationBinding."+f}if(i.updateBinding!=null&&i.hasOwnProperty("updateBinding")){if(!Array.isArray(i.updateBinding))return"updateBinding: array expected";for(c=0;c<i.updateBinding.length;++c){var f;if(f=p.onnx.StringStringEntryProto.verify(i.updateBinding[c]))return"updateBinding."+f}}return null},l.fromObject=function(i){if(i instanceof p.onnx.TrainingInfoProto)return i;var c=new p.onnx.TrainingInfoProto;if(i.initialization!=null){if(typeof i.initialization!="object")throw TypeError(".onnx.TrainingInfoProto.initialization: object expected");c.initialization=p.onnx.GraphProto.fromObject(i.initialization)}if(i.algorithm!=null){if(typeof i.algorithm!="object")throw TypeError(".onnx.TrainingInfoProto.algorithm: object expected");c.algorithm=p.onnx.GraphProto.fromObject(i.algorithm)}if(i.initializationBinding){if(!Array.isArray(i.initializationBinding))throw TypeError(".onnx.TrainingInfoProto.initializationBinding: array expected");c.initializationBinding=[];for(var f=0;f<i.initializationBinding.length;++f){if(typeof i.initializationBinding[f]!="object")throw TypeError(".onnx.TrainingInfoProto.initializationBinding: object expected");c.initializationBinding[f]=p.onnx.StringStringEntryProto.fromObject(i.initializationBinding[f])}}if(i.updateBinding){if(!Array.isArray(i.updateBinding))throw TypeError(".onnx.TrainingInfoProto.updateBinding: array expected");for(c.updateBinding=[],f=0;f<i.updateBinding.length;++f){if(typeof i.updateBinding[f]!="object")throw TypeError(".onnx.TrainingInfoProto.updateBinding: object expected");c.updateBinding[f]=p.onnx.StringStringEntryProto.fromObject(i.updateBinding[f])}}return c},l.toObject=function(i,c){c||(c={});var f={};if((c.arrays||c.defaults)&&(f.initializationBinding=[],f.updateBinding=[]),c.defaults&&(f.initialization=null,f.algorithm=null),i.initialization!=null&&i.hasOwnProperty("initialization")&&(f.initialization=p.onnx.GraphProto.toObject(i.initialization,c)),i.algorithm!=null&&i.hasOwnProperty("algorithm")&&(f.algorithm=p.onnx.GraphProto.toObject(i.algorithm,c)),i.initializationBinding&&i.initializationBinding.length){f.initializationBinding=[];for(var g=0;g<i.initializationBinding.length;++g)f.initializationBinding[g]=p.onnx.StringStringEntryProto.toObject(i.initializationBinding[g],c)}if(i.updateBinding&&i.updateBinding.length)for(f.updateBinding=[],g=0;g<i.updateBinding.length;++g)f.updateBinding[g]=p.onnx.StringStringEntryProto.toObject(i.updateBinding[g],c);return f},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TrainingInfoProto"},l}(),o.ModelProto=function(){function l(i){if(this.opsetImport=[],this.metadataProps=[],this.trainingInfo=[],this.functions=[],i)for(var c=Object.keys(i),f=0;f<c.length;++f)i[c[f]]!=null&&(this[c[f]]=i[c[f]])}return l.prototype.irVersion=h.Long?h.Long.fromBits(0,0,!1):0,l.prototype.opsetImport=h.emptyArray,l.prototype.producerName="",l.prototype.producerVersion="",l.prototype.domain="",l.prototype.modelVersion=h.Long?h.Long.fromBits(0,0,!1):0,l.prototype.docString="",l.prototype.graph=null,l.prototype.metadataProps=h.emptyArray,l.prototype.trainingInfo=h.emptyArray,l.prototype.functions=h.emptyArray,l.create=function(i){return new l(i)},l.encode=function(i,c){if(c||(c=d.create()),i.irVersion!=null&&Object.hasOwnProperty.call(i,"irVersion")&&c.uint32(8).int64(i.irVersion),i.producerName!=null&&Object.hasOwnProperty.call(i,"producerName")&&c.uint32(18).string(i.producerName),i.producerVersion!=null&&Object.hasOwnProperty.call(i,"producerVersion")&&c.uint32(26).string(i.producerVersion),i.domain!=null&&Object.hasOwnProperty.call(i,"domain")&&c.uint32(34).string(i.domain),i.modelVersion!=null&&Object.hasOwnProperty.call(i,"modelVersion")&&c.uint32(40).int64(i.modelVersion),i.docString!=null&&Object.hasOwnProperty.call(i,"docString")&&c.uint32(50).string(i.docString),i.graph!=null&&Object.hasOwnProperty.call(i,"graph")&&p.onnx.GraphProto.encode(i.graph,c.uint32(58).fork()).ldelim(),i.opsetImport!=null&&i.opsetImport.length)for(var f=0;f<i.opsetImport.length;++f)p.onnx.OperatorSetIdProto.encode(i.opsetImport[f],c.uint32(66).fork()).ldelim();if(i.metadataProps!=null&&i.metadataProps.length)for(f=0;f<i.metadataProps.length;++f)p.onnx.StringStringEntryProto.encode(i.metadataProps[f],c.uint32(114).fork()).ldelim();if(i.trainingInfo!=null&&i.trainingInfo.length)for(f=0;f<i.trainingInfo.length;++f)p.onnx.TrainingInfoProto.encode(i.trainingInfo[f],c.uint32(162).fork()).ldelim();if(i.functions!=null&&i.functions.length)for(f=0;f<i.functions.length;++f)p.onnx.FunctionProto.encode(i.functions[f],c.uint32(202).fork()).ldelim();return c},l.encodeDelimited=function(i,c){return this.encode(i,c).ldelim()},l.decode=function(i,c){i instanceof u||(i=u.create(i));for(var f=c===void 0?i.len:i.pos+c,g=new p.onnx.ModelProto;i.pos<f;){var m=i.uint32();switch(m>>>3){case 1:g.irVersion=i.int64();break;case 8:g.opsetImport&&g.opsetImport.length||(g.opsetImport=[]),g.opsetImport.push(p.onnx.OperatorSetIdProto.decode(i,i.uint32()));break;case 2:g.producerName=i.string();break;case 3:g.producerVersion=i.string();break;case 4:g.domain=i.string();break;case 5:g.modelVersion=i.int64();break;case 6:g.docString=i.string();break;case 7:g.graph=p.onnx.GraphProto.decode(i,i.uint32());break;case 14:g.metadataProps&&g.metadataProps.length||(g.metadataProps=[]),g.metadataProps.push(p.onnx.StringStringEntryProto.decode(i,i.uint32()));break;case 20:g.trainingInfo&&g.trainingInfo.length||(g.trainingInfo=[]),g.trainingInfo.push(p.onnx.TrainingInfoProto.decode(i,i.uint32()));break;case 25:g.functions&&g.functions.length||(g.functions=[]),g.functions.push(p.onnx.FunctionProto.decode(i,i.uint32()));break;default:i.skipType(7&m)}}return g},l.decodeDelimited=function(i){return i instanceof u||(i=new u(i)),this.decode(i,i.uint32())},l.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.irVersion!=null&&i.hasOwnProperty("irVersion")&&!(h.isInteger(i.irVersion)||i.irVersion&&h.isInteger(i.irVersion.low)&&h.isInteger(i.irVersion.high)))return"irVersion: integer|Long expected";if(i.opsetImport!=null&&i.hasOwnProperty("opsetImport")){if(!Array.isArray(i.opsetImport))return"opsetImport: array expected";for(var c=0;c<i.opsetImport.length;++c)if(f=p.onnx.OperatorSetIdProto.verify(i.opsetImport[c]))return"opsetImport."+f}if(i.producerName!=null&&i.hasOwnProperty("producerName")&&!h.isString(i.producerName))return"producerName: string expected";if(i.producerVersion!=null&&i.hasOwnProperty("producerVersion")&&!h.isString(i.producerVersion))return"producerVersion: string expected";if(i.domain!=null&&i.hasOwnProperty("domain")&&!h.isString(i.domain))return"domain: string expected";if(i.modelVersion!=null&&i.hasOwnProperty("modelVersion")&&!(h.isInteger(i.modelVersion)||i.modelVersion&&h.isInteger(i.modelVersion.low)&&h.isInteger(i.modelVersion.high)))return"modelVersion: integer|Long expected";if(i.docString!=null&&i.hasOwnProperty("docString")&&!h.isString(i.docString))return"docString: string expected";if(i.graph!=null&&i.hasOwnProperty("graph")&&(f=p.onnx.GraphProto.verify(i.graph)))return"graph."+f;if(i.metadataProps!=null&&i.hasOwnProperty("metadataProps")){if(!Array.isArray(i.metadataProps))return"metadataProps: array expected";for(c=0;c<i.metadataProps.length;++c)if(f=p.onnx.StringStringEntryProto.verify(i.metadataProps[c]))return"metadataProps."+f}if(i.trainingInfo!=null&&i.hasOwnProperty("trainingInfo")){if(!Array.isArray(i.trainingInfo))return"trainingInfo: array expected";for(c=0;c<i.trainingInfo.length;++c)if(f=p.onnx.TrainingInfoProto.verify(i.trainingInfo[c]))return"trainingInfo."+f}if(i.functions!=null&&i.hasOwnProperty("functions")){if(!Array.isArray(i.functions))return"functions: array expected";for(c=0;c<i.functions.length;++c){var f;if(f=p.onnx.FunctionProto.verify(i.functions[c]))return"functions."+f}}return null},l.fromObject=function(i){if(i instanceof p.onnx.ModelProto)return i;var c=new p.onnx.ModelProto;if(i.irVersion!=null&&(h.Long?(c.irVersion=h.Long.fromValue(i.irVersion)).unsigned=!1:typeof i.irVersion=="string"?c.irVersion=parseInt(i.irVersion,10):typeof i.irVersion=="number"?c.irVersion=i.irVersion:typeof i.irVersion=="object"&&(c.irVersion=new h.LongBits(i.irVersion.low>>>0,i.irVersion.high>>>0).toNumber())),i.opsetImport){if(!Array.isArray(i.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");c.opsetImport=[];for(var f=0;f<i.opsetImport.length;++f){if(typeof i.opsetImport[f]!="object")throw TypeError(".onnx.ModelProto.opsetImport: object expected");c.opsetImport[f]=p.onnx.OperatorSetIdProto.fromObject(i.opsetImport[f])}}if(i.producerName!=null&&(c.producerName=String(i.producerName)),i.producerVersion!=null&&(c.producerVersion=String(i.producerVersion)),i.domain!=null&&(c.domain=String(i.domain)),i.modelVersion!=null&&(h.Long?(c.modelVersion=h.Long.fromValue(i.modelVersion)).unsigned=!1:typeof i.modelVersion=="string"?c.modelVersion=parseInt(i.modelVersion,10):typeof i.modelVersion=="number"?c.modelVersion=i.modelVersion:typeof i.modelVersion=="object"&&(c.modelVersion=new h.LongBits(i.modelVersion.low>>>0,i.modelVersion.high>>>0).toNumber())),i.docString!=null&&(c.docString=String(i.docString)),i.graph!=null){if(typeof i.graph!="object")throw TypeError(".onnx.ModelProto.graph: object expected");c.graph=p.onnx.GraphProto.fromObject(i.graph)}if(i.metadataProps){if(!Array.isArray(i.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");for(c.metadataProps=[],f=0;f<i.metadataProps.length;++f){if(typeof i.metadataProps[f]!="object")throw TypeError(".onnx.ModelProto.metadataProps: object expected");c.metadataProps[f]=p.onnx.StringStringEntryProto.fromObject(i.metadataProps[f])}}if(i.trainingInfo){if(!Array.isArray(i.trainingInfo))throw TypeError(".onnx.ModelProto.trainingInfo: array expected");for(c.trainingInfo=[],f=0;f<i.trainingInfo.length;++f){if(typeof i.trainingInfo[f]!="object")throw TypeError(".onnx.ModelProto.trainingInfo: object expected");c.trainingInfo[f]=p.onnx.TrainingInfoProto.fromObject(i.trainingInfo[f])}}if(i.functions){if(!Array.isArray(i.functions))throw TypeError(".onnx.ModelProto.functions: array expected");for(c.functions=[],f=0;f<i.functions.length;++f){if(typeof i.functions[f]!="object")throw TypeError(".onnx.ModelProto.functions: object expected");c.functions[f]=p.onnx.FunctionProto.fromObject(i.functions[f])}}return c},l.toObject=function(i,c){c||(c={});var f={};if((c.arrays||c.defaults)&&(f.opsetImport=[],f.metadataProps=[],f.trainingInfo=[],f.functions=[]),c.defaults){if(h.Long){var g=new h.Long(0,0,!1);f.irVersion=c.longs===String?g.toString():c.longs===Number?g.toNumber():g}else f.irVersion=c.longs===String?"0":0;f.producerName="",f.producerVersion="",f.domain="",h.Long?(g=new h.Long(0,0,!1),f.modelVersion=c.longs===String?g.toString():c.longs===Number?g.toNumber():g):f.modelVersion=c.longs===String?"0":0,f.docString="",f.graph=null}if(i.irVersion!=null&&i.hasOwnProperty("irVersion")&&(typeof i.irVersion=="number"?f.irVersion=c.longs===String?String(i.irVersion):i.irVersion:f.irVersion=c.longs===String?h.Long.prototype.toString.call(i.irVersion):c.longs===Number?new h.LongBits(i.irVersion.low>>>0,i.irVersion.high>>>0).toNumber():i.irVersion),i.producerName!=null&&i.hasOwnProperty("producerName")&&(f.producerName=i.producerName),i.producerVersion!=null&&i.hasOwnProperty("producerVersion")&&(f.producerVersion=i.producerVersion),i.domain!=null&&i.hasOwnProperty("domain")&&(f.domain=i.domain),i.modelVersion!=null&&i.hasOwnProperty("modelVersion")&&(typeof i.modelVersion=="number"?f.modelVersion=c.longs===String?String(i.modelVersion):i.modelVersion:f.modelVersion=c.longs===String?h.Long.prototype.toString.call(i.modelVersion):c.longs===Number?new h.LongBits(i.modelVersion.low>>>0,i.modelVersion.high>>>0).toNumber():i.modelVersion),i.docString!=null&&i.hasOwnProperty("docString")&&(f.docString=i.docString),i.graph!=null&&i.hasOwnProperty("graph")&&(f.graph=p.onnx.GraphProto.toObject(i.graph,c)),i.opsetImport&&i.opsetImport.length){f.opsetImport=[];for(var m=0;m<i.opsetImport.length;++m)f.opsetImport[m]=p.onnx.OperatorSetIdProto.toObject(i.opsetImport[m],c)}if(i.metadataProps&&i.metadataProps.length)for(f.metadataProps=[],m=0;m<i.metadataProps.length;++m)f.metadataProps[m]=p.onnx.StringStringEntryProto.toObject(i.metadataProps[m],c);if(i.trainingInfo&&i.trainingInfo.length)for(f.trainingInfo=[],m=0;m<i.trainingInfo.length;++m)f.trainingInfo[m]=p.onnx.TrainingInfoProto.toObject(i.trainingInfo[m],c);if(i.functions&&i.functions.length)for(f.functions=[],m=0;m<i.functions.length;++m)f.functions[m]=p.onnx.FunctionProto.toObject(i.functions[m],c);return f},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.ModelProto"},l}(),o.StringStringEntryProto=function(){function l(i){if(i)for(var c=Object.keys(i),f=0;f<c.length;++f)i[c[f]]!=null&&(this[c[f]]=i[c[f]])}return l.prototype.key="",l.prototype.value="",l.create=function(i){return new l(i)},l.encode=function(i,c){return c||(c=d.create()),i.key!=null&&Object.hasOwnProperty.call(i,"key")&&c.uint32(10).string(i.key),i.value!=null&&Object.hasOwnProperty.call(i,"value")&&c.uint32(18).string(i.value),c},l.encodeDelimited=function(i,c){return this.encode(i,c).ldelim()},l.decode=function(i,c){i instanceof u||(i=u.create(i));for(var f=c===void 0?i.len:i.pos+c,g=new p.onnx.StringStringEntryProto;i.pos<f;){var m=i.uint32();switch(m>>>3){case 1:g.key=i.string();break;case 2:g.value=i.string();break;default:i.skipType(7&m)}}return g},l.decodeDelimited=function(i){return i instanceof u||(i=new u(i)),this.decode(i,i.uint32())},l.verify=function(i){return typeof i!="object"||i===null?"object expected":i.key!=null&&i.hasOwnProperty("key")&&!h.isString(i.key)?"key: string expected":i.value!=null&&i.hasOwnProperty("value")&&!h.isString(i.value)?"value: string expected":null},l.fromObject=function(i){if(i instanceof p.onnx.StringStringEntryProto)return i;var c=new p.onnx.StringStringEntryProto;return i.key!=null&&(c.key=String(i.key)),i.value!=null&&(c.value=String(i.value)),c},l.toObject=function(i,c){c||(c={});var f={};return c.defaults&&(f.key="",f.value=""),i.key!=null&&i.hasOwnProperty("key")&&(f.key=i.key),i.value!=null&&i.hasOwnProperty("value")&&(f.value=i.value),f},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.StringStringEntryProto"},l}(),o.TensorAnnotation=function(){function l(i){if(this.quantParameterTensorNames=[],i)for(var c=Object.keys(i),f=0;f<c.length;++f)i[c[f]]!=null&&(this[c[f]]=i[c[f]])}return l.prototype.tensorName="",l.prototype.quantParameterTensorNames=h.emptyArray,l.create=function(i){return new l(i)},l.encode=function(i,c){if(c||(c=d.create()),i.tensorName!=null&&Object.hasOwnProperty.call(i,"tensorName")&&c.uint32(10).string(i.tensorName),i.quantParameterTensorNames!=null&&i.quantParameterTensorNames.length)for(var f=0;f<i.quantParameterTensorNames.length;++f)p.onnx.StringStringEntryProto.encode(i.quantParameterTensorNames[f],c.uint32(18).fork()).ldelim();return c},l.encodeDelimited=function(i,c){return this.encode(i,c).ldelim()},l.decode=function(i,c){i instanceof u||(i=u.create(i));for(var f=c===void 0?i.len:i.pos+c,g=new p.onnx.TensorAnnotation;i.pos<f;){var m=i.uint32();switch(m>>>3){case 1:g.tensorName=i.string();break;case 2:g.quantParameterTensorNames&&g.quantParameterTensorNames.length||(g.quantParameterTensorNames=[]),g.quantParameterTensorNames.push(p.onnx.StringStringEntryProto.decode(i,i.uint32()));break;default:i.skipType(7&m)}}return g},l.decodeDelimited=function(i){return i instanceof u||(i=new u(i)),this.decode(i,i.uint32())},l.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.tensorName!=null&&i.hasOwnProperty("tensorName")&&!h.isString(i.tensorName))return"tensorName: string expected";if(i.quantParameterTensorNames!=null&&i.hasOwnProperty("quantParameterTensorNames")){if(!Array.isArray(i.quantParameterTensorNames))return"quantParameterTensorNames: array expected";for(var c=0;c<i.quantParameterTensorNames.length;++c){var f=p.onnx.StringStringEntryProto.verify(i.quantParameterTensorNames[c]);if(f)return"quantParameterTensorNames."+f}}return null},l.fromObject=function(i){if(i instanceof p.onnx.TensorAnnotation)return i;var c=new p.onnx.TensorAnnotation;if(i.tensorName!=null&&(c.tensorName=String(i.tensorName)),i.quantParameterTensorNames){if(!Array.isArray(i.quantParameterTensorNames))throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: array expected");c.quantParameterTensorNames=[];for(var f=0;f<i.quantParameterTensorNames.length;++f){if(typeof i.quantParameterTensorNames[f]!="object")throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: object expected");c.quantParameterTensorNames[f]=p.onnx.StringStringEntryProto.fromObject(i.quantParameterTensorNames[f])}}return c},l.toObject=function(i,c){c||(c={});var f={};if((c.arrays||c.defaults)&&(f.quantParameterTensorNames=[]),c.defaults&&(f.tensorName=""),i.tensorName!=null&&i.hasOwnProperty("tensorName")&&(f.tensorName=i.tensorName),i.quantParameterTensorNames&&i.quantParameterTensorNames.length){f.quantParameterTensorNames=[];for(var g=0;g<i.quantParameterTensorNames.length;++g)f.quantParameterTensorNames[g]=p.onnx.StringStringEntryProto.toObject(i.quantParameterTensorNames[g],c)}return f},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TensorAnnotation"},l}(),o.GraphProto=function(){function l(i){if(this.node=[],this.initializer=[],this.sparseInitializer=[],this.input=[],this.output=[],this.valueInfo=[],this.quantizationAnnotation=[],i)for(var c=Object.keys(i),f=0;f<c.length;++f)i[c[f]]!=null&&(this[c[f]]=i[c[f]])}return l.prototype.node=h.emptyArray,l.prototype.name="",l.prototype.initializer=h.emptyArray,l.prototype.sparseInitializer=h.emptyArray,l.prototype.docString="",l.prototype.input=h.emptyArray,l.prototype.output=h.emptyArray,l.prototype.valueInfo=h.emptyArray,l.prototype.quantizationAnnotation=h.emptyArray,l.create=function(i){return new l(i)},l.encode=function(i,c){if(c||(c=d.create()),i.node!=null&&i.node.length)for(var f=0;f<i.node.length;++f)p.onnx.NodeProto.encode(i.node[f],c.uint32(10).fork()).ldelim();if(i.name!=null&&Object.hasOwnProperty.call(i,"name")&&c.uint32(18).string(i.name),i.initializer!=null&&i.initializer.length)for(f=0;f<i.initializer.length;++f)p.onnx.TensorProto.encode(i.initializer[f],c.uint32(42).fork()).ldelim();if(i.docString!=null&&Object.hasOwnProperty.call(i,"docString")&&c.uint32(82).string(i.docString),i.input!=null&&i.input.length)for(f=0;f<i.input.length;++f)p.onnx.ValueInfoProto.encode(i.input[f],c.uint32(90).fork()).ldelim();if(i.output!=null&&i.output.length)for(f=0;f<i.output.length;++f)p.onnx.ValueInfoProto.encode(i.output[f],c.uint32(98).fork()).ldelim();if(i.valueInfo!=null&&i.valueInfo.length)for(f=0;f<i.valueInfo.length;++f)p.onnx.ValueInfoProto.encode(i.valueInfo[f],c.uint32(106).fork()).ldelim();if(i.quantizationAnnotation!=null&&i.quantizationAnnotation.length)for(f=0;f<i.quantizationAnnotation.length;++f)p.onnx.TensorAnnotation.encode(i.quantizationAnnotation[f],c.uint32(114).fork()).ldelim();if(i.sparseInitializer!=null&&i.sparseInitializer.length)for(f=0;f<i.sparseInitializer.length;++f)p.onnx.SparseTensorProto.encode(i.sparseInitializer[f],c.uint32(122).fork()).ldelim();return c},l.encodeDelimited=function(i,c){return this.encode(i,c).ldelim()},l.decode=function(i,c){i instanceof u||(i=u.create(i));for(var f=c===void 0?i.len:i.pos+c,g=new p.onnx.GraphProto;i.pos<f;){var m=i.uint32();switch(m>>>3){case 1:g.node&&g.node.length||(g.node=[]),g.node.push(p.onnx.NodeProto.decode(i,i.uint32()));break;case 2:g.name=i.string();break;case 5:g.initializer&&g.initializer.length||(g.initializer=[]),g.initializer.push(p.onnx.TensorProto.decode(i,i.uint32()));break;case 15:g.sparseInitializer&&g.sparseInitializer.length||(g.sparseInitializer=[]),g.sparseInitializer.push(p.onnx.SparseTensorProto.decode(i,i.uint32()));break;case 10:g.docString=i.string();break;case 11:g.input&&g.input.length||(g.input=[]),g.input.push(p.onnx.ValueInfoProto.decode(i,i.uint32()));break;case 12:g.output&&g.output.length||(g.output=[]),g.output.push(p.onnx.ValueInfoProto.decode(i,i.uint32()));break;case 13:g.valueInfo&&g.valueInfo.length||(g.valueInfo=[]),g.valueInfo.push(p.onnx.ValueInfoProto.decode(i,i.uint32()));break;case 14:g.quantizationAnnotation&&g.quantizationAnnotation.length||(g.quantizationAnnotation=[]),g.quantizationAnnotation.push(p.onnx.TensorAnnotation.decode(i,i.uint32()));break;default:i.skipType(7&m)}}return g},l.decodeDelimited=function(i){return i instanceof u||(i=new u(i)),this.decode(i,i.uint32())},l.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.node!=null&&i.hasOwnProperty("node")){if(!Array.isArray(i.node))return"node: array expected";for(var c=0;c<i.node.length;++c)if(f=p.onnx.NodeProto.verify(i.node[c]))return"node."+f}if(i.name!=null&&i.hasOwnProperty("name")&&!h.isString(i.name))return"name: string expected";if(i.initializer!=null&&i.hasOwnProperty("initializer")){if(!Array.isArray(i.initializer))return"initializer: array expected";for(c=0;c<i.initializer.length;++c)if(f=p.onnx.TensorProto.verify(i.initializer[c]))return"initializer."+f}if(i.sparseInitializer!=null&&i.hasOwnProperty("sparseInitializer")){if(!Array.isArray(i.sparseInitializer))return"sparseInitializer: array expected";for(c=0;c<i.sparseInitializer.length;++c)if(f=p.onnx.SparseTensorProto.verify(i.sparseInitializer[c]))return"sparseInitializer."+f}if(i.docString!=null&&i.hasOwnProperty("docString")&&!h.isString(i.docString))return"docString: string expected";if(i.input!=null&&i.hasOwnProperty("input")){if(!Array.isArray(i.input))return"input: array expected";for(c=0;c<i.input.length;++c)if(f=p.onnx.ValueInfoProto.verify(i.input[c]))return"input."+f}if(i.output!=null&&i.hasOwnProperty("output")){if(!Array.isArray(i.output))return"output: array expected";for(c=0;c<i.output.length;++c)if(f=p.onnx.ValueInfoProto.verify(i.output[c]))return"output."+f}if(i.valueInfo!=null&&i.hasOwnProperty("valueInfo")){if(!Array.isArray(i.valueInfo))return"valueInfo: array expected";for(c=0;c<i.valueInfo.length;++c)if(f=p.onnx.ValueInfoProto.verify(i.valueInfo[c]))return"valueInfo."+f}if(i.quantizationAnnotation!=null&&i.hasOwnProperty("quantizationAnnotation")){if(!Array.isArray(i.quantizationAnnotation))return"quantizationAnnotation: array expected";for(c=0;c<i.quantizationAnnotation.length;++c){var f;if(f=p.onnx.TensorAnnotation.verify(i.quantizationAnnotation[c]))return"quantizationAnnotation."+f}}return null},l.fromObject=function(i){if(i instanceof p.onnx.GraphProto)return i;var c=new p.onnx.GraphProto;if(i.node){if(!Array.isArray(i.node))throw TypeError(".onnx.GraphProto.node: array expected");c.node=[];for(var f=0;f<i.node.length;++f){if(typeof i.node[f]!="object")throw TypeError(".onnx.GraphProto.node: object expected");c.node[f]=p.onnx.NodeProto.fromObject(i.node[f])}}if(i.name!=null&&(c.name=String(i.name)),i.initializer){if(!Array.isArray(i.initializer))throw TypeError(".onnx.GraphProto.initializer: array expected");for(c.initializer=[],f=0;f<i.initializer.length;++f){if(typeof i.initializer[f]!="object")throw TypeError(".onnx.GraphProto.initializer: object expected");c.initializer[f]=p.onnx.TensorProto.fromObject(i.initializer[f])}}if(i.sparseInitializer){if(!Array.isArray(i.sparseInitializer))throw TypeError(".onnx.GraphProto.sparseInitializer: array expected");for(c.sparseInitializer=[],f=0;f<i.sparseInitializer.length;++f){if(typeof i.sparseInitializer[f]!="object")throw TypeError(".onnx.GraphProto.sparseInitializer: object expected");c.sparseInitializer[f]=p.onnx.SparseTensorProto.fromObject(i.sparseInitializer[f])}}if(i.docString!=null&&(c.docString=String(i.docString)),i.input){if(!Array.isArray(i.input))throw TypeError(".onnx.GraphProto.input: array expected");for(c.input=[],f=0;f<i.input.length;++f){if(typeof i.input[f]!="object")throw TypeError(".onnx.GraphProto.input: object expected");c.input[f]=p.onnx.ValueInfoProto.fromObject(i.input[f])}}if(i.output){if(!Array.isArray(i.output))throw TypeError(".onnx.GraphProto.output: array expected");for(c.output=[],f=0;f<i.output.length;++f){if(typeof i.output[f]!="object")throw TypeError(".onnx.GraphProto.output: object expected");c.output[f]=p.onnx.ValueInfoProto.fromObject(i.output[f])}}if(i.valueInfo){if(!Array.isArray(i.valueInfo))throw TypeError(".onnx.GraphProto.valueInfo: array expected");for(c.valueInfo=[],f=0;f<i.valueInfo.length;++f){if(typeof i.valueInfo[f]!="object")throw TypeError(".onnx.GraphProto.valueInfo: object expected");c.valueInfo[f]=p.onnx.ValueInfoProto.fromObject(i.valueInfo[f])}}if(i.quantizationAnnotation){if(!Array.isArray(i.quantizationAnnotation))throw TypeError(".onnx.GraphProto.quantizationAnnotation: array expected");for(c.quantizationAnnotation=[],f=0;f<i.quantizationAnnotation.length;++f){if(typeof i.quantizationAnnotation[f]!="object")throw TypeError(".onnx.GraphProto.quantizationAnnotation: object expected");c.quantizationAnnotation[f]=p.onnx.TensorAnnotation.fromObject(i.quantizationAnnotation[f])}}return c},l.toObject=function(i,c){c||(c={});var f={};if((c.arrays||c.defaults)&&(f.node=[],f.initializer=[],f.input=[],f.output=[],f.valueInfo=[],f.quantizationAnnotation=[],f.sparseInitializer=[]),c.defaults&&(f.name="",f.docString=""),i.node&&i.node.length){f.node=[];for(var g=0;g<i.node.length;++g)f.node[g]=p.onnx.NodeProto.toObject(i.node[g],c)}if(i.name!=null&&i.hasOwnProperty("name")&&(f.name=i.name),i.initializer&&i.initializer.length)for(f.initializer=[],g=0;g<i.initializer.length;++g)f.initializer[g]=p.onnx.TensorProto.toObject(i.initializer[g],c);if(i.docString!=null&&i.hasOwnProperty("docString")&&(f.docString=i.docString),i.input&&i.input.length)for(f.input=[],g=0;g<i.input.length;++g)f.input[g]=p.onnx.ValueInfoProto.toObject(i.input[g],c);if(i.output&&i.output.length)for(f.output=[],g=0;g<i.output.length;++g)f.output[g]=p.onnx.ValueInfoProto.toObject(i.output[g],c);if(i.valueInfo&&i.valueInfo.length)for(f.valueInfo=[],g=0;g<i.valueInfo.length;++g)f.valueInfo[g]=p.onnx.ValueInfoProto.toObject(i.valueInfo[g],c);if(i.quantizationAnnotation&&i.quantizationAnnotation.length)for(f.quantizationAnnotation=[],g=0;g<i.quantizationAnnotation.length;++g)f.quantizationAnnotation[g]=p.onnx.TensorAnnotation.toObject(i.quantizationAnnotation[g],c);if(i.sparseInitializer&&i.sparseInitializer.length)for(f.sparseInitializer=[],g=0;g<i.sparseInitializer.length;++g)f.sparseInitializer[g]=p.onnx.SparseTensorProto.toObject(i.sparseInitializer[g],c);return f},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.GraphProto"},l}(),o.TensorProto=function(){function l(i){if(this.dims=[],this.floatData=[],this.int32Data=[],this.stringData=[],this.int64Data=[],this.externalData=[],this.doubleData=[],this.uint64Data=[],i)for(var c=Object.keys(i),f=0;f<c.length;++f)i[c[f]]!=null&&(this[c[f]]=i[c[f]])}return l.prototype.dims=h.emptyArray,l.prototype.dataType=0,l.prototype.segment=null,l.prototype.floatData=h.emptyArray,l.prototype.int32Data=h.emptyArray,l.prototype.stringData=h.emptyArray,l.prototype.int64Data=h.emptyArray,l.prototype.name="",l.prototype.docString="",l.prototype.rawData=h.newBuffer([]),l.prototype.externalData=h.emptyArray,l.prototype.dataLocation=0,l.prototype.doubleData=h.emptyArray,l.prototype.uint64Data=h.emptyArray,l.create=function(i){return new l(i)},l.encode=function(i,c){if(c||(c=d.create()),i.dims!=null&&i.dims.length){c.uint32(10).fork();for(var f=0;f<i.dims.length;++f)c.int64(i.dims[f]);c.ldelim()}if(i.dataType!=null&&Object.hasOwnProperty.call(i,"dataType")&&c.uint32(16).int32(i.dataType),i.segment!=null&&Object.hasOwnProperty.call(i,"segment")&&p.onnx.TensorProto.Segment.encode(i.segment,c.uint32(26).fork()).ldelim(),i.floatData!=null&&i.floatData.length){for(c.uint32(34).fork(),f=0;f<i.floatData.length;++f)c.float(i.floatData[f]);c.ldelim()}if(i.int32Data!=null&&i.int32Data.length){for(c.uint32(42).fork(),f=0;f<i.int32Data.length;++f)c.int32(i.int32Data[f]);c.ldelim()}if(i.stringData!=null&&i.stringData.length)for(f=0;f<i.stringData.length;++f)c.uint32(50).bytes(i.stringData[f]);if(i.int64Data!=null&&i.int64Data.length){for(c.uint32(58).fork(),f=0;f<i.int64Data.length;++f)c.int64(i.int64Data[f]);c.ldelim()}if(i.name!=null&&Object.hasOwnProperty.call(i,"name")&&c.uint32(66).string(i.name),i.rawData!=null&&Object.hasOwnProperty.call(i,"rawData")&&c.uint32(74).bytes(i.rawData),i.doubleData!=null&&i.doubleData.length){for(c.uint32(82).fork(),f=0;f<i.doubleData.length;++f)c.double(i.doubleData[f]);c.ldelim()}if(i.uint64Data!=null&&i.uint64Data.length){for(c.uint32(90).fork(),f=0;f<i.uint64Data.length;++f)c.uint64(i.uint64Data[f]);c.ldelim()}if(i.docString!=null&&Object.hasOwnProperty.call(i,"docString")&&c.uint32(98).string(i.docString),i.externalData!=null&&i.externalData.length)for(f=0;f<i.externalData.length;++f)p.onnx.StringStringEntryProto.encode(i.externalData[f],c.uint32(106).fork()).ldelim();return i.dataLocation!=null&&Object.hasOwnProperty.call(i,"dataLocation")&&c.uint32(112).int32(i.dataLocation),c},l.encodeDelimited=function(i,c){return this.encode(i,c).ldelim()},l.decode=function(i,c){i instanceof u||(i=u.create(i));for(var f=c===void 0?i.len:i.pos+c,g=new p.onnx.TensorProto;i.pos<f;){var m=i.uint32();switch(m>>>3){case 1:if(g.dims&&g.dims.length||(g.dims=[]),(7&m)==2)for(var _=i.uint32()+i.pos;i.pos<_;)g.dims.push(i.int64());else g.dims.push(i.int64());break;case 2:g.dataType=i.int32();break;case 3:g.segment=p.onnx.TensorProto.Segment.decode(i,i.uint32());break;case 4:if(g.floatData&&g.floatData.length||(g.floatData=[]),(7&m)==2)for(_=i.uint32()+i.pos;i.pos<_;)g.floatData.push(i.float());else g.floatData.push(i.float());break;case 5:if(g.int32Data&&g.int32Data.length||(g.int32Data=[]),(7&m)==2)for(_=i.uint32()+i.pos;i.pos<_;)g.int32Data.push(i.int32());else g.int32Data.push(i.int32());break;case 6:g.stringData&&g.stringData.length||(g.stringData=[]),g.stringData.push(i.bytes());break;case 7:if(g.int64Data&&g.int64Data.length||(g.int64Data=[]),(7&m)==2)for(_=i.uint32()+i.pos;i.pos<_;)g.int64Data.push(i.int64());else g.int64Data.push(i.int64());break;case 8:g.name=i.string();break;case 12:g.docString=i.string();break;case 9:g.rawData=i.bytes();break;case 13:g.externalData&&g.externalData.length||(g.externalData=[]),g.externalData.push(p.onnx.StringStringEntryProto.decode(i,i.uint32()));break;case 14:g.dataLocation=i.int32();break;case 10:if(g.doubleData&&g.doubleData.length||(g.doubleData=[]),(7&m)==2)for(_=i.uint32()+i.pos;i.pos<_;)g.doubleData.push(i.double());else g.doubleData.push(i.double());break;case 11:if(g.uint64Data&&g.uint64Data.length||(g.uint64Data=[]),(7&m)==2)for(_=i.uint32()+i.pos;i.pos<_;)g.uint64Data.push(i.uint64());else g.uint64Data.push(i.uint64());break;default:i.skipType(7&m)}}return g},l.decodeDelimited=function(i){return i instanceof u||(i=new u(i)),this.decode(i,i.uint32())},l.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.dims!=null&&i.hasOwnProperty("dims")){if(!Array.isArray(i.dims))return"dims: array expected";for(var c=0;c<i.dims.length;++c)if(!(h.isInteger(i.dims[c])||i.dims[c]&&h.isInteger(i.dims[c].low)&&h.isInteger(i.dims[c].high)))return"dims: integer|Long[] expected"}if(i.dataType!=null&&i.hasOwnProperty("dataType")&&!h.isInteger(i.dataType))return"dataType: integer expected";if(i.segment!=null&&i.hasOwnProperty("segment")&&(f=p.onnx.TensorProto.Segment.verify(i.segment)))return"segment."+f;if(i.floatData!=null&&i.hasOwnProperty("floatData")){if(!Array.isArray(i.floatData))return"floatData: array expected";for(c=0;c<i.floatData.length;++c)if(typeof i.floatData[c]!="number")return"floatData: number[] expected"}if(i.int32Data!=null&&i.hasOwnProperty("int32Data")){if(!Array.isArray(i.int32Data))return"int32Data: array expected";for(c=0;c<i.int32Data.length;++c)if(!h.isInteger(i.int32Data[c]))return"int32Data: integer[] expected"}if(i.stringData!=null&&i.hasOwnProperty("stringData")){if(!Array.isArray(i.stringData))return"stringData: array expected";for(c=0;c<i.stringData.length;++c)if(!(i.stringData[c]&&typeof i.stringData[c].length=="number"||h.isString(i.stringData[c])))return"stringData: buffer[] expected"}if(i.int64Data!=null&&i.hasOwnProperty("int64Data")){if(!Array.isArray(i.int64Data))return"int64Data: array expected";for(c=0;c<i.int64Data.length;++c)if(!(h.isInteger(i.int64Data[c])||i.int64Data[c]&&h.isInteger(i.int64Data[c].low)&&h.isInteger(i.int64Data[c].high)))return"int64Data: integer|Long[] expected"}if(i.name!=null&&i.hasOwnProperty("name")&&!h.isString(i.name))return"name: string expected";if(i.docString!=null&&i.hasOwnProperty("docString")&&!h.isString(i.docString))return"docString: string expected";if(i.rawData!=null&&i.hasOwnProperty("rawData")&&!(i.rawData&&typeof i.rawData.length=="number"||h.isString(i.rawData)))return"rawData: buffer expected";if(i.externalData!=null&&i.hasOwnProperty("externalData")){if(!Array.isArray(i.externalData))return"externalData: array expected";for(c=0;c<i.externalData.length;++c){var f;if(f=p.onnx.StringStringEntryProto.verify(i.externalData[c]))return"externalData."+f}}if(i.dataLocation!=null&&i.hasOwnProperty("dataLocation"))switch(i.dataLocation){default:return"dataLocation: enum value expected";case 0:case 1:}if(i.doubleData!=null&&i.hasOwnProperty("doubleData")){if(!Array.isArray(i.doubleData))return"doubleData: array expected";for(c=0;c<i.doubleData.length;++c)if(typeof i.doubleData[c]!="number")return"doubleData: number[] expected"}if(i.uint64Data!=null&&i.hasOwnProperty("uint64Data")){if(!Array.isArray(i.uint64Data))return"uint64Data: array expected";for(c=0;c<i.uint64Data.length;++c)if(!(h.isInteger(i.uint64Data[c])||i.uint64Data[c]&&h.isInteger(i.uint64Data[c].low)&&h.isInteger(i.uint64Data[c].high)))return"uint64Data: integer|Long[] expected"}return null},l.fromObject=function(i){if(i instanceof p.onnx.TensorProto)return i;var c=new p.onnx.TensorProto;if(i.dims){if(!Array.isArray(i.dims))throw TypeError(".onnx.TensorProto.dims: array expected");c.dims=[];for(var f=0;f<i.dims.length;++f)h.Long?(c.dims[f]=h.Long.fromValue(i.dims[f])).unsigned=!1:typeof i.dims[f]=="string"?c.dims[f]=parseInt(i.dims[f],10):typeof i.dims[f]=="number"?c.dims[f]=i.dims[f]:typeof i.dims[f]=="object"&&(c.dims[f]=new h.LongBits(i.dims[f].low>>>0,i.dims[f].high>>>0).toNumber())}if(i.dataType!=null&&(c.dataType=0|i.dataType),i.segment!=null){if(typeof i.segment!="object")throw TypeError(".onnx.TensorProto.segment: object expected");c.segment=p.onnx.TensorProto.Segment.fromObject(i.segment)}if(i.floatData){if(!Array.isArray(i.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");for(c.floatData=[],f=0;f<i.floatData.length;++f)c.floatData[f]=Number(i.floatData[f])}if(i.int32Data){if(!Array.isArray(i.int32Data))throw TypeError(".onnx.TensorProto.int32Data: array expected");for(c.int32Data=[],f=0;f<i.int32Data.length;++f)c.int32Data[f]=0|i.int32Data[f]}if(i.stringData){if(!Array.isArray(i.stringData))throw TypeError(".onnx.TensorProto.stringData: array expected");for(c.stringData=[],f=0;f<i.stringData.length;++f)typeof i.stringData[f]=="string"?h.base64.decode(i.stringData[f],c.stringData[f]=h.newBuffer(h.base64.length(i.stringData[f])),0):i.stringData[f].length>=0&&(c.stringData[f]=i.stringData[f])}if(i.int64Data){if(!Array.isArray(i.int64Data))throw TypeError(".onnx.TensorProto.int64Data: array expected");for(c.int64Data=[],f=0;f<i.int64Data.length;++f)h.Long?(c.int64Data[f]=h.Long.fromValue(i.int64Data[f])).unsigned=!1:typeof i.int64Data[f]=="string"?c.int64Data[f]=parseInt(i.int64Data[f],10):typeof i.int64Data[f]=="number"?c.int64Data[f]=i.int64Data[f]:typeof i.int64Data[f]=="object"&&(c.int64Data[f]=new h.LongBits(i.int64Data[f].low>>>0,i.int64Data[f].high>>>0).toNumber())}if(i.name!=null&&(c.name=String(i.name)),i.docString!=null&&(c.docString=String(i.docString)),i.rawData!=null&&(typeof i.rawData=="string"?h.base64.decode(i.rawData,c.rawData=h.newBuffer(h.base64.length(i.rawData)),0):i.rawData.length>=0&&(c.rawData=i.rawData)),i.externalData){if(!Array.isArray(i.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");for(c.externalData=[],f=0;f<i.externalData.length;++f){if(typeof i.externalData[f]!="object")throw TypeError(".onnx.TensorProto.externalData: object expected");c.externalData[f]=p.onnx.StringStringEntryProto.fromObject(i.externalData[f])}}switch(i.dataLocation){default:if(typeof i.dataLocation=="number"){c.dataLocation=i.dataLocation;break}break;case"DEFAULT":case 0:c.dataLocation=0;break;case"EXTERNAL":case 1:c.dataLocation=1}if(i.doubleData){if(!Array.isArray(i.doubleData))throw TypeError(".onnx.TensorProto.doubleData: array expected");for(c.doubleData=[],f=0;f<i.doubleData.length;++f)c.doubleData[f]=Number(i.doubleData[f])}if(i.uint64Data){if(!Array.isArray(i.uint64Data))throw TypeError(".onnx.TensorProto.uint64Data: array expected");for(c.uint64Data=[],f=0;f<i.uint64Data.length;++f)h.Long?(c.uint64Data[f]=h.Long.fromValue(i.uint64Data[f])).unsigned=!0:typeof i.uint64Data[f]=="string"?c.uint64Data[f]=parseInt(i.uint64Data[f],10):typeof i.uint64Data[f]=="number"?c.uint64Data[f]=i.uint64Data[f]:typeof i.uint64Data[f]=="object"&&(c.uint64Data[f]=new h.LongBits(i.uint64Data[f].low>>>0,i.uint64Data[f].high>>>0).toNumber(!0))}return c},l.toObject=function(i,c){c||(c={});var f={};if((c.arrays||c.defaults)&&(f.dims=[],f.floatData=[],f.int32Data=[],f.stringData=[],f.int64Data=[],f.doubleData=[],f.uint64Data=[],f.externalData=[]),c.defaults&&(f.dataType=0,f.segment=null,f.name="",c.bytes===String?f.rawData="":(f.rawData=[],c.bytes!==Array&&(f.rawData=h.newBuffer(f.rawData))),f.docString="",f.dataLocation=c.enums===String?"DEFAULT":0),i.dims&&i.dims.length){f.dims=[];for(var g=0;g<i.dims.length;++g)typeof i.dims[g]=="number"?f.dims[g]=c.longs===String?String(i.dims[g]):i.dims[g]:f.dims[g]=c.longs===String?h.Long.prototype.toString.call(i.dims[g]):c.longs===Number?new h.LongBits(i.dims[g].low>>>0,i.dims[g].high>>>0).toNumber():i.dims[g]}if(i.dataType!=null&&i.hasOwnProperty("dataType")&&(f.dataType=i.dataType),i.segment!=null&&i.hasOwnProperty("segment")&&(f.segment=p.onnx.TensorProto.Segment.toObject(i.segment,c)),i.floatData&&i.floatData.length)for(f.floatData=[],g=0;g<i.floatData.length;++g)f.floatData[g]=c.json&&!isFinite(i.floatData[g])?String(i.floatData[g]):i.floatData[g];if(i.int32Data&&i.int32Data.length)for(f.int32Data=[],g=0;g<i.int32Data.length;++g)f.int32Data[g]=i.int32Data[g];if(i.stringData&&i.stringData.length)for(f.stringData=[],g=0;g<i.stringData.length;++g)f.stringData[g]=c.bytes===String?h.base64.encode(i.stringData[g],0,i.stringData[g].length):c.bytes===Array?Array.prototype.slice.call(i.stringData[g]):i.stringData[g];if(i.int64Data&&i.int64Data.length)for(f.int64Data=[],g=0;g<i.int64Data.length;++g)typeof i.int64Data[g]=="number"?f.int64Data[g]=c.longs===String?String(i.int64Data[g]):i.int64Data[g]:f.int64Data[g]=c.longs===String?h.Long.prototype.toString.call(i.int64Data[g]):c.longs===Number?new h.LongBits(i.int64Data[g].low>>>0,i.int64Data[g].high>>>0).toNumber():i.int64Data[g];if(i.name!=null&&i.hasOwnProperty("name")&&(f.name=i.name),i.rawData!=null&&i.hasOwnProperty("rawData")&&(f.rawData=c.bytes===String?h.base64.encode(i.rawData,0,i.rawData.length):c.bytes===Array?Array.prototype.slice.call(i.rawData):i.rawData),i.doubleData&&i.doubleData.length)for(f.doubleData=[],g=0;g<i.doubleData.length;++g)f.doubleData[g]=c.json&&!isFinite(i.doubleData[g])?String(i.doubleData[g]):i.doubleData[g];if(i.uint64Data&&i.uint64Data.length)for(f.uint64Data=[],g=0;g<i.uint64Data.length;++g)typeof i.uint64Data[g]=="number"?f.uint64Data[g]=c.longs===String?String(i.uint64Data[g]):i.uint64Data[g]:f.uint64Data[g]=c.longs===String?h.Long.prototype.toString.call(i.uint64Data[g]):c.longs===Number?new h.LongBits(i.uint64Data[g].low>>>0,i.uint64Data[g].high>>>0).toNumber(!0):i.uint64Data[g];if(i.docString!=null&&i.hasOwnProperty("docString")&&(f.docString=i.docString),i.externalData&&i.externalData.length)for(f.externalData=[],g=0;g<i.externalData.length;++g)f.externalData[g]=p.onnx.StringStringEntryProto.toObject(i.externalData[g],c);return i.dataLocation!=null&&i.hasOwnProperty("dataLocation")&&(f.dataLocation=c.enums===String?p.onnx.TensorProto.DataLocation[i.dataLocation]===void 0?i.dataLocation:p.onnx.TensorProto.DataLocation[i.dataLocation]:i.dataLocation),f},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TensorProto"},l.DataType=function(){var i={},c=Object.create(i);return c[i[0]="UNDEFINED"]=0,c[i[1]="FLOAT"]=1,c[i[2]="UINT8"]=2,c[i[3]="INT8"]=3,c[i[4]="UINT16"]=4,c[i[5]="INT16"]=5,c[i[6]="INT32"]=6,c[i[7]="INT64"]=7,c[i[8]="STRING"]=8,c[i[9]="BOOL"]=9,c[i[10]="FLOAT16"]=10,c[i[11]="DOUBLE"]=11,c[i[12]="UINT32"]=12,c[i[13]="UINT64"]=13,c[i[14]="COMPLEX64"]=14,c[i[15]="COMPLEX128"]=15,c[i[16]="BFLOAT16"]=16,c[i[17]="FLOAT8E4M3FN"]=17,c[i[18]="FLOAT8E4M3FNUZ"]=18,c[i[19]="FLOAT8E5M2"]=19,c[i[20]="FLOAT8E5M2FNUZ"]=20,c}(),l.Segment=function(){function i(c){if(c)for(var f=Object.keys(c),g=0;g<f.length;++g)c[f[g]]!=null&&(this[f[g]]=c[f[g]])}return i.prototype.begin=h.Long?h.Long.fromBits(0,0,!1):0,i.prototype.end=h.Long?h.Long.fromBits(0,0,!1):0,i.create=function(c){return new i(c)},i.encode=function(c,f){return f||(f=d.create()),c.begin!=null&&Object.hasOwnProperty.call(c,"begin")&&f.uint32(8).int64(c.begin),c.end!=null&&Object.hasOwnProperty.call(c,"end")&&f.uint32(16).int64(c.end),f},i.encodeDelimited=function(c,f){return this.encode(c,f).ldelim()},i.decode=function(c,f){c instanceof u||(c=u.create(c));for(var g=f===void 0?c.len:c.pos+f,m=new p.onnx.TensorProto.Segment;c.pos<g;){var _=c.uint32();switch(_>>>3){case 1:m.begin=c.int64();break;case 2:m.end=c.int64();break;default:c.skipType(7&_)}}return m},i.decodeDelimited=function(c){return c instanceof u||(c=new u(c)),this.decode(c,c.uint32())},i.verify=function(c){return typeof c!="object"||c===null?"object expected":c.begin!=null&&c.hasOwnProperty("begin")&&!(h.isInteger(c.begin)||c.begin&&h.isInteger(c.begin.low)&&h.isInteger(c.begin.high))?"begin: integer|Long expected":c.end!=null&&c.hasOwnProperty("end")&&!(h.isInteger(c.end)||c.end&&h.isInteger(c.end.low)&&h.isInteger(c.end.high))?"end: integer|Long expected":null},i.fromObject=function(c){if(c instanceof p.onnx.TensorProto.Segment)return c;var f=new p.onnx.TensorProto.Segment;return c.begin!=null&&(h.Long?(f.begin=h.Long.fromValue(c.begin)).unsigned=!1:typeof c.begin=="string"?f.begin=parseInt(c.begin,10):typeof c.begin=="number"?f.begin=c.begin:typeof c.begin=="object"&&(f.begin=new h.LongBits(c.begin.low>>>0,c.begin.high>>>0).toNumber())),c.end!=null&&(h.Long?(f.end=h.Long.fromValue(c.end)).unsigned=!1:typeof c.end=="string"?f.end=parseInt(c.end,10):typeof c.end=="number"?f.end=c.end:typeof c.end=="object"&&(f.end=new h.LongBits(c.end.low>>>0,c.end.high>>>0).toNumber())),f},i.toObject=function(c,f){f||(f={});var g={};if(f.defaults){if(h.Long){var m=new h.Long(0,0,!1);g.begin=f.longs===String?m.toString():f.longs===Number?m.toNumber():m}else g.begin=f.longs===String?"0":0;h.Long?(m=new h.Long(0,0,!1),g.end=f.longs===String?m.toString():f.longs===Number?m.toNumber():m):g.end=f.longs===String?"0":0}return c.begin!=null&&c.hasOwnProperty("begin")&&(typeof c.begin=="number"?g.begin=f.longs===String?String(c.begin):c.begin:g.begin=f.longs===String?h.Long.prototype.toString.call(c.begin):f.longs===Number?new h.LongBits(c.begin.low>>>0,c.begin.high>>>0).toNumber():c.begin),c.end!=null&&c.hasOwnProperty("end")&&(typeof c.end=="number"?g.end=f.longs===String?String(c.end):c.end:g.end=f.longs===String?h.Long.prototype.toString.call(c.end):f.longs===Number?new h.LongBits(c.end.low>>>0,c.end.high>>>0).toNumber():c.end),g},i.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},i.getTypeUrl=function(c){return c===void 0&&(c="type.googleapis.com"),c+"/onnx.TensorProto.Segment"},i}(),l.DataLocation=function(){var i={},c=Object.create(i);return c[i[0]="DEFAULT"]=0,c[i[1]="EXTERNAL"]=1,c}(),l}(),o.SparseTensorProto=function(){function l(i){if(this.dims=[],i)for(var c=Object.keys(i),f=0;f<c.length;++f)i[c[f]]!=null&&(this[c[f]]=i[c[f]])}return l.prototype.values=null,l.prototype.indices=null,l.prototype.dims=h.emptyArray,l.create=function(i){return new l(i)},l.encode=function(i,c){if(c||(c=d.create()),i.values!=null&&Object.hasOwnProperty.call(i,"values")&&p.onnx.TensorProto.encode(i.values,c.uint32(10).fork()).ldelim(),i.indices!=null&&Object.hasOwnProperty.call(i,"indices")&&p.onnx.TensorProto.encode(i.indices,c.uint32(18).fork()).ldelim(),i.dims!=null&&i.dims.length){c.uint32(26).fork();for(var f=0;f<i.dims.length;++f)c.int64(i.dims[f]);c.ldelim()}return c},l.encodeDelimited=function(i,c){return this.encode(i,c).ldelim()},l.decode=function(i,c){i instanceof u||(i=u.create(i));for(var f=c===void 0?i.len:i.pos+c,g=new p.onnx.SparseTensorProto;i.pos<f;){var m=i.uint32();switch(m>>>3){case 1:g.values=p.onnx.TensorProto.decode(i,i.uint32());break;case 2:g.indices=p.onnx.TensorProto.decode(i,i.uint32());break;case 3:if(g.dims&&g.dims.length||(g.dims=[]),(7&m)==2)for(var _=i.uint32()+i.pos;i.pos<_;)g.dims.push(i.int64());else g.dims.push(i.int64());break;default:i.skipType(7&m)}}return g},l.decodeDelimited=function(i){return i instanceof u||(i=new u(i)),this.decode(i,i.uint32())},l.verify=function(i){if(typeof i!="object"||i===null)return"object expected";var c;if(i.values!=null&&i.hasOwnProperty("values")&&(c=p.onnx.TensorProto.verify(i.values)))return"values."+c;if(i.indices!=null&&i.hasOwnProperty("indices")&&(c=p.onnx.TensorProto.verify(i.indices)))return"indices."+c;if(i.dims!=null&&i.hasOwnProperty("dims")){if(!Array.isArray(i.dims))return"dims: array expected";for(var f=0;f<i.dims.length;++f)if(!(h.isInteger(i.dims[f])||i.dims[f]&&h.isInteger(i.dims[f].low)&&h.isInteger(i.dims[f].high)))return"dims: integer|Long[] expected"}return null},l.fromObject=function(i){if(i instanceof p.onnx.SparseTensorProto)return i;var c=new p.onnx.SparseTensorProto;if(i.values!=null){if(typeof i.values!="object")throw TypeError(".onnx.SparseTensorProto.values: object expected");c.values=p.onnx.TensorProto.fromObject(i.values)}if(i.indices!=null){if(typeof i.indices!="object")throw TypeError(".onnx.SparseTensorProto.indices: object expected");c.indices=p.onnx.TensorProto.fromObject(i.indices)}if(i.dims){if(!Array.isArray(i.dims))throw TypeError(".onnx.SparseTensorProto.dims: array expected");c.dims=[];for(var f=0;f<i.dims.length;++f)h.Long?(c.dims[f]=h.Long.fromValue(i.dims[f])).unsigned=!1:typeof i.dims[f]=="string"?c.dims[f]=parseInt(i.dims[f],10):typeof i.dims[f]=="number"?c.dims[f]=i.dims[f]:typeof i.dims[f]=="object"&&(c.dims[f]=new h.LongBits(i.dims[f].low>>>0,i.dims[f].high>>>0).toNumber())}return c},l.toObject=function(i,c){c||(c={});var f={};if((c.arrays||c.defaults)&&(f.dims=[]),c.defaults&&(f.values=null,f.indices=null),i.values!=null&&i.hasOwnProperty("values")&&(f.values=p.onnx.TensorProto.toObject(i.values,c)),i.indices!=null&&i.hasOwnProperty("indices")&&(f.indices=p.onnx.TensorProto.toObject(i.indices,c)),i.dims&&i.dims.length){f.dims=[];for(var g=0;g<i.dims.length;++g)typeof i.dims[g]=="number"?f.dims[g]=c.longs===String?String(i.dims[g]):i.dims[g]:f.dims[g]=c.longs===String?h.Long.prototype.toString.call(i.dims[g]):c.longs===Number?new h.LongBits(i.dims[g].low>>>0,i.dims[g].high>>>0).toNumber():i.dims[g]}return f},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.SparseTensorProto"},l}(),o.TensorShapeProto=function(){function l(i){if(this.dim=[],i)for(var c=Object.keys(i),f=0;f<c.length;++f)i[c[f]]!=null&&(this[c[f]]=i[c[f]])}return l.prototype.dim=h.emptyArray,l.create=function(i){return new l(i)},l.encode=function(i,c){if(c||(c=d.create()),i.dim!=null&&i.dim.length)for(var f=0;f<i.dim.length;++f)p.onnx.TensorShapeProto.Dimension.encode(i.dim[f],c.uint32(10).fork()).ldelim();return c},l.encodeDelimited=function(i,c){return this.encode(i,c).ldelim()},l.decode=function(i,c){i instanceof u||(i=u.create(i));for(var f=c===void 0?i.len:i.pos+c,g=new p.onnx.TensorShapeProto;i.pos<f;){var m=i.uint32();m>>>3==1?(g.dim&&g.dim.length||(g.dim=[]),g.dim.push(p.onnx.TensorShapeProto.Dimension.decode(i,i.uint32()))):i.skipType(7&m)}return g},l.decodeDelimited=function(i){return i instanceof u||(i=new u(i)),this.decode(i,i.uint32())},l.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.dim!=null&&i.hasOwnProperty("dim")){if(!Array.isArray(i.dim))return"dim: array expected";for(var c=0;c<i.dim.length;++c){var f=p.onnx.TensorShapeProto.Dimension.verify(i.dim[c]);if(f)return"dim."+f}}return null},l.fromObject=function(i){if(i instanceof p.onnx.TensorShapeProto)return i;var c=new p.onnx.TensorShapeProto;if(i.dim){if(!Array.isArray(i.dim))throw TypeError(".onnx.TensorShapeProto.dim: array expected");c.dim=[];for(var f=0;f<i.dim.length;++f){if(typeof i.dim[f]!="object")throw TypeError(".onnx.TensorShapeProto.dim: object expected");c.dim[f]=p.onnx.TensorShapeProto.Dimension.fromObject(i.dim[f])}}return c},l.toObject=function(i,c){c||(c={});var f={};if((c.arrays||c.defaults)&&(f.dim=[]),i.dim&&i.dim.length){f.dim=[];for(var g=0;g<i.dim.length;++g)f.dim[g]=p.onnx.TensorShapeProto.Dimension.toObject(i.dim[g],c)}return f},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TensorShapeProto"},l.Dimension=function(){function i(f){if(f)for(var g=Object.keys(f),m=0;m<g.length;++m)f[g[m]]!=null&&(this[g[m]]=f[g[m]])}var c;return i.prototype.dimValue=null,i.prototype.dimParam=null,i.prototype.denotation="",Object.defineProperty(i.prototype,"value",{get:h.oneOfGetter(c=["dimValue","dimParam"]),set:h.oneOfSetter(c)}),i.create=function(f){return new i(f)},i.encode=function(f,g){return g||(g=d.create()),f.dimValue!=null&&Object.hasOwnProperty.call(f,"dimValue")&&g.uint32(8).int64(f.dimValue),f.dimParam!=null&&Object.hasOwnProperty.call(f,"dimParam")&&g.uint32(18).string(f.dimParam),f.denotation!=null&&Object.hasOwnProperty.call(f,"denotation")&&g.uint32(26).string(f.denotation),g},i.encodeDelimited=function(f,g){return this.encode(f,g).ldelim()},i.decode=function(f,g){f instanceof u||(f=u.create(f));for(var m=g===void 0?f.len:f.pos+g,_=new p.onnx.TensorShapeProto.Dimension;f.pos<m;){var b=f.uint32();switch(b>>>3){case 1:_.dimValue=f.int64();break;case 2:_.dimParam=f.string();break;case 3:_.denotation=f.string();break;default:f.skipType(7&b)}}return _},i.decodeDelimited=function(f){return f instanceof u||(f=new u(f)),this.decode(f,f.uint32())},i.verify=function(f){if(typeof f!="object"||f===null)return"object expected";var g={};if(f.dimValue!=null&&f.hasOwnProperty("dimValue")&&(g.value=1,!(h.isInteger(f.dimValue)||f.dimValue&&h.isInteger(f.dimValue.low)&&h.isInteger(f.dimValue.high))))return"dimValue: integer|Long expected";if(f.dimParam!=null&&f.hasOwnProperty("dimParam")){if(g.value===1)return"value: multiple values";if(g.value=1,!h.isString(f.dimParam))return"dimParam: string expected"}return f.denotation!=null&&f.hasOwnProperty("denotation")&&!h.isString(f.denotation)?"denotation: string expected":null},i.fromObject=function(f){if(f instanceof p.onnx.TensorShapeProto.Dimension)return f;var g=new p.onnx.TensorShapeProto.Dimension;return f.dimValue!=null&&(h.Long?(g.dimValue=h.Long.fromValue(f.dimValue)).unsigned=!1:typeof f.dimValue=="string"?g.dimValue=parseInt(f.dimValue,10):typeof f.dimValue=="number"?g.dimValue=f.dimValue:typeof f.dimValue=="object"&&(g.dimValue=new h.LongBits(f.dimValue.low>>>0,f.dimValue.high>>>0).toNumber())),f.dimParam!=null&&(g.dimParam=String(f.dimParam)),f.denotation!=null&&(g.denotation=String(f.denotation)),g},i.toObject=function(f,g){g||(g={});var m={};return g.defaults&&(m.denotation=""),f.dimValue!=null&&f.hasOwnProperty("dimValue")&&(typeof f.dimValue=="number"?m.dimValue=g.longs===String?String(f.dimValue):f.dimValue:m.dimValue=g.longs===String?h.Long.prototype.toString.call(f.dimValue):g.longs===Number?new h.LongBits(f.dimValue.low>>>0,f.dimValue.high>>>0).toNumber():f.dimValue,g.oneofs&&(m.value="dimValue")),f.dimParam!=null&&f.hasOwnProperty("dimParam")&&(m.dimParam=f.dimParam,g.oneofs&&(m.value="dimParam")),f.denotation!=null&&f.hasOwnProperty("denotation")&&(m.denotation=f.denotation),m},i.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},i.getTypeUrl=function(f){return f===void 0&&(f="type.googleapis.com"),f+"/onnx.TensorShapeProto.Dimension"},i}(),l}(),o.TypeProto=function(){function l(c){if(c)for(var f=Object.keys(c),g=0;g<f.length;++g)c[f[g]]!=null&&(this[f[g]]=c[f[g]])}var i;return l.prototype.tensorType=null,l.prototype.sequenceType=null,l.prototype.mapType=null,l.prototype.optionalType=null,l.prototype.sparseTensorType=null,l.prototype.denotation="",Object.defineProperty(l.prototype,"value",{get:h.oneOfGetter(i=["tensorType","sequenceType","mapType","optionalType","sparseTensorType"]),set:h.oneOfSetter(i)}),l.create=function(c){return new l(c)},l.encode=function(c,f){return f||(f=d.create()),c.tensorType!=null&&Object.hasOwnProperty.call(c,"tensorType")&&p.onnx.TypeProto.Tensor.encode(c.tensorType,f.uint32(10).fork()).ldelim(),c.sequenceType!=null&&Object.hasOwnProperty.call(c,"sequenceType")&&p.onnx.TypeProto.Sequence.encode(c.sequenceType,f.uint32(34).fork()).ldelim(),c.mapType!=null&&Object.hasOwnProperty.call(c,"mapType")&&p.onnx.TypeProto.Map.encode(c.mapType,f.uint32(42).fork()).ldelim(),c.denotation!=null&&Object.hasOwnProperty.call(c,"denotation")&&f.uint32(50).string(c.denotation),c.sparseTensorType!=null&&Object.hasOwnProperty.call(c,"sparseTensorType")&&p.onnx.TypeProto.SparseTensor.encode(c.sparseTensorType,f.uint32(66).fork()).ldelim(),c.optionalType!=null&&Object.hasOwnProperty.call(c,"optionalType")&&p.onnx.TypeProto.Optional.encode(c.optionalType,f.uint32(74).fork()).ldelim(),f},l.encodeDelimited=function(c,f){return this.encode(c,f).ldelim()},l.decode=function(c,f){c instanceof u||(c=u.create(c));for(var g=f===void 0?c.len:c.pos+f,m=new p.onnx.TypeProto;c.pos<g;){var _=c.uint32();switch(_>>>3){case 1:m.tensorType=p.onnx.TypeProto.Tensor.decode(c,c.uint32());break;case 4:m.sequenceType=p.onnx.TypeProto.Sequence.decode(c,c.uint32());break;case 5:m.mapType=p.onnx.TypeProto.Map.decode(c,c.uint32());break;case 9:m.optionalType=p.onnx.TypeProto.Optional.decode(c,c.uint32());break;case 8:m.sparseTensorType=p.onnx.TypeProto.SparseTensor.decode(c,c.uint32());break;case 6:m.denotation=c.string();break;default:c.skipType(7&_)}}return m},l.decodeDelimited=function(c){return c instanceof u||(c=new u(c)),this.decode(c,c.uint32())},l.verify=function(c){if(typeof c!="object"||c===null)return"object expected";var f={};if(c.tensorType!=null&&c.hasOwnProperty("tensorType")&&(f.value=1,g=p.onnx.TypeProto.Tensor.verify(c.tensorType)))return"tensorType."+g;if(c.sequenceType!=null&&c.hasOwnProperty("sequenceType")){if(f.value===1)return"value: multiple values";if(f.value=1,g=p.onnx.TypeProto.Sequence.verify(c.sequenceType))return"sequenceType."+g}if(c.mapType!=null&&c.hasOwnProperty("mapType")){if(f.value===1)return"value: multiple values";if(f.value=1,g=p.onnx.TypeProto.Map.verify(c.mapType))return"mapType."+g}if(c.optionalType!=null&&c.hasOwnProperty("optionalType")){if(f.value===1)return"value: multiple values";if(f.value=1,g=p.onnx.TypeProto.Optional.verify(c.optionalType))return"optionalType."+g}if(c.sparseTensorType!=null&&c.hasOwnProperty("sparseTensorType")){if(f.value===1)return"value: multiple values";var g;if(f.value=1,g=p.onnx.TypeProto.SparseTensor.verify(c.sparseTensorType))return"sparseTensorType."+g}return c.denotation!=null&&c.hasOwnProperty("denotation")&&!h.isString(c.denotation)?"denotation: string expected":null},l.fromObject=function(c){if(c instanceof p.onnx.TypeProto)return c;var f=new p.onnx.TypeProto;if(c.tensorType!=null){if(typeof c.tensorType!="object")throw TypeError(".onnx.TypeProto.tensorType: object expected");f.tensorType=p.onnx.TypeProto.Tensor.fromObject(c.tensorType)}if(c.sequenceType!=null){if(typeof c.sequenceType!="object")throw TypeError(".onnx.TypeProto.sequenceType: object expected");f.sequenceType=p.onnx.TypeProto.Sequence.fromObject(c.sequenceType)}if(c.mapType!=null){if(typeof c.mapType!="object")throw TypeError(".onnx.TypeProto.mapType: object expected");f.mapType=p.onnx.TypeProto.Map.fromObject(c.mapType)}if(c.optionalType!=null){if(typeof c.optionalType!="object")throw TypeError(".onnx.TypeProto.optionalType: object expected");f.optionalType=p.onnx.TypeProto.Optional.fromObject(c.optionalType)}if(c.sparseTensorType!=null){if(typeof c.sparseTensorType!="object")throw TypeError(".onnx.TypeProto.sparseTensorType: object expected");f.sparseTensorType=p.onnx.TypeProto.SparseTensor.fromObject(c.sparseTensorType)}return c.denotation!=null&&(f.denotation=String(c.denotation)),f},l.toObject=function(c,f){f||(f={});var g={};return f.defaults&&(g.denotation=""),c.tensorType!=null&&c.hasOwnProperty("tensorType")&&(g.tensorType=p.onnx.TypeProto.Tensor.toObject(c.tensorType,f),f.oneofs&&(g.value="tensorType")),c.sequenceType!=null&&c.hasOwnProperty("sequenceType")&&(g.sequenceType=p.onnx.TypeProto.Sequence.toObject(c.sequenceType,f),f.oneofs&&(g.value="sequenceType")),c.mapType!=null&&c.hasOwnProperty("mapType")&&(g.mapType=p.onnx.TypeProto.Map.toObject(c.mapType,f),f.oneofs&&(g.value="mapType")),c.denotation!=null&&c.hasOwnProperty("denotation")&&(g.denotation=c.denotation),c.sparseTensorType!=null&&c.hasOwnProperty("sparseTensorType")&&(g.sparseTensorType=p.onnx.TypeProto.SparseTensor.toObject(c.sparseTensorType,f),f.oneofs&&(g.value="sparseTensorType")),c.optionalType!=null&&c.hasOwnProperty("optionalType")&&(g.optionalType=p.onnx.TypeProto.Optional.toObject(c.optionalType,f),f.oneofs&&(g.value="optionalType")),g},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(c){return c===void 0&&(c="type.googleapis.com"),c+"/onnx.TypeProto"},l.Tensor=function(){function c(f){if(f)for(var g=Object.keys(f),m=0;m<g.length;++m)f[g[m]]!=null&&(this[g[m]]=f[g[m]])}return c.prototype.elemType=0,c.prototype.shape=null,c.create=function(f){return new c(f)},c.encode=function(f,g){return g||(g=d.create()),f.elemType!=null&&Object.hasOwnProperty.call(f,"elemType")&&g.uint32(8).int32(f.elemType),f.shape!=null&&Object.hasOwnProperty.call(f,"shape")&&p.onnx.TensorShapeProto.encode(f.shape,g.uint32(18).fork()).ldelim(),g},c.encodeDelimited=function(f,g){return this.encode(f,g).ldelim()},c.decode=function(f,g){f instanceof u||(f=u.create(f));for(var m=g===void 0?f.len:f.pos+g,_=new p.onnx.TypeProto.Tensor;f.pos<m;){var b=f.uint32();switch(b>>>3){case 1:_.elemType=f.int32();break;case 2:_.shape=p.onnx.TensorShapeProto.decode(f,f.uint32());break;default:f.skipType(7&b)}}return _},c.decodeDelimited=function(f){return f instanceof u||(f=new u(f)),this.decode(f,f.uint32())},c.verify=function(f){if(typeof f!="object"||f===null)return"object expected";if(f.elemType!=null&&f.hasOwnProperty("elemType")&&!h.isInteger(f.elemType))return"elemType: integer expected";if(f.shape!=null&&f.hasOwnProperty("shape")){var g=p.onnx.TensorShapeProto.verify(f.shape);if(g)return"shape."+g}return null},c.fromObject=function(f){if(f instanceof p.onnx.TypeProto.Tensor)return f;var g=new p.onnx.TypeProto.Tensor;if(f.elemType!=null&&(g.elemType=0|f.elemType),f.shape!=null){if(typeof f.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");g.shape=p.onnx.TensorShapeProto.fromObject(f.shape)}return g},c.toObject=function(f,g){g||(g={});var m={};return g.defaults&&(m.elemType=0,m.shape=null),f.elemType!=null&&f.hasOwnProperty("elemType")&&(m.elemType=f.elemType),f.shape!=null&&f.hasOwnProperty("shape")&&(m.shape=p.onnx.TensorShapeProto.toObject(f.shape,g)),m},c.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},c.getTypeUrl=function(f){return f===void 0&&(f="type.googleapis.com"),f+"/onnx.TypeProto.Tensor"},c}(),l.Sequence=function(){function c(f){if(f)for(var g=Object.keys(f),m=0;m<g.length;++m)f[g[m]]!=null&&(this[g[m]]=f[g[m]])}return c.prototype.elemType=null,c.create=function(f){return new c(f)},c.encode=function(f,g){return g||(g=d.create()),f.elemType!=null&&Object.hasOwnProperty.call(f,"elemType")&&p.onnx.TypeProto.encode(f.elemType,g.uint32(10).fork()).ldelim(),g},c.encodeDelimited=function(f,g){return this.encode(f,g).ldelim()},c.decode=function(f,g){f instanceof u||(f=u.create(f));for(var m=g===void 0?f.len:f.pos+g,_=new p.onnx.TypeProto.Sequence;f.pos<m;){var b=f.uint32();b>>>3==1?_.elemType=p.onnx.TypeProto.decode(f,f.uint32()):f.skipType(7&b)}return _},c.decodeDelimited=function(f){return f instanceof u||(f=new u(f)),this.decode(f,f.uint32())},c.verify=function(f){if(typeof f!="object"||f===null)return"object expected";if(f.elemType!=null&&f.hasOwnProperty("elemType")){var g=p.onnx.TypeProto.verify(f.elemType);if(g)return"elemType."+g}return null},c.fromObject=function(f){if(f instanceof p.onnx.TypeProto.Sequence)return f;var g=new p.onnx.TypeProto.Sequence;if(f.elemType!=null){if(typeof f.elemType!="object")throw TypeError(".onnx.TypeProto.Sequence.elemType: object expected");g.elemType=p.onnx.TypeProto.fromObject(f.elemType)}return g},c.toObject=function(f,g){g||(g={});var m={};return g.defaults&&(m.elemType=null),f.elemType!=null&&f.hasOwnProperty("elemType")&&(m.elemType=p.onnx.TypeProto.toObject(f.elemType,g)),m},c.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},c.getTypeUrl=function(f){return f===void 0&&(f="type.googleapis.com"),f+"/onnx.TypeProto.Sequence"},c}(),l.Map=function(){function c(f){if(f)for(var g=Object.keys(f),m=0;m<g.length;++m)f[g[m]]!=null&&(this[g[m]]=f[g[m]])}return c.prototype.keyType=0,c.prototype.valueType=null,c.create=function(f){return new c(f)},c.encode=function(f,g){return g||(g=d.create()),f.keyType!=null&&Object.hasOwnProperty.call(f,"keyType")&&g.uint32(8).int32(f.keyType),f.valueType!=null&&Object.hasOwnProperty.call(f,"valueType")&&p.onnx.TypeProto.encode(f.valueType,g.uint32(18).fork()).ldelim(),g},c.encodeDelimited=function(f,g){return this.encode(f,g).ldelim()},c.decode=function(f,g){f instanceof u||(f=u.create(f));for(var m=g===void 0?f.len:f.pos+g,_=new p.onnx.TypeProto.Map;f.pos<m;){var b=f.uint32();switch(b>>>3){case 1:_.keyType=f.int32();break;case 2:_.valueType=p.onnx.TypeProto.decode(f,f.uint32());break;default:f.skipType(7&b)}}return _},c.decodeDelimited=function(f){return f instanceof u||(f=new u(f)),this.decode(f,f.uint32())},c.verify=function(f){if(typeof f!="object"||f===null)return"object expected";if(f.keyType!=null&&f.hasOwnProperty("keyType")&&!h.isInteger(f.keyType))return"keyType: integer expected";if(f.valueType!=null&&f.hasOwnProperty("valueType")){var g=p.onnx.TypeProto.verify(f.valueType);if(g)return"valueType."+g}return null},c.fromObject=function(f){if(f instanceof p.onnx.TypeProto.Map)return f;var g=new p.onnx.TypeProto.Map;if(f.keyType!=null&&(g.keyType=0|f.keyType),f.valueType!=null){if(typeof f.valueType!="object")throw TypeError(".onnx.TypeProto.Map.valueType: object expected");g.valueType=p.onnx.TypeProto.fromObject(f.valueType)}return g},c.toObject=function(f,g){g||(g={});var m={};return g.defaults&&(m.keyType=0,m.valueType=null),f.keyType!=null&&f.hasOwnProperty("keyType")&&(m.keyType=f.keyType),f.valueType!=null&&f.hasOwnProperty("valueType")&&(m.valueType=p.onnx.TypeProto.toObject(f.valueType,g)),m},c.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},c.getTypeUrl=function(f){return f===void 0&&(f="type.googleapis.com"),f+"/onnx.TypeProto.Map"},c}(),l.Optional=function(){function c(f){if(f)for(var g=Object.keys(f),m=0;m<g.length;++m)f[g[m]]!=null&&(this[g[m]]=f[g[m]])}return c.prototype.elemType=null,c.create=function(f){return new c(f)},c.encode=function(f,g){return g||(g=d.create()),f.elemType!=null&&Object.hasOwnProperty.call(f,"elemType")&&p.onnx.TypeProto.encode(f.elemType,g.uint32(10).fork()).ldelim(),g},c.encodeDelimited=function(f,g){return this.encode(f,g).ldelim()},c.decode=function(f,g){f instanceof u||(f=u.create(f));for(var m=g===void 0?f.len:f.pos+g,_=new p.onnx.TypeProto.Optional;f.pos<m;){var b=f.uint32();b>>>3==1?_.elemType=p.onnx.TypeProto.decode(f,f.uint32()):f.skipType(7&b)}return _},c.decodeDelimited=function(f){return f instanceof u||(f=new u(f)),this.decode(f,f.uint32())},c.verify=function(f){if(typeof f!="object"||f===null)return"object expected";if(f.elemType!=null&&f.hasOwnProperty("elemType")){var g=p.onnx.TypeProto.verify(f.elemType);if(g)return"elemType."+g}return null},c.fromObject=function(f){if(f instanceof p.onnx.TypeProto.Optional)return f;var g=new p.onnx.TypeProto.Optional;if(f.elemType!=null){if(typeof f.elemType!="object")throw TypeError(".onnx.TypeProto.Optional.elemType: object expected");g.elemType=p.onnx.TypeProto.fromObject(f.elemType)}return g},c.toObject=function(f,g){g||(g={});var m={};return g.defaults&&(m.elemType=null),f.elemType!=null&&f.hasOwnProperty("elemType")&&(m.elemType=p.onnx.TypeProto.toObject(f.elemType,g)),m},c.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},c.getTypeUrl=function(f){return f===void 0&&(f="type.googleapis.com"),f+"/onnx.TypeProto.Optional"},c}(),l.SparseTensor=function(){function c(f){if(f)for(var g=Object.keys(f),m=0;m<g.length;++m)f[g[m]]!=null&&(this[g[m]]=f[g[m]])}return c.prototype.elemType=0,c.prototype.shape=null,c.create=function(f){return new c(f)},c.encode=function(f,g){return g||(g=d.create()),f.elemType!=null&&Object.hasOwnProperty.call(f,"elemType")&&g.uint32(8).int32(f.elemType),f.shape!=null&&Object.hasOwnProperty.call(f,"shape")&&p.onnx.TensorShapeProto.encode(f.shape,g.uint32(18).fork()).ldelim(),g},c.encodeDelimited=function(f,g){return this.encode(f,g).ldelim()},c.decode=function(f,g){f instanceof u||(f=u.create(f));for(var m=g===void 0?f.len:f.pos+g,_=new p.onnx.TypeProto.SparseTensor;f.pos<m;){var b=f.uint32();switch(b>>>3){case 1:_.elemType=f.int32();break;case 2:_.shape=p.onnx.TensorShapeProto.decode(f,f.uint32());break;default:f.skipType(7&b)}}return _},c.decodeDelimited=function(f){return f instanceof u||(f=new u(f)),this.decode(f,f.uint32())},c.verify=function(f){if(typeof f!="object"||f===null)return"object expected";if(f.elemType!=null&&f.hasOwnProperty("elemType")&&!h.isInteger(f.elemType))return"elemType: integer expected";if(f.shape!=null&&f.hasOwnProperty("shape")){var g=p.onnx.TensorShapeProto.verify(f.shape);if(g)return"shape."+g}return null},c.fromObject=function(f){if(f instanceof p.onnx.TypeProto.SparseTensor)return f;var g=new p.onnx.TypeProto.SparseTensor;if(f.elemType!=null&&(g.elemType=0|f.elemType),f.shape!=null){if(typeof f.shape!="object")throw TypeError(".onnx.TypeProto.SparseTensor.shape: object expected");g.shape=p.onnx.TensorShapeProto.fromObject(f.shape)}return g},c.toObject=function(f,g){g||(g={});var m={};return g.defaults&&(m.elemType=0,m.shape=null),f.elemType!=null&&f.hasOwnProperty("elemType")&&(m.elemType=f.elemType),f.shape!=null&&f.hasOwnProperty("shape")&&(m.shape=p.onnx.TensorShapeProto.toObject(f.shape,g)),m},c.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},c.getTypeUrl=function(f){return f===void 0&&(f="type.googleapis.com"),f+"/onnx.TypeProto.SparseTensor"},c}(),l}(),o.OperatorSetIdProto=function(){function l(i){if(i)for(var c=Object.keys(i),f=0;f<c.length;++f)i[c[f]]!=null&&(this[c[f]]=i[c[f]])}return l.prototype.domain="",l.prototype.version=h.Long?h.Long.fromBits(0,0,!1):0,l.create=function(i){return new l(i)},l.encode=function(i,c){return c||(c=d.create()),i.domain!=null&&Object.hasOwnProperty.call(i,"domain")&&c.uint32(10).string(i.domain),i.version!=null&&Object.hasOwnProperty.call(i,"version")&&c.uint32(16).int64(i.version),c},l.encodeDelimited=function(i,c){return this.encode(i,c).ldelim()},l.decode=function(i,c){i instanceof u||(i=u.create(i));for(var f=c===void 0?i.len:i.pos+c,g=new p.onnx.OperatorSetIdProto;i.pos<f;){var m=i.uint32();switch(m>>>3){case 1:g.domain=i.string();break;case 2:g.version=i.int64();break;default:i.skipType(7&m)}}return g},l.decodeDelimited=function(i){return i instanceof u||(i=new u(i)),this.decode(i,i.uint32())},l.verify=function(i){return typeof i!="object"||i===null?"object expected":i.domain!=null&&i.hasOwnProperty("domain")&&!h.isString(i.domain)?"domain: string expected":i.version!=null&&i.hasOwnProperty("version")&&!(h.isInteger(i.version)||i.version&&h.isInteger(i.version.low)&&h.isInteger(i.version.high))?"version: integer|Long expected":null},l.fromObject=function(i){if(i instanceof p.onnx.OperatorSetIdProto)return i;var c=new p.onnx.OperatorSetIdProto;return i.domain!=null&&(c.domain=String(i.domain)),i.version!=null&&(h.Long?(c.version=h.Long.fromValue(i.version)).unsigned=!1:typeof i.version=="string"?c.version=parseInt(i.version,10):typeof i.version=="number"?c.version=i.version:typeof i.version=="object"&&(c.version=new h.LongBits(i.version.low>>>0,i.version.high>>>0).toNumber())),c},l.toObject=function(i,c){c||(c={});var f={};if(c.defaults)if(f.domain="",h.Long){var g=new h.Long(0,0,!1);f.version=c.longs===String?g.toString():c.longs===Number?g.toNumber():g}else f.version=c.longs===String?"0":0;return i.domain!=null&&i.hasOwnProperty("domain")&&(f.domain=i.domain),i.version!=null&&i.hasOwnProperty("version")&&(typeof i.version=="number"?f.version=c.longs===String?String(i.version):i.version:f.version=c.longs===String?h.Long.prototype.toString.call(i.version):c.longs===Number?new h.LongBits(i.version.low>>>0,i.version.high>>>0).toNumber():i.version),f},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.OperatorSetIdProto"},l}(),o.OperatorStatus=function(){var l={},i=Object.create(l);return i[l[0]="EXPERIMENTAL"]=0,i[l[1]="STABLE"]=1,i}(),o.FunctionProto=function(){function l(i){if(this.input=[],this.output=[],this.attribute=[],this.attributeProto=[],this.node=[],this.opsetImport=[],i)for(var c=Object.keys(i),f=0;f<c.length;++f)i[c[f]]!=null&&(this[c[f]]=i[c[f]])}return l.prototype.name="",l.prototype.input=h.emptyArray,l.prototype.output=h.emptyArray,l.prototype.attribute=h.emptyArray,l.prototype.attributeProto=h.emptyArray,l.prototype.node=h.emptyArray,l.prototype.docString="",l.prototype.opsetImport=h.emptyArray,l.prototype.domain="",l.create=function(i){return new l(i)},l.encode=function(i,c){if(c||(c=d.create()),i.name!=null&&Object.hasOwnProperty.call(i,"name")&&c.uint32(10).string(i.name),i.input!=null&&i.input.length)for(var f=0;f<i.input.length;++f)c.uint32(34).string(i.input[f]);if(i.output!=null&&i.output.length)for(f=0;f<i.output.length;++f)c.uint32(42).string(i.output[f]);if(i.attribute!=null&&i.attribute.length)for(f=0;f<i.attribute.length;++f)c.uint32(50).string(i.attribute[f]);if(i.node!=null&&i.node.length)for(f=0;f<i.node.length;++f)p.onnx.NodeProto.encode(i.node[f],c.uint32(58).fork()).ldelim();if(i.docString!=null&&Object.hasOwnProperty.call(i,"docString")&&c.uint32(66).string(i.docString),i.opsetImport!=null&&i.opsetImport.length)for(f=0;f<i.opsetImport.length;++f)p.onnx.OperatorSetIdProto.encode(i.opsetImport[f],c.uint32(74).fork()).ldelim();if(i.domain!=null&&Object.hasOwnProperty.call(i,"domain")&&c.uint32(82).string(i.domain),i.attributeProto!=null&&i.attributeProto.length)for(f=0;f<i.attributeProto.length;++f)p.onnx.AttributeProto.encode(i.attributeProto[f],c.uint32(90).fork()).ldelim();return c},l.encodeDelimited=function(i,c){return this.encode(i,c).ldelim()},l.decode=function(i,c){i instanceof u||(i=u.create(i));for(var f=c===void 0?i.len:i.pos+c,g=new p.onnx.FunctionProto;i.pos<f;){var m=i.uint32();switch(m>>>3){case 1:g.name=i.string();break;case 4:g.input&&g.input.length||(g.input=[]),g.input.push(i.string());break;case 5:g.output&&g.output.length||(g.output=[]),g.output.push(i.string());break;case 6:g.attribute&&g.attribute.length||(g.attribute=[]),g.attribute.push(i.string());break;case 11:g.attributeProto&&g.attributeProto.length||(g.attributeProto=[]),g.attributeProto.push(p.onnx.AttributeProto.decode(i,i.uint32()));break;case 7:g.node&&g.node.length||(g.node=[]),g.node.push(p.onnx.NodeProto.decode(i,i.uint32()));break;case 8:g.docString=i.string();break;case 9:g.opsetImport&&g.opsetImport.length||(g.opsetImport=[]),g.opsetImport.push(p.onnx.OperatorSetIdProto.decode(i,i.uint32()));break;case 10:g.domain=i.string();break;default:i.skipType(7&m)}}return g},l.decodeDelimited=function(i){return i instanceof u||(i=new u(i)),this.decode(i,i.uint32())},l.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.name!=null&&i.hasOwnProperty("name")&&!h.isString(i.name))return"name: string expected";if(i.input!=null&&i.hasOwnProperty("input")){if(!Array.isArray(i.input))return"input: array expected";for(var c=0;c<i.input.length;++c)if(!h.isString(i.input[c]))return"input: string[] expected"}if(i.output!=null&&i.hasOwnProperty("output")){if(!Array.isArray(i.output))return"output: array expected";for(c=0;c<i.output.length;++c)if(!h.isString(i.output[c]))return"output: string[] expected"}if(i.attribute!=null&&i.hasOwnProperty("attribute")){if(!Array.isArray(i.attribute))return"attribute: array expected";for(c=0;c<i.attribute.length;++c)if(!h.isString(i.attribute[c]))return"attribute: string[] expected"}if(i.attributeProto!=null&&i.hasOwnProperty("attributeProto")){if(!Array.isArray(i.attributeProto))return"attributeProto: array expected";for(c=0;c<i.attributeProto.length;++c)if(f=p.onnx.AttributeProto.verify(i.attributeProto[c]))return"attributeProto."+f}if(i.node!=null&&i.hasOwnProperty("node")){if(!Array.isArray(i.node))return"node: array expected";for(c=0;c<i.node.length;++c)if(f=p.onnx.NodeProto.verify(i.node[c]))return"node."+f}if(i.docString!=null&&i.hasOwnProperty("docString")&&!h.isString(i.docString))return"docString: string expected";if(i.opsetImport!=null&&i.hasOwnProperty("opsetImport")){if(!Array.isArray(i.opsetImport))return"opsetImport: array expected";for(c=0;c<i.opsetImport.length;++c){var f;if(f=p.onnx.OperatorSetIdProto.verify(i.opsetImport[c]))return"opsetImport."+f}}return i.domain!=null&&i.hasOwnProperty("domain")&&!h.isString(i.domain)?"domain: string expected":null},l.fromObject=function(i){if(i instanceof p.onnx.FunctionProto)return i;var c=new p.onnx.FunctionProto;if(i.name!=null&&(c.name=String(i.name)),i.input){if(!Array.isArray(i.input))throw TypeError(".onnx.FunctionProto.input: array expected");c.input=[];for(var f=0;f<i.input.length;++f)c.input[f]=String(i.input[f])}if(i.output){if(!Array.isArray(i.output))throw TypeError(".onnx.FunctionProto.output: array expected");for(c.output=[],f=0;f<i.output.length;++f)c.output[f]=String(i.output[f])}if(i.attribute){if(!Array.isArray(i.attribute))throw TypeError(".onnx.FunctionProto.attribute: array expected");for(c.attribute=[],f=0;f<i.attribute.length;++f)c.attribute[f]=String(i.attribute[f])}if(i.attributeProto){if(!Array.isArray(i.attributeProto))throw TypeError(".onnx.FunctionProto.attributeProto: array expected");for(c.attributeProto=[],f=0;f<i.attributeProto.length;++f){if(typeof i.attributeProto[f]!="object")throw TypeError(".onnx.FunctionProto.attributeProto: object expected");c.attributeProto[f]=p.onnx.AttributeProto.fromObject(i.attributeProto[f])}}if(i.node){if(!Array.isArray(i.node))throw TypeError(".onnx.FunctionProto.node: array expected");for(c.node=[],f=0;f<i.node.length;++f){if(typeof i.node[f]!="object")throw TypeError(".onnx.FunctionProto.node: object expected");c.node[f]=p.onnx.NodeProto.fromObject(i.node[f])}}if(i.docString!=null&&(c.docString=String(i.docString)),i.opsetImport){if(!Array.isArray(i.opsetImport))throw TypeError(".onnx.FunctionProto.opsetImport: array expected");for(c.opsetImport=[],f=0;f<i.opsetImport.length;++f){if(typeof i.opsetImport[f]!="object")throw TypeError(".onnx.FunctionProto.opsetImport: object expected");c.opsetImport[f]=p.onnx.OperatorSetIdProto.fromObject(i.opsetImport[f])}}return i.domain!=null&&(c.domain=String(i.domain)),c},l.toObject=function(i,c){c||(c={});var f={};if((c.arrays||c.defaults)&&(f.input=[],f.output=[],f.attribute=[],f.node=[],f.opsetImport=[],f.attributeProto=[]),c.defaults&&(f.name="",f.docString="",f.domain=""),i.name!=null&&i.hasOwnProperty("name")&&(f.name=i.name),i.input&&i.input.length){f.input=[];for(var g=0;g<i.input.length;++g)f.input[g]=i.input[g]}if(i.output&&i.output.length)for(f.output=[],g=0;g<i.output.length;++g)f.output[g]=i.output[g];if(i.attribute&&i.attribute.length)for(f.attribute=[],g=0;g<i.attribute.length;++g)f.attribute[g]=i.attribute[g];if(i.node&&i.node.length)for(f.node=[],g=0;g<i.node.length;++g)f.node[g]=p.onnx.NodeProto.toObject(i.node[g],c);if(i.docString!=null&&i.hasOwnProperty("docString")&&(f.docString=i.docString),i.opsetImport&&i.opsetImport.length)for(f.opsetImport=[],g=0;g<i.opsetImport.length;++g)f.opsetImport[g]=p.onnx.OperatorSetIdProto.toObject(i.opsetImport[g],c);if(i.domain!=null&&i.hasOwnProperty("domain")&&(f.domain=i.domain),i.attributeProto&&i.attributeProto.length)for(f.attributeProto=[],g=0;g<i.attributeProto.length;++g)f.attributeProto[g]=p.onnx.AttributeProto.toObject(i.attributeProto[g],c);return f},l.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},l.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.FunctionProto"},l}(),o),s.exports=p},3474:(s,e,t)=>{var n,r=(n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0,typeof __filename<"u"&&(n=n||__filename),function(o={}){function a(){return B.buffer!=ee.buffer&&ge(),ee}function u(){return B.buffer!=ee.buffer&&ge(),Q}function d(){return B.buffer!=ee.buffer&&ge(),re}function h(){return B.buffer!=ee.buffer&&ge(),oe}function p(){return B.buffer!=ee.buffer&&ge(),ce}var l,i,c=o;c.ready=new Promise((O,D)=>{l=O,i=D});var f,g,m,_=Object.assign({},c),b="./this.program",v=(O,D)=>{throw D},T=typeof window=="object",y=typeof importScripts=="function",S=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",w=c.ENVIRONMENT_IS_PTHREAD||!1,k="";function P(O){return c.locateFile?c.locateFile(O,k):k+O}if(S){var I=t(1384),F=t(908);let O;k=y?F.dirname(k)+"/":__dirname+"/",f=(D,M)=>(D=D.startsWith("file://")?new URL(D):F.normalize(D),I.readFileSync(D,M?void 0:"utf8")),m=D=>((D=f(D,!0)).buffer||(D=new Uint8Array(D)),D),g=(D,M,V,q=!0)=>{D=D.startsWith("file://")?new URL(D):F.normalize(D),I.readFile(D,q?void 0:"utf8",(ne,ae)=>{ne?V(ne):M(q?ae.buffer:ae)})},!c.thisProgram&&1<process.argv.length&&(b=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),v=(D,M)=>{throw process.exitCode=D,M},c.inspect=()=>"[Emscripten Module object]";try{O=t(9925)}catch(D){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),D}commonjsGlobal.Worker=O.Worker}else(T||y)&&(y?k=self.location.href:typeof document<"u"&&document.currentScript&&(k=document.currentScript.src),n&&(k=n),k=k.indexOf("blob:")!==0?k.substr(0,k.replace(/[?#].*/,"").lastIndexOf("/")+1):"",S||(f=O=>{var D=new XMLHttpRequest;return D.open("GET",O,!1),D.send(null),D.responseText},y&&(m=O=>{var D=new XMLHttpRequest;return D.open("GET",O,!1),D.responseType="arraybuffer",D.send(null),new Uint8Array(D.response)}),g=(O,D,M)=>{var V=new XMLHttpRequest;V.open("GET",O,!0),V.responseType="arraybuffer",V.onload=()=>{V.status==200||V.status==0&&V.response?D(V.response):M()},V.onerror=M,V.send(null)}));S&&typeof performance>"u"&&(commonjsGlobal.performance=t(6953).performance);var C=console.log.bind(console),E=console.error.bind(console);S&&(C=(...O)=>I.writeSync(1,O.join(" ")+`
`),E=(...O)=>I.writeSync(2,O.join(" ")+`
`));var $,x=c.print||C,A=c.printErr||E;Object.assign(c,_),_=null,c.thisProgram&&(b=c.thisProgram),c.quit&&(v=c.quit),c.wasmBinary&&($=c.wasmBinary);var L=c.noExitRuntime||!0;typeof WebAssembly!="object"&&ke("no native wasm support detected");var B,H,J,X,ee,Q,re,oe,ce,fe=!1;function ge(){var O=B.buffer;c.HEAP8=ee=new Int8Array(O),c.HEAP16=new Int16Array(O),c.HEAP32=re=new Int32Array(O),c.HEAPU8=Q=new Uint8Array(O),c.HEAPU16=new Uint16Array(O),c.HEAPU32=oe=new Uint32Array(O),c.HEAPF32=new Float32Array(O),c.HEAPF64=ce=new Float64Array(O)}var we=c.INITIAL_MEMORY||16777216;if(5242880<=we||ke("INITIAL_MEMORY should be larger than STACK_SIZE, was "+we+"! (STACK_SIZE=5242880)"),w)B=c.wasmMemory;else if(c.wasmMemory)B=c.wasmMemory;else if(!((B=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"),S&&A("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");ge(),we=B.buffer.byteLength;var xe,_e=[],ye=[],pe=[],Se=0;function Ie(){return L||0<Se}var Oe,Pe,Ce=0,Ae=null;function $e(){Ce++,c.monitorRunDependencies&&c.monitorRunDependencies(Ce)}function Me(){if(Ce--,c.monitorRunDependencies&&c.monitorRunDependencies(Ce),Ce==0&&Ae){var O=Ae;Ae=null,O()}}function ke(O){throw c.onAbort&&c.onAbort(O),A(O="Aborted("+O+")"),fe=!0,X=1,O=new WebAssembly.RuntimeError(O+". Build with -sASSERTIONS for more info."),i(O),O}function Fe(O){return O.startsWith("data:application/octet-stream;base64,")}function Ze(O){if(O==Oe&&$)return new Uint8Array($);if(m)return m(O);throw"both async and sync fetching of the wasm failed"}function We(O,D,M){return function(V){if(!$&&(T||y)){if(typeof fetch=="function"&&!V.startsWith("file://"))return fetch(V,{credentials:"same-origin"}).then(q=>{if(!q.ok)throw"failed to load wasm binary file at '"+V+"'";return q.arrayBuffer()}).catch(()=>Ze(V));if(g)return new Promise((q,ne)=>{g(V,ae=>q(new Uint8Array(ae)),ne)})}return Promise.resolve().then(()=>Ze(V))}(O).then(V=>WebAssembly.instantiate(V,D)).then(V=>V).then(M,V=>{A("failed to asynchronously prepare wasm: "+V),ke(V)})}function je(O){this.name="ExitStatus",this.message=`Program terminated with exit(${O})`,this.status=O}function Ge(O){O.terminate(),O.onmessage=()=>{}}function ze(O){(O=se.Fa[O])||ke(),se.fb(O)}function qe(O){var D=se.Za();if(!D)return 6;se.Ia.push(D),se.Fa[O.Ha]=D,D.Ha=O.Ha;var M={cmd:"run",start_routine:O.gb,arg:O.Ya,pthread_ptr:O.Ha};return S&&D.unref(),D.postMessage(M,O.mb),0}Fe(Oe="ort-wasm-threaded.wasm")||(Oe=P(Oe));var Qe=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Ke=(O,D,M)=>{var V=(D>>>=0)+M;for(M=D;O[M]&&!(M>=V);)++M;if(16<M-D&&O.buffer&&Qe)return Qe.decode(O.buffer instanceof SharedArrayBuffer?O.slice(D,M):O.subarray(D,M));for(V="";D<M;){var q=O[D++];if(128&q){var ne=63&O[D++];if((224&q)==192)V+=String.fromCharCode((31&q)<<6|ne);else{var ae=63&O[D++];65536>(q=(240&q)==224?(15&q)<<12|ne<<6|ae:(7&q)<<18|ne<<12|ae<<6|63&O[D++])?V+=String.fromCharCode(q):(q-=65536,V+=String.fromCharCode(55296|q>>10,56320|1023&q))}}else V+=String.fromCharCode(q)}return V},Ue=(O,D)=>(O>>>=0)?Ke(u(),O,D):"";function Ye(O){if(w)return be(1,1,O);X=O,Ie()||(se.hb(),c.onExit&&c.onExit(O),fe=!0),v(O,new je(O))}var He=O=>{if(X=O,w)throw Xe(O),"unwind";Ye(O)},se={La:[],Ia:[],Ta:[],Fa:{},Pa:function(){w?se.ab():se.$a()},$a:function(){_e.unshift(()=>{$e(),se.bb(()=>Me())})},ab:function(){se.receiveObjectTransfer=se.eb,se.threadInitTLS=se.Sa,se.setExitStatus=se.Ra,L=!1},Ra:function(O){X=O},rb:["$terminateWorker"],hb:function(){for(var O of se.Ia)Ge(O);for(O of se.La)Ge(O);se.La=[],se.Ia=[],se.Fa=[]},fb:function(O){var D=O.Ha;delete se.Fa[D],se.La.push(O),se.Ia.splice(se.Ia.indexOf(O),1),O.Ha=0,dt(D)},eb:function(){},Sa:function(){se.Ta.forEach(O=>O())},cb:O=>new Promise(D=>{O.onmessage=q=>{var ne=(q=q.data).cmd;if(q.targetThread&&q.targetThread!=it()){var ae=se.Fa[q.qb];ae?ae.postMessage(q,q.transferList):A('Internal error! Worker sent a message "'+ne+'" to target pthread '+q.targetThread+", but that thread no longer exists!")}else ne==="checkMailbox"?rt():ne==="spawnThread"?qe(q):ne==="cleanupThread"?ze(q.thread):ne==="killThread"?(q=q.thread,ne=se.Fa[q],delete se.Fa[q],Ge(ne),dt(q),se.Ia.splice(se.Ia.indexOf(ne),1),ne.Ha=0):ne==="cancelThread"?se.Fa[q.thread].postMessage({cmd:"cancel"}):ne==="loaded"?(O.loaded=!0,D(O)):ne==="alert"?alert("Thread "+q.threadId+": "+q.text):q.target==="setimmediate"?O.postMessage(q):ne==="callHandler"?c[q.handler](...q.args):ne&&A("worker sent an unknown command "+ne)},O.onerror=q=>{throw A("worker sent an error! "+q.filename+":"+q.lineno+": "+q.message),q},S&&(O.on("message",function(q){O.onmessage({data:q})}),O.on("error",function(q){O.onerror(q)}));var M,V=[];for(M of["onExit","onAbort","print","printErr"])c.hasOwnProperty(M)&&V.push(M);O.postMessage({cmd:"load",handlers:V,urlOrBlob:c.mainScriptUrlOrBlob||n,wasmMemory:B,wasmModule:J})}),bb:function(O){O()},Xa:function(){var O=P("ort-wasm-threaded.worker.js");O=new Worker(O),se.La.push(O)},Za:function(){return se.La.length==0&&(se.Xa(),se.cb(se.La[0])),se.La.pop()}};c.PThread=se;var Be=O=>{for(;0<O.length;)O.shift()(c)};function Xe(O){if(w)return be(2,0,O);He(O)}c.establishStackSpace=function(){var O=it(),D=d()[O+52>>2>>>0];O=d()[O+56>>2>>>0],Mt(D,D-O),at(D)};var R=[];function U(O){this.Oa=O-24,this.Wa=function(D){h()[this.Oa+4>>2>>>0]=D},this.Va=function(D){h()[this.Oa+8>>2>>>0]=D},this.Pa=function(D,M){this.Ua(),this.Wa(D),this.Va(M)},this.Ua=function(){h()[this.Oa+16>>2>>>0]=0}}function G(O,D,M,V){return w?be(3,1,O,D,M,V):Y(O,D,M,V)}function Y(O,D,M,V){if(O>>>=0,D>>>=0,M>>>=0,V>>>=0,typeof SharedArrayBuffer>"u")return A("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var q=[];return w&&q.length===0?G(O,D,M,V):(O={gb:M,Ha:O,Ya:V,mb:q},w?(O.ob="spawnThread",postMessage(O,q),0):qe(O))}function N(O,D,M){return w?be(4,1,O,D,M):0}function j(O,D){if(w)return be(5,1,O,D)}c.invokeEntryPoint=function(O,D){var M=R[O];M||(O>=R.length&&(R.length=O+1),R[O]=M=xe.get(O)),O=M(D),Ie()?se.Ra(O):ft(O)};var Z=O=>{for(var D=0,M=0;M<O.length;++M){var V=O.charCodeAt(M);127>=V?D++:2047>=V?D+=2:55296<=V&&57343>=V?(D+=4,++M):D+=3}return D},te=(O,D,M,V)=>{if(!(0<V))return 0;var q=M>>>=0;V=M+V-1;for(var ne=0;ne<O.length;++ne){var ae=O.charCodeAt(ne);if(55296<=ae&&57343>=ae&&(ae=65536+((1023&ae)<<10)|1023&O.charCodeAt(++ne)),127>=ae){if(M>=V)break;D[M++>>>0]=ae}else{if(2047>=ae){if(M+1>=V)break;D[M++>>>0]=192|ae>>6}else{if(65535>=ae){if(M+2>=V)break;D[M++>>>0]=224|ae>>12}else{if(M+3>=V)break;D[M++>>>0]=240|ae>>18,D[M++>>>0]=128|ae>>12&63}D[M++>>>0]=128|ae>>6&63}D[M++>>>0]=128|63&ae}}return D[M>>>0]=0,M-q},ie=(O,D,M)=>te(O,u(),D,M);function ue(O,D){if(w)return be(6,1,O,D)}function le(O,D,M){if(w)return be(7,1,O,D,M)}function Ne(O,D,M){return w?be(8,1,O,D,M):0}function Re(O,D){if(w)return be(9,1,O,D)}function W(O,D,M){if(w)return be(10,1,O,D,M)}function de(O,D,M,V){if(w)return be(11,1,O,D,M,V)}function me(O,D,M,V){if(w)return be(12,1,O,D,M,V)}function Ve(O,D,M,V){if(w)return be(13,1,O,D,M,V)}function tt(O){if(w)return be(14,1,O)}function gt(O,D){if(w)return be(15,1,O,D)}function mt(O,D,M){if(w)return be(16,1,O,D,M)}var zt=O=>{if(!fe)try{if(O(),!Ie())try{w?ft(X):He(X)}catch(D){D instanceof je||D=="unwind"||v(1,D)}}catch(D){D instanceof je||D=="unwind"||v(1,D)}};function st(O){O>>>=0,typeof Atomics.nb=="function"&&(Atomics.nb(d(),O>>2,O).value.then(rt),O+=128,Atomics.store(d(),O>>2,1))}function rt(){var O=it();O&&(st(O),zt(()=>Ft()))}c.__emscripten_thread_mailbox_await=st,c.checkMailbox=rt;var et=O=>O%4==0&&(O%100!=0||O%400==0),_t=[0,31,60,91,121,152,182,213,244,274,305,335],bt=[0,31,59,90,120,151,181,212,243,273,304,334];function yt(O,D,M,V,q,ne,ae,ve){return w?be(17,1,O,D,M,V,q,ne,ae,ve):-52}function vt(O,D,M,V,q,ne,ae){if(w)return be(18,1,O,D,M,V,q,ne,ae)}var Tt=O=>{var D=Z(O)+1,M=Nt(D);return M&&ie(O,M,D),M},Ht=O=>{var D=ht();return O=O(),at(D),O};function be(O,D){var M=arguments.length-2,V=arguments;return Ht(()=>{for(var q=pt(8*M),ne=q>>3,ae=0;ae<M;ae++){var ve=V[2+ae];p()[ne+ae>>>0]=ve}return Rt(O,M,q,D)})}var lt,ct=[],ut={},wt=()=>{if(!lt){var O,D={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 ut)ut[O]===void 0?delete D[O]:D[O]=ut[O];var M=[];for(O in D)M.push(`${O}=${D[O]}`);lt=M}return lt};function St(O,D){if(w)return be(19,1,O,D);O>>>=0,D>>>=0;var M=0;return wt().forEach(function(V,q){var ne=D+M;for(q=h()[O+4*q>>2>>>0]=ne,ne=0;ne<V.length;++ne)a()[q++>>0>>>0]=V.charCodeAt(ne);a()[q>>0>>>0]=0,M+=V.length+1}),0}function xt(O,D){if(w)return be(20,1,O,D);O>>>=0,D>>>=0;var M=wt();h()[O>>2>>>0]=M.length;var V=0;return M.forEach(function(q){V+=q.length+1}),h()[D>>2>>>0]=V,0}function Ot(O){return w?be(21,1,O):52}function kt(O,D,M,V){return w?be(22,1,O,D,M,V):52}function Et(O,D,M,V,q){return w?be(23,1,O,D,M,V,q):70}var Zt=[null,[],[]];function It(O,D,M,V){if(w)return be(24,1,O,D,M,V);D>>>=0,M>>>=0,V>>>=0;for(var q=0,ne=0;ne<M;ne++){var ae=h()[D>>2>>>0],ve=h()[D+4>>2>>>0];D+=8;for(var Le=0;Le<ve;Le++){var Ee=u()[ae+Le>>>0],De=Zt[O];Ee===0||Ee===10?((O===1?x:A)(Ke(De,0)),De.length=0):De.push(Ee)}q+=ve}return h()[V>>2>>>0]=q,0}var Pt=O=>(Pt=(()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return V=>(V.set(crypto.getRandomValues(new Uint8Array(V.byteLength))),V);if(S)try{var D=t(760);if(D.randomFillSync)return V=>D.randomFillSync(V);var M=D.randomBytes;return V=>(V.set(M(V.byteLength)),V)}catch{}ke("initRandomDevice")})())(O),At=[31,29,31,30,31,30,31,31,30,31,30,31],Ct=[31,28,31,30,31,30,31,31,30,31,30,31],Wt=(O,D)=>{a().set(O,D>>>0)};function $t(O,D,M,V){function q(K,he,Te){for(K=typeof K=="number"?K.toString():K||"";K.length<he;)K=Te[0]+K;return K}function ne(K,he){return q(K,he,"0")}function ae(K,he){function Te(Gt){return 0>Gt?-1:0<Gt?1:0}var Je;return(Je=Te(K.getFullYear()-he.getFullYear()))===0&&(Je=Te(K.getMonth()-he.getMonth()))===0&&(Je=Te(K.getDate()-he.getDate())),Je}function ve(K){switch(K.getDay()){case 0:return new Date(K.getFullYear()-1,11,29);case 1:return K;case 2:return new Date(K.getFullYear(),0,3);case 3:return new Date(K.getFullYear(),0,2);case 4:return new Date(K.getFullYear(),0,1);case 5:return new Date(K.getFullYear()-1,11,31);case 6:return new Date(K.getFullYear()-1,11,30)}}function Le(K){var he=K.Ja;for(K=new Date(new Date(K.Ka+1900,0,1).getTime());0<he;){var Te=K.getMonth(),Je=(et(K.getFullYear())?At:Ct)[Te];if(!(he>Je-K.getDate())){K.setDate(K.getDate()+he);break}he-=Je-K.getDate()+1,K.setDate(1),11>Te?K.setMonth(Te+1):(K.setMonth(0),K.setFullYear(K.getFullYear()+1))}return Te=new Date(K.getFullYear()+1,0,4),he=ve(new Date(K.getFullYear(),0,4)),Te=ve(Te),0>=ae(he,K)?0>=ae(Te,K)?K.getFullYear()+1:K.getFullYear():K.getFullYear()-1}O>>>=0,D>>>=0,M>>>=0,V>>>=0;var Ee=d()[V+40>>2>>>0];for(var De in V={kb:d()[V>>2>>>0],jb:d()[V+4>>2>>>0],Ma:d()[V+8>>2>>>0],Qa:d()[V+12>>2>>>0],Na:d()[V+16>>2>>>0],Ka:d()[V+20>>2>>>0],Ga:d()[V+24>>2>>>0],Ja:d()[V+28>>2>>>0],sb:d()[V+32>>2>>>0],ib:d()[V+36>>2>>>0],lb:Ee?Ue(Ee):""},M=Ue(M),Ee={"%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"})M=M.replace(new RegExp(De,"g"),Ee[De]);var Ut="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 Ee={"%a":K=>Ut[K.Ga].substring(0,3),"%A":K=>Ut[K.Ga],"%b":K=>Vt[K.Na].substring(0,3),"%B":K=>Vt[K.Na],"%C":K=>ne((K.Ka+1900)/100|0,2),"%d":K=>ne(K.Qa,2),"%e":K=>q(K.Qa,2," "),"%g":K=>Le(K).toString().substring(2),"%G":K=>Le(K),"%H":K=>ne(K.Ma,2),"%I":K=>((K=K.Ma)==0?K=12:12<K&&(K-=12),ne(K,2)),"%j":K=>{for(var he=0,Te=0;Te<=K.Na-1;he+=(et(K.Ka+1900)?At:Ct)[Te++]);return ne(K.Qa+he,3)},"%m":K=>ne(K.Na+1,2),"%M":K=>ne(K.jb,2),"%n":()=>`
`,"%p":K=>0<=K.Ma&&12>K.Ma?"AM":"PM","%S":K=>ne(K.kb,2),"%t":()=>"	","%u":K=>K.Ga||7,"%U":K=>ne(Math.floor((K.Ja+7-K.Ga)/7),2),"%V":K=>{var he=Math.floor((K.Ja+7-(K.Ga+6)%7)/7);if(2>=(K.Ga+371-K.Ja-2)%7&&he++,he)he==53&&((Te=(K.Ga+371-K.Ja)%7)==4||Te==3&&et(K.Ka)||(he=1));else{he=52;var Te=(K.Ga+7-K.Ja-1)%7;(Te==4||Te==5&&et(K.Ka%400-1))&&he++}return ne(he,2)},"%w":K=>K.Ga,"%W":K=>ne(Math.floor((K.Ja+7-(K.Ga+6)%7)/7),2),"%y":K=>(K.Ka+1900).toString().substring(2),"%Y":K=>K.Ka+1900,"%z":K=>{var he=0<=(K=K.ib);return K=Math.abs(K)/60,(he?"+":"-")+("0000"+(K/60*100+K%60)).slice(-4)},"%Z":K=>K.lb,"%%":()=>"%"},M=M.replace(/%%/g,"\0\0"),Ee)M.includes(De)&&(M=M.replace(new RegExp(De,"g"),Ee[De](V)));return De=function(K){var he=Array(Z(K)+1);return te(K,he,0,he.length),he}(M=M.replace(/\0\0/g,"%")),De.length>D?0:(Wt(De,O),De.length-1)}se.Pa();var qt=[null,Ye,Xe,G,N,j,ue,le,Ne,Re,W,de,me,Ve,tt,gt,mt,yt,vt,St,xt,Ot,kt,Et,It],Kt={b:function(O,D,M){throw new U(O>>>=0).Pa(D>>>0,M>>>0),O},N:function(O){Dt(O>>>0,!y,1,!T,131072,!1),se.Sa()},k:function(O){O>>>=0,w?postMessage({cmd:"cleanupThread",thread:O}):ze(O)},I:Y,h:N,T:j,E:ue,G:le,U:Ne,R:Re,J:W,Q:de,o:me,F:Ve,C:tt,S:gt,D:mt,q:()=>!0,A:function(O,D){(O>>>=0)==D>>>0?setTimeout(()=>rt()):w?postMessage({targetThread:O,cmd:"checkMailbox"}):(O=se.Fa[O])&&O.postMessage({cmd:"checkMailbox"})},L:function(){return-1},M:st,p:function(O){S&&se.Fa[O>>>0].ref()},t:function(O,D,M){O=D+2097152>>>0<4194305-!!O?(O>>>0)+4294967296*D:NaN,M>>>=0,O=new Date(1e3*O),d()[M>>2>>>0]=O.getUTCSeconds(),d()[M+4>>2>>>0]=O.getUTCMinutes(),d()[M+8>>2>>>0]=O.getUTCHours(),d()[M+12>>2>>>0]=O.getUTCDate(),d()[M+16>>2>>>0]=O.getUTCMonth(),d()[M+20>>2>>>0]=O.getUTCFullYear()-1900,d()[M+24>>2>>>0]=O.getUTCDay(),O=(O.getTime()-Date.UTC(O.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,d()[M+28>>2>>>0]=O},u:function(O,D,M){O=D+2097152>>>0<4194305-!!O?(O>>>0)+4294967296*D:NaN,M>>>=0,O=new Date(1e3*O),d()[M>>2>>>0]=O.getSeconds(),d()[M+4>>2>>>0]=O.getMinutes(),d()[M+8>>2>>>0]=O.getHours(),d()[M+12>>2>>>0]=O.getDate(),d()[M+16>>2>>>0]=O.getMonth(),d()[M+20>>2>>>0]=O.getFullYear()-1900,d()[M+24>>2>>>0]=O.getDay(),D=(et(O.getFullYear())?_t:bt)[O.getMonth()]+O.getDate()-1|0,d()[M+28>>2>>>0]=D,d()[M+36>>2>>>0]=-60*O.getTimezoneOffset(),D=new Date(O.getFullYear(),6,1).getTimezoneOffset();var V=new Date(O.getFullYear(),0,1).getTimezoneOffset();O=0|(D!=V&&O.getTimezoneOffset()==Math.min(V,D)),d()[M+32>>2>>>0]=O},v:function(O){O>>>=0;var D=new Date(d()[O+20>>2>>>0]+1900,d()[O+16>>2>>>0],d()[O+12>>2>>>0],d()[O+8>>2>>>0],d()[O+4>>2>>>0],d()[O>>2>>>0],0),M=d()[O+32>>2>>>0],V=D.getTimezoneOffset(),q=new Date(D.getFullYear(),6,1).getTimezoneOffset(),ne=new Date(D.getFullYear(),0,1).getTimezoneOffset(),ae=Math.min(ne,q);return 0>M?d()[O+32>>2>>>0]=+(q!=ne&&ae==V):0<M!=(ae==V)&&(q=Math.max(ne,q),D.setTime(D.getTime()+6e4*((0<M?ae:q)-V))),d()[O+24>>2>>>0]=D.getDay(),M=(et(D.getFullYear())?_t:bt)[D.getMonth()]+D.getDate()-1|0,d()[O+28>>2>>>0]=M,d()[O>>2>>>0]=D.getSeconds(),d()[O+4>>2>>>0]=D.getMinutes(),d()[O+8>>2>>>0]=D.getHours(),d()[O+12>>2>>>0]=D.getDate(),d()[O+16>>2>>>0]=D.getMonth(),d()[O+20>>2>>>0]=D.getYear(),O=D.getTime()/1e3,Lt((Pe=O,1<=+Math.abs(Pe)?0<Pe?+Math.floor(Pe/4294967296)>>>0:~~+Math.ceil((Pe-+(~~Pe>>>0))/4294967296)>>>0:0)),O>>>0},r:yt,s:vt,z:function(O,D,M){function V(Ee){return(Ee=Ee.toTimeString().match(/\(([A-Za-z ]+)\)$/))?Ee[1]:"GMT"}O>>>=0,D>>>=0,M>>>=0;var q=new Date().getFullYear(),ne=new Date(q,0,1),ae=new Date(q,6,1);q=ne.getTimezoneOffset();var ve=ae.getTimezoneOffset(),Le=Math.max(q,ve);h()[O>>2>>>0]=60*Le,d()[D>>2>>>0]=+(q!=ve),O=V(ne),D=V(ae),O=Tt(O),D=Tt(D),ve<q?(h()[M>>2>>>0]=O,h()[M+4>>2>>>0]=D):(h()[M>>2>>>0]=D,h()[M+4>>2>>>0]=O)},c:()=>{ke("")},l:function(){},i:function(){return Date.now()},V:()=>{throw Se+=1,"unwind"},B:function(){return 4294901760},e:()=>performance.timeOrigin+performance.now(),f:function(){return S?t(3993).cpus().length:navigator.hardwareConcurrency},K:function(O,D,M,V){for(se.pb=D>>>0,ct.length=M,D=V>>>0>>3,V=0;V<M;V++)ct[V]=p()[D+V>>>0];return qt[O].apply(null,ct)},y:function(O){O>>>=0;var D=u().length;if(O<=D||4294901760<O)return!1;for(var M=1;4>=M;M*=2){var V=D*(1+.2/M);V=Math.min(V,O+100663296);var q=Math;V=Math.max(O,V);e:{q=q.min.call(q,4294901760,V+(65536-V%65536)%65536)-B.buffer.byteLength+65535>>>16;try{B.grow(q),ge();var ne=1;break e}catch{}ne=void 0}if(ne)return!0}return!1},O:St,P:xt,j:He,g:Ot,n:kt,w:Et,m:It,x:function(O,D){return O>>>=0,D>>>=0,Pt(u().subarray(O>>>0,O+D>>>0)),0},a:B||c.wasmMemory,H:$t,d:function(O,D,M,V){return $t(O>>>0,D>>>0,M>>>0,V>>>0)}};(function(){function O(M,V){return M=M.exports,H=M=function(q){var ne=ve=>()=>ve()>>>0,ae=ve=>Le=>ve(Le)>>>0;return(q=Object.assign({},q)).__errno_location=ne(q.__errno_location),q.pthread_self=ne(q.pthread_self),q.malloc=ae(q.malloc),q.stackSave=ne(q.stackSave),q.stackAlloc=ae(q.stackAlloc),q}(M),se.Ta.push(H.sa),xe=H.ta,ye.unshift(H.W),J=V,Me(),M}var D={a:Kt};if($e(),c.instantiateWasm)try{return c.instantiateWasm(D,O)}catch(M){A("Module.instantiateWasm callback failed with error: "+M),i(M)}(function(M,V){var q=Oe;return $||typeof WebAssembly.instantiateStreaming!="function"||Fe(q)||q.startsWith("file://")||S||typeof fetch!="function"?We(q,M,V):fetch(q,{credentials:"same-origin"}).then(ne=>WebAssembly.instantiateStreaming(ne,M).then(V,function(ae){return A("wasm streaming compile failed: "+ae),A("falling back to ArrayBuffer instantiation"),We(q,M,V)}))})(D,function(M){O(M.instance,M.module)}).catch(i)})(),c._OrtInit=(O,D)=>(c._OrtInit=H.X)(O,D),c._OrtGetLastError=(O,D)=>(c._OrtGetLastError=H.Y)(O,D),c._OrtCreateSessionOptions=(O,D,M,V,q,ne,ae,ve,Le,Ee)=>(c._OrtCreateSessionOptions=H.Z)(O,D,M,V,q,ne,ae,ve,Le,Ee),c._OrtAppendExecutionProvider=(O,D)=>(c._OrtAppendExecutionProvider=H._)(O,D),c._OrtAddSessionConfigEntry=(O,D,M)=>(c._OrtAddSessionConfigEntry=H.$)(O,D,M),c._OrtReleaseSessionOptions=O=>(c._OrtReleaseSessionOptions=H.aa)(O),c._OrtCreateSession=(O,D,M)=>(c._OrtCreateSession=H.ba)(O,D,M),c._OrtReleaseSession=O=>(c._OrtReleaseSession=H.ca)(O),c._OrtGetInputOutputCount=(O,D,M)=>(c._OrtGetInputOutputCount=H.da)(O,D,M),c._OrtGetInputName=(O,D)=>(c._OrtGetInputName=H.ea)(O,D),c._OrtGetOutputName=(O,D)=>(c._OrtGetOutputName=H.fa)(O,D),c._OrtFree=O=>(c._OrtFree=H.ga)(O),c._OrtCreateTensor=(O,D,M,V,q)=>(c._OrtCreateTensor=H.ha)(O,D,M,V,q),c._OrtGetTensorData=(O,D,M,V,q)=>(c._OrtGetTensorData=H.ia)(O,D,M,V,q),c._OrtReleaseTensor=O=>(c._OrtReleaseTensor=H.ja)(O),c._OrtCreateRunOptions=(O,D,M,V)=>(c._OrtCreateRunOptions=H.ka)(O,D,M,V),c._OrtAddRunConfigEntry=(O,D,M)=>(c._OrtAddRunConfigEntry=H.la)(O,D,M),c._OrtReleaseRunOptions=O=>(c._OrtReleaseRunOptions=H.ma)(O),c._OrtRun=(O,D,M,V,q,ne,ae,ve)=>(c._OrtRun=H.na)(O,D,M,V,q,ne,ae,ve),c._OrtEndProfiling=O=>(c._OrtEndProfiling=H.oa)(O);var it=c._pthread_self=()=>(it=c._pthread_self=H.pa)(),Nt=c._malloc=O=>(Nt=c._malloc=H.qa)(O);c._free=O=>(c._free=H.ra)(O),c.__emscripten_tls_init=()=>(c.__emscripten_tls_init=H.sa)();var Dt=c.__emscripten_thread_init=(O,D,M,V,q,ne)=>(Dt=c.__emscripten_thread_init=H.ua)(O,D,M,V,q,ne);c.__emscripten_thread_crashed=()=>(c.__emscripten_thread_crashed=H.va)();var ot,Rt=(O,D,M,V)=>(Rt=H.wa)(O,D,M,V),dt=O=>(dt=H.xa)(O),ft=c.__emscripten_thread_exit=O=>(ft=c.__emscripten_thread_exit=H.ya)(O),Ft=c.__emscripten_check_mailbox=()=>(Ft=c.__emscripten_check_mailbox=H.za)(),Lt=O=>(Lt=H.Aa)(O),Mt=(O,D)=>(Mt=H.Ba)(O,D),ht=()=>(ht=H.Ca)(),at=O=>(at=H.Da)(O),pt=O=>(pt=H.Ea)(O);function jt(){function O(){if(!ot&&(ot=!0,c.calledRun=!0,!fe)&&(w||Be(ye),l(c),c.onRuntimeInitialized&&c.onRuntimeInitialized(),!w)){if(c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;){var D=c.postRun.shift();pe.unshift(D)}Be(pe)}}if(!(0<Ce))if(w)l(c),w||Be(ye),startWorker(c);else{if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)_e.unshift(c.preRun.shift());Be(_e),0<Ce||(c.setStatus?(c.setStatus("Running..."),setTimeout(function(){setTimeout(function(){c.setStatus("")},1),O()},1)):O())}}if(c.keepRuntimeAlive=Ie,c.wasmMemory=B,c.stackAlloc=pt,c.stackSave=ht,c.stackRestore=at,c.UTF8ToString=Ue,c.stringToUTF8=ie,c.lengthBytesUTF8=Z,c.ExitStatus=je,c.PThread=se,Ae=function O(){ot||jt(),ot||(Ae=O)},c.preInit)for(typeof c.preInit=="function"&&(c.preInit=[c.preInit]);0<c.preInit.length;)c.preInit.pop()();return jt(),o.ready});s.exports=r},932:(s,e,t)=>{var n,r=(n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0,typeof __filename<"u"&&(n=n||__filename),function(o={}){var a,u,d=o;d.ready=new Promise((R,U)=>{a=R,u=U});var h,p,l,i=Object.assign({},d),c="./this.program",f=(R,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 v=t(1384),T=t(908);b=m?T.dirname(b)+"/":__dirname+"/",h=(R,U)=>(R=R.startsWith("file://")?new URL(R):T.normalize(R),v.readFileSync(R,U?void 0:"utf8")),l=R=>((R=h(R,!0)).buffer||(R=new Uint8Array(R)),R),p=(R,U,G,Y=!0)=>{R=R.startsWith("file://")?new URL(R):T.normalize(R),v.readFile(R,Y?void 0:"utf8",(N,j)=>{N?G(N):U(Y?j.buffer:j)})},!d.thisProgram&&1<process.argv.length&&(c=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),f=(R,U)=>{throw process.exitCode=R,U},d.inspect=()=>"[Emscripten Module object]"}else(g||m)&&(m?b=self.location.href:typeof document<"u"&&document.currentScript&&(b=document.currentScript.src),n&&(b=n),b=b.indexOf("blob:")!==0?b.substr(0,b.replace(/[?#].*/,"").lastIndexOf("/")+1):"",h=R=>{var U=new XMLHttpRequest;return U.open("GET",R,!1),U.send(null),U.responseText},m&&(l=R=>{var U=new XMLHttpRequest;return U.open("GET",R,!1),U.responseType="arraybuffer",U.send(null),new Uint8Array(U.response)}),p=(R,U,G)=>{var Y=new XMLHttpRequest;Y.open("GET",R,!0),Y.responseType="arraybuffer",Y.onload=()=>{Y.status==200||Y.status==0&&Y.response?U(Y.response):G()},Y.onerror=G,Y.send(null)});var y,S=d.print||console.log.bind(console),w=d.printErr||console.error.bind(console);Object.assign(d,i),i=null,d.thisProgram&&(c=d.thisProgram),d.quit&&(f=d.quit),d.wasmBinary&&(y=d.wasmBinary);var k=d.noExitRuntime||!0;typeof WebAssembly!="object"&&oe("no native wasm support detected");var P,I,F,C,E,$,x=!1;function A(){var R=P.buffer;d.HEAP8=F=new Int8Array(R),d.HEAP16=new Int16Array(R),d.HEAP32=E=new Int32Array(R),d.HEAPU8=C=new Uint8Array(R),d.HEAPU16=new Uint16Array(R),d.HEAPU32=$=new Uint32Array(R),d.HEAPF32=new Float32Array(R),d.HEAPF64=new Float64Array(R)}var L=[],B=[],H=[];function J(){var R=d.preRun.shift();L.unshift(R)}var X,ee,Q=0,re=null;function oe(R){throw d.onAbort&&d.onAbort(R),w(R="Aborted("+R+")"),x=!0,R=new WebAssembly.RuntimeError(R+". Build with -sASSERTIONS for more info."),u(R),R}function ce(R){return R.startsWith("data:application/octet-stream;base64,")}if(!ce(X="ort-wasm.wasm")){var fe=X;X=d.locateFile?d.locateFile(fe,b):b+fe}function ge(R){if(R==X&&y)return new Uint8Array(y);if(l)return l(R);throw"both async and sync fetching of the wasm failed"}function we(R,U,G){return function(Y){if(!y&&(g||m)){if(typeof fetch=="function"&&!Y.startsWith("file://"))return fetch(Y,{credentials:"same-origin"}).then(N=>{if(!N.ok)throw"failed to load wasm binary file at '"+Y+"'";return N.arrayBuffer()}).catch(()=>ge(Y));if(p)return new Promise((N,j)=>{p(Y,Z=>N(new Uint8Array(Z)),j)})}return Promise.resolve().then(()=>ge(Y))}(R).then(Y=>WebAssembly.instantiate(Y,U)).then(Y=>Y).then(G,Y=>{w("failed to asynchronously prepare wasm: "+Y),oe(Y)})}function xe(R){this.name="ExitStatus",this.message=`Program terminated with exit(${R})`,this.status=R}var _e=R=>{for(;0<R.length;)R.shift()(d)};function ye(R){this.qa=R-24,this.va=function(U){$[this.qa+4>>2>>>0]=U},this.ua=function(U){$[this.qa+8>>2>>>0]=U},this.sa=function(U,G){this.ta(),this.va(U),this.ua(G)},this.ta=function(){$[this.qa+16>>2>>>0]=0}}var pe,Se=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Ie=(R,U,G)=>{var Y=(U>>>=0)+G;for(G=U;R[G]&&!(G>=Y);)++G;if(16<G-U&&R.buffer&&Se)return Se.decode(R.subarray(U,G));for(Y="";U<G;){var N=R[U++];if(128&N){var j=63&R[U++];if((224&N)==192)Y+=String.fromCharCode((31&N)<<6|j);else{var Z=63&R[U++];65536>(N=(240&N)==224?(15&N)<<12|j<<6|Z:(7&N)<<18|j<<12|Z<<6|63&R[U++])?Y+=String.fromCharCode(N):(N-=65536,Y+=String.fromCharCode(55296|N>>10,56320|1023&N))}}else Y+=String.fromCharCode(N)}return Y},Oe=(R,U)=>(R>>>=0)?Ie(C,R,U):"",Pe=R=>{for(var U=0,G=0;G<R.length;++G){var Y=R.charCodeAt(G);127>=Y?U++:2047>=Y?U+=2:55296<=Y&&57343>=Y?(U+=4,++G):U+=3}return U},Ce=(R,U,G,Y)=>{if(!(0<Y))return 0;var N=G>>>=0;Y=G+Y-1;for(var j=0;j<R.length;++j){var Z=R.charCodeAt(j);if(55296<=Z&&57343>=Z&&(Z=65536+((1023&Z)<<10)|1023&R.charCodeAt(++j)),127>=Z){if(G>=Y)break;U[G++>>>0]=Z}else{if(2047>=Z){if(G+1>=Y)break;U[G++>>>0]=192|Z>>6}else{if(65535>=Z){if(G+2>=Y)break;U[G++>>>0]=224|Z>>12}else{if(G+3>=Y)break;U[G++>>>0]=240|Z>>18,U[G++>>>0]=128|Z>>12&63}U[G++>>>0]=128|Z>>6&63}U[G++>>>0]=128|63&Z}}return U[G>>>0]=0,G-N},Ae=R=>R%4==0&&(R%100!=0||R%400==0),$e=[0,31,60,91,121,152,182,213,244,274,305,335],Me=[0,31,59,90,120,151,181,212,243,273,304,334],ke=R=>{var U=Pe(R)+1,G=Ke(U);return G&&Ce(R,C,G,U),G},Fe={},Ze=()=>{if(!pe){var R,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",_:c||"./this.program"};for(R in Fe)Fe[R]===void 0?delete U[R]:U[R]=Fe[R];var G=[];for(R in U)G.push(`${R}=${U[R]}`);pe=G}return pe},We=[null,[],[]],je=R=>(je=(()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return Y=>crypto.getRandomValues(Y);if(_)try{var U=t(760);if(U.randomFillSync)return Y=>U.randomFillSync(Y);var G=U.randomBytes;return Y=>(Y.set(G(Y.byteLength)),Y)}catch{}oe("initRandomDevice")})())(R),Ge=[31,29,31,30,31,30,31,31,30,31,30,31],ze=[31,28,31,30,31,30,31,31,30,31,30,31];function qe(R,U,G,Y){function N(W,de,me){for(W=typeof W=="number"?W.toString():W||"";W.length<de;)W=me[0]+W;return W}function j(W,de){return N(W,de,"0")}function Z(W,de){function me(tt){return 0>tt?-1:0<tt?1:0}var Ve;return(Ve=me(W.getFullYear()-de.getFullYear()))===0&&(Ve=me(W.getMonth()-de.getMonth()))===0&&(Ve=me(W.getDate()-de.getDate())),Ve}function te(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 ie(W){var de=W.ma;for(W=new Date(new Date(W.na+1900,0,1).getTime());0<de;){var me=W.getMonth(),Ve=(Ae(W.getFullYear())?Ge:ze)[me];if(!(de>Ve-W.getDate())){W.setDate(W.getDate()+de);break}de-=Ve-W.getDate()+1,W.setDate(1),11>me?W.setMonth(me+1):(W.setMonth(0),W.setFullYear(W.getFullYear()+1))}return me=new Date(W.getFullYear()+1,0,4),de=te(new Date(W.getFullYear(),0,4)),me=te(me),0>=Z(de,W)?0>=Z(me,W)?W.getFullYear()+1:W.getFullYear():W.getFullYear()-1}R>>>=0,U>>>=0,G>>>=0;var ue=E[40+(Y>>>=0)>>2>>>0];for(var le in Y={ya:E[Y>>2>>>0],xa:E[Y+4>>2>>>0],oa:E[Y+8>>2>>>0],ra:E[Y+12>>2>>>0],pa:E[Y+16>>2>>>0],na:E[Y+20>>2>>>0],ha:E[Y+24>>2>>>0],ma:E[Y+28>>2>>>0],Aa:E[Y+32>>2>>>0],wa:E[Y+36>>2>>>0],za:ue?Oe(ue):""},G=Oe(G),ue={"%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"})G=G.replace(new RegExp(le,"g"),ue[le]);var Ne="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Re="January February March April May June July August September October November December".split(" ");for(le in ue={"%a":W=>Ne[W.ha].substring(0,3),"%A":W=>Ne[W.ha],"%b":W=>Re[W.pa].substring(0,3),"%B":W=>Re[W.pa],"%C":W=>j((W.na+1900)/100|0,2),"%d":W=>j(W.ra,2),"%e":W=>N(W.ra,2," "),"%g":W=>ie(W).toString().substring(2),"%G":W=>ie(W),"%H":W=>j(W.oa,2),"%I":W=>((W=W.oa)==0?W=12:12<W&&(W-=12),j(W,2)),"%j":W=>{for(var de=0,me=0;me<=W.pa-1;de+=(Ae(W.na+1900)?Ge:ze)[me++]);return j(W.ra+de,3)},"%m":W=>j(W.pa+1,2),"%M":W=>j(W.xa,2),"%n":()=>`
`,"%p":W=>0<=W.oa&&12>W.oa?"AM":"PM","%S":W=>j(W.ya,2),"%t":()=>"	","%u":W=>W.ha||7,"%U":W=>j(Math.floor((W.ma+7-W.ha)/7),2),"%V":W=>{var de=Math.floor((W.ma+7-(W.ha+6)%7)/7);if(2>=(W.ha+371-W.ma-2)%7&&de++,de)de==53&&((me=(W.ha+371-W.ma)%7)==4||me==3&&Ae(W.na)||(de=1));else{de=52;var me=(W.ha+7-W.ma-1)%7;(me==4||me==5&&Ae(W.na%400-1))&&de++}return j(de,2)},"%w":W=>W.ha,"%W":W=>j(Math.floor((W.ma+7-(W.ha+6)%7)/7),2),"%y":W=>(W.na+1900).toString().substring(2),"%Y":W=>W.na+1900,"%z":W=>{var de=0<=(W=W.wa);return W=Math.abs(W)/60,(de?"+":"-")+("0000"+(W/60*100+W%60)).slice(-4)},"%Z":W=>W.za,"%%":()=>"%"},G=G.replace(/%%/g,"\0\0"),ue)G.includes(le)&&(G=G.replace(new RegExp(le,"g"),ue[le](Y)));return le=function(W){var de=Array(Pe(W)+1);return Ce(W,de,0,de.length),de}(G=G.replace(/\0\0/g,"%")),le.length>U?0:(F.set(le,R>>>0),le.length-1)}var Qe={a:function(R,U,G){throw new ye(R>>>=0).sa(U>>>0,G>>>0),R},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(R,U,G){R=U+2097152>>>0<4194305-!!R?(R>>>0)+4294967296*U:NaN,G>>>=0,R=new Date(1e3*R),E[G>>2>>>0]=R.getUTCSeconds(),E[G+4>>2>>>0]=R.getUTCMinutes(),E[G+8>>2>>>0]=R.getUTCHours(),E[G+12>>2>>>0]=R.getUTCDate(),E[G+16>>2>>>0]=R.getUTCMonth(),E[G+20>>2>>>0]=R.getUTCFullYear()-1900,E[G+24>>2>>>0]=R.getUTCDay(),E[G+28>>2>>>0]=(R.getTime()-Date.UTC(R.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},o:function(R,U,G){R=U+2097152>>>0<4194305-!!R?(R>>>0)+4294967296*U:NaN,G>>>=0,R=new Date(1e3*R),E[G>>2>>>0]=R.getSeconds(),E[G+4>>2>>>0]=R.getMinutes(),E[G+8>>2>>>0]=R.getHours(),E[G+12>>2>>>0]=R.getDate(),E[G+16>>2>>>0]=R.getMonth(),E[G+20>>2>>>0]=R.getFullYear()-1900,E[G+24>>2>>>0]=R.getDay(),E[G+28>>2>>>0]=(Ae(R.getFullYear())?$e:Me)[R.getMonth()]+R.getDate()-1|0,E[G+36>>2>>>0]=-60*R.getTimezoneOffset(),U=new Date(R.getFullYear(),6,1).getTimezoneOffset();var Y=new Date(R.getFullYear(),0,1).getTimezoneOffset();E[G+32>>2>>>0]=0|(U!=Y&&R.getTimezoneOffset()==Math.min(Y,U))},p:function(R){R>>>=0;var U=new Date(E[R+20>>2>>>0]+1900,E[R+16>>2>>>0],E[R+12>>2>>>0],E[R+8>>2>>>0],E[R+4>>2>>>0],E[R>>2>>>0],0),G=E[R+32>>2>>>0],Y=U.getTimezoneOffset(),N=new Date(U.getFullYear(),6,1).getTimezoneOffset(),j=new Date(U.getFullYear(),0,1).getTimezoneOffset(),Z=Math.min(j,N);return 0>G?E[R+32>>2>>>0]=+(N!=j&&Z==Y):0<G!=(Z==Y)&&(N=Math.max(j,N),U.setTime(U.getTime()+6e4*((0<G?Z:N)-Y))),E[R+24>>2>>>0]=U.getDay(),E[R+28>>2>>>0]=(Ae(U.getFullYear())?$e:Me)[U.getMonth()]+U.getDate()-1|0,E[R>>2>>>0]=U.getSeconds(),E[R+4>>2>>>0]=U.getMinutes(),E[R+8>>2>>>0]=U.getHours(),E[R+12>>2>>>0]=U.getDate(),E[R+16>>2>>>0]=U.getMonth(),E[R+20>>2>>>0]=U.getYear(),R=U.getTime()/1e3,Ye((ee=R,1<=+Math.abs(ee)?0<ee?+Math.floor(ee/4294967296)>>>0:~~+Math.ceil((ee-+(~~ee>>>0))/4294967296)>>>0:0)),R>>>0},l:function(){return-52},m:function(){},u:function(R,U,G){function Y(ie){return(ie=ie.toTimeString().match(/\(([A-Za-z ]+)\)$/))?ie[1]:"GMT"}G>>>=0;var N=new Date().getFullYear(),j=new Date(N,0,1),Z=new Date(N,6,1);N=j.getTimezoneOffset();var te=Z.getTimezoneOffset();$[R>>>0>>2>>>0]=60*Math.max(N,te),E[U>>>0>>2>>>0]=+(N!=te),R=Y(j),U=Y(Z),R=ke(R),U=ke(U),te<N?($[G>>2>>>0]=R,$[G+4>>2>>>0]=U):($[G>>2>>>0]=U,$[G+4>>2>>>0]=R)},d:()=>{oe("")},h:function(){return Date.now()},v:function(){return 4294901760},b:()=>performance.now(),J:function(R,U,G){return U>>>=0,C.copyWithin(R>>>0>>>0,U>>>0,U+(G>>>0)>>>0)},t:function(R){R>>>=0;var U=C.length;if(4294901760<R)return!1;for(var G=1;4>=G;G*=2){var Y=U*(1+.2/G);Y=Math.min(Y,R+100663296);var N=Math;Y=Math.max(R,Y);e:{N=N.min.call(N,4294901760,Y+(65536-Y%65536)%65536)-P.buffer.byteLength+65535>>>16;try{P.grow(N),A();var j=1;break e}catch{}j=void 0}if(j)return!0}return!1},D:function(R,U){R>>>=0,U>>>=0;var G=0;return Ze().forEach(function(Y,N){var j=U+G;for(N=$[R+4*N>>2>>>0]=j,j=0;j<Y.length;++j)F[N++>>0>>>0]=Y.charCodeAt(j);F[N>>0>>>0]=0,G+=Y.length+1}),0},E:function(R,U){R>>>=0,U>>>=0;var G=Ze();$[R>>2>>>0]=G.length;var Y=0;return G.forEach(function(N){Y+=N.length+1}),$[U>>2>>>0]=Y,0},s:R=>{k||(d.onExit&&d.onExit(R),x=!0),f(R,new xe(R))},f:()=>52,j:function(){return 52},q:function(){return 70},i:function(R,U,G,Y){U>>>=0,G>>>=0,Y>>>=0;for(var N=0,j=0;j<G;j++){var Z=$[U>>2>>>0],te=$[U+4>>2>>>0];U+=8;for(var ie=0;ie<te;ie++){var ue=C[Z+ie>>>0],le=We[R];ue===0||ue===10?((R===1?S:w)(Ie(le,0)),le.length=0):le.push(ue)}N+=te}return $[Y>>2>>>0]=N,0},r:function(R,U){return R>>>=0,je(C.subarray(R>>>0,R+(U>>>0)>>>0)),0},C:qe,c:function(R,U,G,Y){return qe(R>>>0,U>>>0,G>>>0,Y>>>0)}};(function(){function R(G){if(G=G.exports,I=G=function(N){var j=te=>()=>te()>>>0,Z=te=>ie=>te(ie)>>>0;return(N=Object.assign({},N)).__errno_location=j(N.__errno_location),N.malloc=Z(N.malloc),N.stackSave=j(N.stackSave),N.stackAlloc=Z(N.stackAlloc),N}(G),P=I.L,A(),B.unshift(I.M),Q--,d.monitorRunDependencies&&d.monitorRunDependencies(Q),Q==0&&re){var Y=re;re=null,Y()}return G}var U={a:Qe};if(Q++,d.monitorRunDependencies&&d.monitorRunDependencies(Q),d.instantiateWasm)try{return d.instantiateWasm(U,R)}catch(G){w("Module.instantiateWasm callback failed with error: "+G),u(G)}(function(G,Y){var N=X;return y||typeof WebAssembly.instantiateStreaming!="function"||ce(N)||N.startsWith("file://")||_||typeof fetch!="function"?we(N,G,Y):fetch(N,{credentials:"same-origin"}).then(j=>WebAssembly.instantiateStreaming(j,G).then(Y,function(Z){return w("wasm streaming compile failed: "+Z),w("falling back to ArrayBuffer instantiation"),we(N,G,Y)}))})(U,function(G){R(G.instance)}).catch(u)})(),d._OrtInit=(R,U)=>(d._OrtInit=I.N)(R,U),d._OrtGetLastError=(R,U)=>(d._OrtGetLastError=I.O)(R,U),d._OrtCreateSessionOptions=(R,U,G,Y,N,j,Z,te,ie,ue)=>(d._OrtCreateSessionOptions=I.P)(R,U,G,Y,N,j,Z,te,ie,ue),d._OrtAppendExecutionProvider=(R,U)=>(d._OrtAppendExecutionProvider=I.Q)(R,U),d._OrtAddSessionConfigEntry=(R,U,G)=>(d._OrtAddSessionConfigEntry=I.R)(R,U,G),d._OrtReleaseSessionOptions=R=>(d._OrtReleaseSessionOptions=I.S)(R),d._OrtCreateSession=(R,U,G)=>(d._OrtCreateSession=I.T)(R,U,G),d._OrtReleaseSession=R=>(d._OrtReleaseSession=I.U)(R),d._OrtGetInputOutputCount=(R,U,G)=>(d._OrtGetInputOutputCount=I.V)(R,U,G),d._OrtGetInputName=(R,U)=>(d._OrtGetInputName=I.W)(R,U),d._OrtGetOutputName=(R,U)=>(d._OrtGetOutputName=I.X)(R,U),d._OrtFree=R=>(d._OrtFree=I.Y)(R),d._OrtCreateTensor=(R,U,G,Y,N)=>(d._OrtCreateTensor=I.Z)(R,U,G,Y,N),d._OrtGetTensorData=(R,U,G,Y,N)=>(d._OrtGetTensorData=I._)(R,U,G,Y,N),d._OrtReleaseTensor=R=>(d._OrtReleaseTensor=I.$)(R),d._OrtCreateRunOptions=(R,U,G,Y)=>(d._OrtCreateRunOptions=I.aa)(R,U,G,Y),d._OrtAddRunConfigEntry=(R,U,G)=>(d._OrtAddRunConfigEntry=I.ba)(R,U,G),d._OrtReleaseRunOptions=R=>(d._OrtReleaseRunOptions=I.ca)(R),d._OrtRun=(R,U,G,Y,N,j,Z,te)=>(d._OrtRun=I.da)(R,U,G,Y,N,j,Z,te),d._OrtEndProfiling=R=>(d._OrtEndProfiling=I.ea)(R);var Ke=d._malloc=R=>(Ke=d._malloc=I.fa)(R);d._free=R=>(d._free=I.ga)(R);var Ue,Ye=R=>(Ye=I.ia)(R),He=()=>(He=I.ja)(),se=R=>(se=I.ka)(R),Be=R=>(Be=I.la)(R);function Xe(){function R(){if(!Ue&&(Ue=!0,d.calledRun=!0,!x)){if(_e(B),a(d),d.onRuntimeInitialized&&d.onRuntimeInitialized(),d.postRun)for(typeof d.postRun=="function"&&(d.postRun=[d.postRun]);d.postRun.length;){var U=d.postRun.shift();H.unshift(U)}_e(H)}}if(!(0<Q)){if(d.preRun)for(typeof d.preRun=="function"&&(d.preRun=[d.preRun]);d.preRun.length;)J();_e(L),0<Q||(d.setStatus?(d.setStatus("Running..."),setTimeout(function(){setTimeout(function(){d.setStatus("")},1),R()},1)):R())}}if(d.stackAlloc=Be,d.stackSave=He,d.stackRestore=se,d.UTF8ToString=Oe,d.stringToUTF8=(R,U,G)=>Ce(R,C,U,G),d.lengthBytesUTF8=Pe,re=function R(){Ue||Xe(),Ue||(re=R)},d.preInit)for(typeof d.preInit=="function"&&(d.preInit=[d.preInit]);0<d.preInit.length;)d.preInit.pop()();return Xe(),o.ready});s.exports=r},4537:s=>{s.exports=function(e,t){for(var n=new Array(arguments.length-1),r=0,o=2,a=!0;o<arguments.length;)n[r++]=arguments[o++];return new Promise(function(u,d){n[r]=function(h){if(a)if(a=!1,h)d(h);else{for(var p=new Array(arguments.length-1),l=0;l<p.length;)p[l++]=arguments[l];u.apply(null,p)}};try{e.apply(t||null,n)}catch(h){a&&(a=!1,d(h))}})}},7419:(s,e)=>{var t=e;t.length=function(u){var d=u.length;if(!d)return 0;for(var h=0;--d%4>1&&u.charAt(d)==="=";)++h;return Math.ceil(3*u.length)/4-h};for(var n=new Array(64),r=new Array(123),o=0;o<64;)r[n[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;t.encode=function(u,d,h){for(var p,l=null,i=[],c=0,f=0;d<h;){var g=u[d++];switch(f){case 0:i[c++]=n[g>>2],p=(3&g)<<4,f=1;break;case 1:i[c++]=n[p|g>>4],p=(15&g)<<2,f=2;break;case 2:i[c++]=n[p|g>>6],i[c++]=n[63&g],f=0}c>8191&&((l||(l=[])).push(String.fromCharCode.apply(String,i)),c=0)}return f&&(i[c++]=n[p],i[c++]=61,f===1&&(i[c++]=61)),l?(c&&l.push(String.fromCharCode.apply(String,i.slice(0,c))),l.join("")):String.fromCharCode.apply(String,i.slice(0,c))};var a="invalid encoding";t.decode=function(u,d,h){for(var p,l=h,i=0,c=0;c<u.length;){var f=u.charCodeAt(c++);if(f===61&&i>1)break;if((f=r[f])===void 0)throw Error(a);switch(i){case 0:p=f,i=1;break;case 1:d[h++]=p<<2|(48&f)>>4,p=f,i=2;break;case 2:d[h++]=(15&p)<<4|(60&f)>>2,p=f,i=3;break;case 3:d[h++]=(3&p)<<6|f,i=0}}if(i===1)throw Error(a);return h-l},t.test=function(u){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(u)}},9211:s=>{function e(){this._listeners={}}s.exports=e,e.prototype.on=function(t,n,r){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:n,ctx:r||this}),this},e.prototype.off=function(t,n){if(t===void 0)this._listeners={};else if(n===void 0)this._listeners[t]=[];else for(var r=this._listeners[t],o=0;o<r.length;)r[o].fn===n?r.splice(o,1):++o;return this},e.prototype.emit=function(t){var n=this._listeners[t];if(n){for(var r=[],o=1;o<arguments.length;)r.push(arguments[o++]);for(o=0;o<n.length;)n[o].fn.apply(n[o++].ctx,r)}return this}},945:s=>{function e(a){return typeof Float32Array<"u"?function(){var u=new Float32Array([-0]),d=new Uint8Array(u.buffer),h=d[3]===128;function p(f,g,m){u[0]=f,g[m]=d[0],g[m+1]=d[1],g[m+2]=d[2],g[m+3]=d[3]}function l(f,g,m){u[0]=f,g[m]=d[3],g[m+1]=d[2],g[m+2]=d[1],g[m+3]=d[0]}function i(f,g){return d[0]=f[g],d[1]=f[g+1],d[2]=f[g+2],d[3]=f[g+3],u[0]}function c(f,g){return d[3]=f[g],d[2]=f[g+1],d[1]=f[g+2],d[0]=f[g+3],u[0]}a.writeFloatLE=h?p:l,a.writeFloatBE=h?l:p,a.readFloatLE=h?i:c,a.readFloatBE=h?c:i}():function(){function u(h,p,l,i){var c=p<0?1:0;if(c&&(p=-p),p===0)h(1/p>0?0:2147483648,l,i);else if(isNaN(p))h(2143289344,l,i);else if(p>34028234663852886e22)h((c<<31|2139095040)>>>0,l,i);else if(p<11754943508222875e-54)h((c<<31|Math.round(p/1401298464324817e-60))>>>0,l,i);else{var f=Math.floor(Math.log(p)/Math.LN2);h((c<<31|f+127<<23|8388607&Math.round(p*Math.pow(2,-f)*8388608))>>>0,l,i)}}function d(h,p,l){var i=h(p,l),c=2*(i>>31)+1,f=i>>>23&255,g=8388607&i;return f===255?g?NaN:c*(1/0):f===0?1401298464324817e-60*c*g:c*Math.pow(2,f-150)*(g+8388608)}a.writeFloatLE=u.bind(null,t),a.writeFloatBE=u.bind(null,n),a.readFloatLE=d.bind(null,r),a.readFloatBE=d.bind(null,o)}(),typeof Float64Array<"u"?function(){var u=new Float64Array([-0]),d=new Uint8Array(u.buffer),h=d[7]===128;function p(f,g,m){u[0]=f,g[m]=d[0],g[m+1]=d[1],g[m+2]=d[2],g[m+3]=d[3],g[m+4]=d[4],g[m+5]=d[5],g[m+6]=d[6],g[m+7]=d[7]}function l(f,g,m){u[0]=f,g[m]=d[7],g[m+1]=d[6],g[m+2]=d[5],g[m+3]=d[4],g[m+4]=d[3],g[m+5]=d[2],g[m+6]=d[1],g[m+7]=d[0]}function i(f,g){return d[0]=f[g],d[1]=f[g+1],d[2]=f[g+2],d[3]=f[g+3],d[4]=f[g+4],d[5]=f[g+5],d[6]=f[g+6],d[7]=f[g+7],u[0]}function c(f,g){return d[7]=f[g],d[6]=f[g+1],d[5]=f[g+2],d[4]=f[g+3],d[3]=f[g+4],d[2]=f[g+5],d[1]=f[g+6],d[0]=f[g+7],u[0]}a.writeDoubleLE=h?p:l,a.writeDoubleBE=h?l:p,a.readDoubleLE=h?i:c,a.readDoubleBE=h?c:i}():function(){function u(h,p,l,i,c,f){var g=i<0?1:0;if(g&&(i=-i),i===0)h(0,c,f+p),h(1/i>0?0:2147483648,c,f+l);else if(isNaN(i))h(0,c,f+p),h(2146959360,c,f+l);else if(i>17976931348623157e292)h(0,c,f+p),h((g<<31|2146435072)>>>0,c,f+l);else{var m;if(i<22250738585072014e-324)h((m=i/5e-324)>>>0,c,f+p),h((g<<31|m/4294967296)>>>0,c,f+l);else{var _=Math.floor(Math.log(i)/Math.LN2);_===1024&&(_=1023),h(4503599627370496*(m=i*Math.pow(2,-_))>>>0,c,f+p),h((g<<31|_+1023<<20|1048576*m&1048575)>>>0,c,f+l)}}}function d(h,p,l,i,c){var f=h(i,c+p),g=h(i,c+l),m=2*(g>>31)+1,_=g>>>20&2047,b=4294967296*(1048575&g)+f;return _===2047?b?NaN:m*(1/0):_===0?5e-324*m*b:m*Math.pow(2,_-1075)*(b+4503599627370496)}a.writeDoubleLE=u.bind(null,t,0,4),a.writeDoubleBE=u.bind(null,n,4,0),a.readDoubleLE=d.bind(null,r,0,4),a.readDoubleBE=d.bind(null,o,4,0)}(),a}function t(a,u,d){u[d]=255&a,u[d+1]=a>>>8&255,u[d+2]=a>>>16&255,u[d+3]=a>>>24}function n(a,u,d){u[d]=a>>>24,u[d+1]=a>>>16&255,u[d+2]=a>>>8&255,u[d+3]=255&a}function r(a,u){return(a[u]|a[u+1]<<8|a[u+2]<<16|a[u+3]<<24)>>>0}function o(a,u){return(a[u]<<24|a[u+1]<<16|a[u+2]<<8|a[u+3])>>>0}s.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(s){}return null}module.exports=inquire},6662:s=>{s.exports=function(e,t,n){var r=n||8192,o=r>>>1,a=null,u=r;return function(d){if(d<1||d>o)return e(d);u+d>r&&(a=e(r),u=0);var h=t.call(a,u,u+=d);return 7&u&&(u=1+(7|u)),h}}},4997:(s,e)=>{var t=e;t.length=function(n){for(var r=0,o=0,a=0;a<n.length;++a)(o=n.charCodeAt(a))<128?r+=1:o<2048?r+=2:(64512&o)==55296&&(64512&n.charCodeAt(a+1))==56320?(++a,r+=4):r+=3;return r},t.read=function(n,r,o){if(o-r<1)return"";for(var a,u=null,d=[],h=0;r<o;)(a=n[r++])<128?d[h++]=a:a>191&&a<224?d[h++]=(31&a)<<6|63&n[r++]:a>239&&a<365?(a=((7&a)<<18|(63&n[r++])<<12|(63&n[r++])<<6|63&n[r++])-65536,d[h++]=55296+(a>>10),d[h++]=56320+(1023&a)):d[h++]=(15&a)<<12|(63&n[r++])<<6|63&n[r++],h>8191&&((u||(u=[])).push(String.fromCharCode.apply(String,d)),h=0);return u?(h&&u.push(String.fromCharCode.apply(String,d.slice(0,h))),u.join("")):String.fromCharCode.apply(String,d.slice(0,h))},t.write=function(n,r,o){for(var a,u,d=o,h=0;h<n.length;++h)(a=n.charCodeAt(h))<128?r[o++]=a:a<2048?(r[o++]=a>>6|192,r[o++]=63&a|128):(64512&a)==55296&&(64512&(u=n.charCodeAt(h+1)))==56320?(a=65536+((1023&a)<<10)+(1023&u),++h,r[o++]=a>>18|240,r[o++]=a>>12&63|128,r[o++]=a>>6&63|128,r[o++]=63&a|128):(r[o++]=a>>12|224,r[o++]=a>>6&63|128,r[o++]=63&a|128);return o-d}},3442:(s,e)=>{e.__esModule=!0;var t=function(){function n(r){if(!r)throw new TypeError("Invalid argument; `value` has no value.");this.value=n.EMPTY,r&&n.isGuid(r)&&(this.value=r)}return n.isGuid=function(r){var o=r.toString();return r&&(r instanceof n||n.validator.test(o))},n.create=function(){return new n([n.gen(2),n.gen(1),n.gen(1),n.gen(1),n.gen(3)].join("-"))},n.createEmpty=function(){return new n("emptyguid")},n.parse=function(r){return new n(r)},n.raw=function(){return[n.gen(2),n.gen(1),n.gen(1),n.gen(1),n.gen(3)].join("-")},n.gen=function(r){for(var o="",a=0;a<r;a++)o+=(65536*(1+Math.random())|0).toString(16).substring(1);return o},n.prototype.equals=function(r){return n.isGuid(r)&&this.value===r.toString()},n.prototype.isEmpty=function(){return this.value===n.EMPTY},n.prototype.toString=function(){return this.value},n.prototype.toJSON=function(){return{value:this.value}},n.validator=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),n.EMPTY="00000000-0000-0000-0000-000000000000",n}();e.Guid=t},2100:(s,e,t)=>{s.exports=t(9482)},9482:(s,e,t)=>{var n=e;function r(){n.util._configure(),n.Writer._configure(n.BufferWriter),n.Reader._configure(n.BufferReader)}n.build="minimal",n.Writer=t(1173),n.BufferWriter=t(3155),n.Reader=t(1408),n.BufferReader=t(593),n.util=t(9693),n.rpc=t(5994),n.roots=t(5054),n.configure=r,r()},1408:(s,e,t)=>{s.exports=d;var n,r=t(9693),o=r.LongBits,a=r.utf8;function u(g,m){return RangeError("index out of range: "+g.pos+" + "+(m||1)+" > "+g.len)}function d(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 d(g);throw Error("illegal buffer")}:function(g){if(Array.isArray(g))return new d(g);throw Error("illegal buffer")},l=function(){return r.Buffer?function(g){return(d.create=function(m){return r.Buffer.isBuffer(m)?new n(m):p(m)})(g)}:p};function i(){var g=new o(0,0),m=0;if(!(this.len-this.pos>4)){for(;m<3;++m){if(this.pos>=this.len)throw u(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 u(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 c(g,m){return(g[m-4]|g[m-3]<<8|g[m-2]<<16|g[m-1]<<24)>>>0}function f(){if(this.pos+8>this.len)throw u(this,8);return new o(c(this.buf,this.pos+=4),c(this.buf,this.pos+=4))}d.create=l(),d.prototype._slice=r.Array.prototype.subarray||r.Array.prototype.slice,d.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,u(this,10);return h}),d.prototype.int32=function(){return 0|this.uint32()},d.prototype.sint32=function(){var g=this.uint32();return g>>>1^-(1&g)|0},d.prototype.bool=function(){return this.uint32()!==0},d.prototype.fixed32=function(){if(this.pos+4>this.len)throw u(this,4);return c(this.buf,this.pos+=4)},d.prototype.sfixed32=function(){if(this.pos+4>this.len)throw u(this,4);return 0|c(this.buf,this.pos+=4)},d.prototype.float=function(){if(this.pos+4>this.len)throw u(this,4);var g=r.float.readFloatLE(this.buf,this.pos);return this.pos+=4,g},d.prototype.double=function(){if(this.pos+8>this.len)throw u(this,4);var g=r.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,g},d.prototype.bytes=function(){var g=this.uint32(),m=this.pos,_=this.pos+g;if(_>this.len)throw u(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,_)},d.prototype.string=function(){var g=this.bytes();return a.read(g,0,g.length)},d.prototype.skip=function(g){if(typeof g=="number"){if(this.pos+g>this.len)throw u(this,g);this.pos+=g}else do if(this.pos>=this.len)throw u(this);while(128&this.buf[this.pos++]);return this},d.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},d._configure=function(g){n=g,d.create=l(),n._configure();var m=r.Long?"toLong":"toNumber";r.merge(d.prototype,{int64:function(){return i.call(this)[m](!1)},uint64:function(){return i.call(this)[m](!0)},sint64:function(){return i.call(this).zzDecode()[m](!1)},fixed64:function(){return f.call(this)[m](!0)},sfixed64:function(){return f.call(this)[m](!1)}})}},593:(s,e,t)=>{s.exports=o;var n=t(1408);(o.prototype=Object.create(n.prototype)).constructor=o;var r=t(9693);function o(a){n.call(this,a)}o._configure=function(){r.Buffer&&(o.prototype._slice=r.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:s=>{s.exports={}},5994:(s,e,t)=>{e.Service=t(7948)},7948:(s,e,t)=>{s.exports=r;var n=t(9693);function r(o,a,u){if(typeof o!="function")throw TypeError("rpcImpl must be a function");n.EventEmitter.call(this),this.rpcImpl=o,this.requestDelimited=!!a,this.responseDelimited=!!u}(r.prototype=Object.create(n.EventEmitter.prototype)).constructor=r,r.prototype.rpcCall=function o(a,u,d,h,p){if(!h)throw TypeError("request must be specified");var l=this;if(!p)return n.asPromise(o,l,a,u,d,h);if(l.rpcImpl)try{return l.rpcImpl(a,u[l.requestDelimited?"encodeDelimited":"encode"](h).finish(),function(i,c){if(i)return l.emit("error",i,a),p(i);if(c!==null){if(!(c instanceof d))try{c=d[l.responseDelimited?"decodeDelimited":"decode"](c)}catch(f){return l.emit("error",f,a),p(f)}return l.emit("data",c,a),p(null,c)}l.end(!0)})}catch(i){return l.emit("error",i,a),void setTimeout(function(){p(i)},0)}else setTimeout(function(){p(Error("already ended"))},0)},r.prototype.end=function(o){return this.rpcImpl&&(o||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},1945:(s,e,t)=>{s.exports=r;var n=t(9693);function r(d,h){this.lo=d>>>0,this.hi=h>>>0}var o=r.zero=new r(0,0);o.toNumber=function(){return 0},o.zzEncode=o.zzDecode=function(){return this},o.length=function(){return 1};var a=r.zeroHash="\0\0\0\0\0\0\0\0";r.fromNumber=function(d){if(d===0)return o;var h=d<0;h&&(d=-d);var p=d>>>0,l=(d-p)/4294967296>>>0;return h&&(l=~l>>>0,p=~p>>>0,++p>4294967295&&(p=0,++l>4294967295&&(l=0))),new r(p,l)},r.from=function(d){if(typeof d=="number")return r.fromNumber(d);if(n.isString(d)){if(!n.Long)return r.fromNumber(parseInt(d,10));d=n.Long.fromString(d)}return d.low||d.high?new r(d.low>>>0,d.high>>>0):o},r.prototype.toNumber=function(d){if(!d&&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},r.prototype.toLong=function(d){return n.Long?new n.Long(0|this.lo,0|this.hi,!!d):{low:0|this.lo,high:0|this.hi,unsigned:!!d}};var u=String.prototype.charCodeAt;r.fromHash=function(d){return d===a?o:new r((u.call(d,0)|u.call(d,1)<<8|u.call(d,2)<<16|u.call(d,3)<<24)>>>0,(u.call(d,4)|u.call(d,5)<<8|u.call(d,6)<<16|u.call(d,7)<<24)>>>0)},r.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)},r.prototype.zzEncode=function(){var d=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^d)>>>0,this.lo=(this.lo<<1^d)>>>0,this},r.prototype.zzDecode=function(){var d=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^d)>>>0,this.hi=(this.hi>>>1^d)>>>0,this},r.prototype.length=function(){var d=this.lo,h=(this.lo>>>28|this.hi<<4)>>>0,p=this.hi>>>24;return p===0?h===0?d<16384?d<128?1:2:d<2097152?3:4:h<16384?h<128?5:6:h<2097152?7:8:p<128?9:10}},9693:function(s,e,t){var n=e;function r(a,u,d){for(var h=Object.keys(u),p=0;p<h.length;++p)a[h[p]]!==void 0&&d||(a[h[p]]=u[h[p]]);return a}function o(a){function u(d,h){if(!(this instanceof u))return new u(d,h);Object.defineProperty(this,"message",{get:function(){return d}}),Error.captureStackTrace?Error.captureStackTrace(this,u):Object.defineProperty(this,"stack",{value:new Error().stack||""}),h&&r(this,h)}return u.prototype=Object.create(Error.prototype,{constructor:{value:u,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}}),u}n.asPromise=t(4537),n.base64=t(7419),n.EventEmitter=t(9211),n.float=t(945),n.inquire=t(7199),n.utf8=t(4997),n.pool=t(6662),n.LongBits=t(1945),n.isNode=!!(typeof commonjsGlobal<"u"&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),n.global=n.isNode&&commonjsGlobal||typeof window<"u"&&window||typeof self<"u"&&self||this,n.emptyArray=Object.freeze?Object.freeze([]):[],n.emptyObject=Object.freeze?Object.freeze({}):{},n.isInteger=Number.isInteger||function(a){return typeof a=="number"&&isFinite(a)&&Math.floor(a)===a},n.isString=function(a){return typeof a=="string"||a instanceof String},n.isObject=function(a){return a&&typeof a=="object"},n.isset=n.isSet=function(a,u){var d=a[u];return!(d==null||!a.hasOwnProperty(u))&&(typeof d!="object"||(Array.isArray(d)?d.length:Object.keys(d).length)>0)},n.Buffer=function(){try{var a=n.inquire("buffer").Buffer;return a.prototype.utf8Write?a:null}catch{return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(a){return typeof a=="number"?n.Buffer?n._Buffer_allocUnsafe(a):new n.Array(a):n.Buffer?n._Buffer_from(a):typeof Uint8Array>"u"?a:new Uint8Array(a)},n.Array=typeof Uint8Array<"u"?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(a){return a?n.LongBits.from(a).toHash():n.LongBits.zeroHash},n.longFromHash=function(a,u){var d=n.LongBits.fromHash(a);return n.Long?n.Long.fromBits(d.lo,d.hi,u):d.toNumber(!!u)},n.merge=r,n.lcFirst=function(a){return a.charAt(0).toLowerCase()+a.substring(1)},n.newError=o,n.ProtocolError=o("ProtocolError"),n.oneOfGetter=function(a){for(var u={},d=0;d<a.length;++d)u[a[d]]=1;return function(){for(var h=Object.keys(this),p=h.length-1;p>-1;--p)if(u[h[p]]===1&&this[h[p]]!==void 0&&this[h[p]]!==null)return h[p]}},n.oneOfSetter=function(a){return function(u){for(var d=0;d<a.length;++d)a[d]!==u&&delete this[a[d]]}},n.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},n._configure=function(){var a=n.Buffer;a?(n._Buffer_from=a.from!==Uint8Array.from&&a.from||function(u,d){return new a(u,d)},n._Buffer_allocUnsafe=a.allocUnsafe||function(u){return new a(u)}):n._Buffer_from=n._Buffer_allocUnsafe=null}},1173:(s,e,t)=>{s.exports=l;var n,r=t(9693),o=r.LongBits,a=r.base64,u=r.utf8;function d(b,v,T){this.fn=b,this.len=v,this.next=void 0,this.val=T}function h(){}function p(b){this.head=b.head,this.tail=b.tail,this.len=b.len,this.next=b.states}function l(){this.len=0,this.head=new d(h,0,0),this.tail=this.head,this.states=null}var i=function(){return r.Buffer?function(){return(l.create=function(){return new n})()}:function(){return new l}};function c(b,v,T){v[T]=255&b}function f(b,v){this.len=b,this.next=void 0,this.val=v}function g(b,v,T){for(;b.hi;)v[T++]=127&b.lo|128,b.lo=(b.lo>>>7|b.hi<<25)>>>0,b.hi>>>=7;for(;b.lo>127;)v[T++]=127&b.lo|128,b.lo=b.lo>>>7;v[T++]=b.lo}function m(b,v,T){v[T]=255&b,v[T+1]=b>>>8&255,v[T+2]=b>>>16&255,v[T+3]=b>>>24}l.create=i(),l.alloc=function(b){return new r.Array(b)},r.Array!==Array&&(l.alloc=r.pool(l.alloc,r.Array.prototype.subarray)),l.prototype._push=function(b,v,T){return this.tail=this.tail.next=new d(b,v,T),this.len+=v,this},f.prototype=Object.create(d.prototype),f.prototype.fn=function(b,v,T){for(;b>127;)v[T++]=127&b|128,b>>>=7;v[T]=b},l.prototype.uint32=function(b){return this.len+=(this.tail=this.tail.next=new f((b>>>=0)<128?1:b<16384?2:b<2097152?3:b<268435456?4:5,b)).len,this},l.prototype.int32=function(b){return b<0?this._push(g,10,o.fromNumber(b)):this.uint32(b)},l.prototype.sint32=function(b){return this.uint32((b<<1^b>>31)>>>0)},l.prototype.uint64=function(b){var v=o.from(b);return this._push(g,v.length(),v)},l.prototype.int64=l.prototype.uint64,l.prototype.sint64=function(b){var v=o.from(b).zzEncode();return this._push(g,v.length(),v)},l.prototype.bool=function(b){return this._push(c,1,b?1:0)},l.prototype.fixed32=function(b){return this._push(m,4,b>>>0)},l.prototype.sfixed32=l.prototype.fixed32,l.prototype.fixed64=function(b){var v=o.from(b);return this._push(m,4,v.lo)._push(m,4,v.hi)},l.prototype.sfixed64=l.prototype.fixed64,l.prototype.float=function(b){return this._push(r.float.writeFloatLE,4,b)},l.prototype.double=function(b){return this._push(r.float.writeDoubleLE,8,b)};var _=r.Array.prototype.set?function(b,v,T){v.set(b,T)}:function(b,v,T){for(var y=0;y<b.length;++y)v[T+y]=b[y]};l.prototype.bytes=function(b){var v=b.length>>>0;if(!v)return this._push(c,1,0);if(r.isString(b)){var T=l.alloc(v=a.length(b));a.decode(b,T,0),b=T}return this.uint32(v)._push(_,v,b)},l.prototype.string=function(b){var v=u.length(b);return v?this.uint32(v)._push(u.write,v,b):this._push(c,1,0)},l.prototype.fork=function(){return this.states=new p(this),this.head=this.tail=new d(h,0,0),this.len=0,this},l.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 d(h,0,0),this.len=0),this},l.prototype.ldelim=function(){var b=this.head,v=this.tail,T=this.len;return this.reset().uint32(T),T&&(this.tail.next=b.next,this.tail=v,this.len+=T),this},l.prototype.finish=function(){for(var b=this.head.next,v=this.constructor.alloc(this.len),T=0;b;)b.fn(b.val,v,T),T+=b.len,b=b.next;return v},l._configure=function(b){n=b,l.create=i(),n._configure()}},3155:(s,e,t)=>{s.exports=o;var n=t(1173);(o.prototype=Object.create(n.prototype)).constructor=o;var r=t(9693);function o(){n.call(this)}function a(u,d,h){u.length<40?r.utf8.write(u,d,h):d.utf8Write?d.utf8Write(u,h):d.write(u,h)}o._configure=function(){o.alloc=r._Buffer_allocUnsafe,o.writeBytesBuffer=r.Buffer&&r.Buffer.prototype instanceof Uint8Array&&r.Buffer.prototype.set.name==="set"?function(u,d,h){d.set(u,h)}:function(u,d,h){if(u.copy)u.copy(d,h,0,u.length);else for(var p=0;p<u.length;)d[h++]=u[p++]}},o.prototype.bytes=function(u){r.isString(u)&&(u=r._Buffer_from(u,"base64"));var d=u.length>>>0;return this.uint32(d),d&&this._push(o.writeBytesBuffer,d,u),this},o.prototype.string=function(u){var d=r.Buffer.byteLength(u);return this.uint32(d),d&&this._push(a,d,u),this},o._configure()},4154:s=>{s.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:(s,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveBackend=e.registerBackend=void 0;const t={},n=[];e.registerBackend=(r,o,a)=>{if(!o||typeof o.init!="function"||typeof o.createSessionHandler!="function")throw new TypeError("not a valid backend");{const u=t[r];if(u===void 0)t[r]={backend:o,priority:a};else{if(u.priority>a)return;if(u.priority===a&&u.backend!==o)throw new Error(`cannot register backend "${r}" using priority ${a}`)}if(a>=0){const d=n.indexOf(r);d!==-1&&n.splice(d,1);for(let h=0;h<n.length;h++)if(t[n[h]].priority<=a)return void n.splice(h,0,r);n.push(r)}}},e.resolveBackend=async r=>{const o=r.length===0?n:r,a=[];for(const u of o){const d=t[u];if(d){if(d.initialized)return d.backend;if(d.aborted)continue;const h=!!d.initPromise;try{return h||(d.initPromise=d.backend.init()),await d.initPromise,d.initialized=!0,d.backend}catch(p){h||a.push({name:u,err:p}),d.aborted=!0}finally{delete d.initPromise}}}throw new Error(`no available backend found. ERR: ${a.map(u=>`[${u.name}] ${u.err}`).join(", ")}`)}},4798:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.registerBackend=void 0;var n=t(685);Object.defineProperty(e,"registerBackend",{enumerable:!0,get:function(){return n.registerBackend}})},3121:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.env=void 0;const n=t(9104);let r="warning";e.env={wasm:{},webgl:{},webgpu:{},versions:{common:n.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}`);r=o}},get logLevel(){return r}},Object.defineProperty(e.env,"logLevel",{enumerable:!0})},2457:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.env=void 0;const n=t(3121);e.env=n.env},2235:function(s,e,t){var n=this&&this.__createBinding||(Object.create?function(o,a,u,d){d===void 0&&(d=u);var h=Object.getOwnPropertyDescriptor(a,u);h&&!("get"in h?!a.__esModule:h.writable||h.configurable)||(h={enumerable:!0,get:function(){return a[u]}}),Object.defineProperty(o,d,h)}:function(o,a,u,d){d===void 0&&(d=u),o[d]=a[u]}),r=this&&this.__exportStar||function(o,a){for(var u in o)u==="default"||Object.prototype.hasOwnProperty.call(a,u)||n(a,o,u)};Object.defineProperty(e,"__esModule",{value:!0}),r(t(4798),e),r(t(2457),e),r(t(3974),e),r(t(963),e),r(t(7852),e)},8036:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.InferenceSession=void 0;const n=t(685),r=t(963);class o{constructor(u){this.handler=u}async run(u,d,h){const p={};let l={};if(typeof u!="object"||u===null||u instanceof r.Tensor||Array.isArray(u))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let i=!0;if(typeof d=="object"){if(d===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(d instanceof r.Tensor)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(d)){if(d.length===0)throw new TypeError("'fetches' cannot be an empty array.");i=!1;for(const g of d){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)l=h;else if(h!==void 0)throw new TypeError("'options' must be an object.")}else{let g=!1;const m=Object.getOwnPropertyNames(d);for(const _ of this.outputNames)if(m.indexOf(_)!==-1){const b=d[_];(b===null||b instanceof r.Tensor)&&(g=!0,i=!1,p[_]=b)}if(g){if(typeof h=="object"&&h!==null)l=h;else if(h!==void 0)throw new TypeError("'options' must be an object.")}else l=d}}else if(d!==void 0)throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(const g of this.inputNames)if(u[g]===void 0)throw new Error(`input '${g}' is missing in 'feeds'.`);if(i)for(const g of this.outputNames)p[g]=null;const c=await this.handler.run(u,p,l),f={};for(const g in c)Object.hasOwnProperty.call(c,g)&&(f[g]=new r.Tensor(c[g].type,c[g].data,c[g].dims));return f}async release(){return this.handler.dispose()}static async create(u,d,h,p){let l,i={};if(typeof u=="string"){if(l=u,typeof d=="object"&&d!==null)i=d;else if(d!==void 0)throw new TypeError("'options' must be an object.")}else if(u instanceof Uint8Array){if(l=u,typeof d=="object"&&d!==null)i=d;else if(d!==void 0)throw new TypeError("'options' must be an object.")}else{if(!(u instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&u instanceof SharedArrayBuffer))throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");{const m=u;let _=0,b=u.byteLength;if(typeof d=="object"&&d!==null)i=d;else if(typeof d=="number"){if(_=d,!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=u.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)i=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(d!==void 0)throw new TypeError("'options' must be an object.");l=new Uint8Array(m,_,b)}}const c=(i.executionProviders||[]).map(m=>typeof m=="string"?m:m.name),f=await(0,n.resolveBackend)(c),g=await f.createSessionHandler(l,i);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:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.InferenceSession=void 0;const n=t(8036);e.InferenceSession=n.InferenceSession},7852:(s,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},2350:(s,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tensorToImageData=e.tensorToDataURL=void 0,e.tensorToDataURL=(t,n)=>{const r=document.createElement("canvas");r.width=t.dims[3],r.height=t.dims[2];const o=r.getContext("2d");if(o!=null){let a,u;(n==null?void 0:n.tensorLayout)!==void 0&&n.tensorLayout==="NHWC"?(a=t.dims[2],u=t.dims[3]):(a=t.dims[3],u=t.dims[2]);const d=(n==null?void 0:n.format)!==void 0?n.format:"RGB",h=n==null?void 0:n.norm;let p,l;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?l=[0,0,0,0]:typeof h.bias=="number"?l=[h.bias,h.bias,h.bias,h.bias]:(l=[h.bias[0],h.bias[1],h.bias[2],0],h.bias[3]!==void 0&&(l[3]=h.bias[3]));const i=u*a;let c=0,f=i,g=2*i,m=-1;d==="RGBA"?(c=0,f=i,g=2*i,m=3*i):d==="RGB"?(c=0,f=i,g=2*i):d==="RBG"&&(c=0,g=i,f=2*i);for(let _=0;_<u;_++)for(let b=0;b<a;b++){const v=(t.data[c++]-l[0])*p[0],T=(t.data[f++]-l[1])*p[1],y=(t.data[g++]-l[2])*p[2],S=m===-1?255:(t.data[m++]-l[3])*p[3];o.fillStyle="rgba("+v+","+T+","+y+","+S+")",o.fillRect(b,_,1,1)}return r.toDataURL()}throw new Error("Can not access image data")},e.tensorToImageData=(t,n)=>{const r=document.createElement("canvas").getContext("2d");let o;if(r==null)throw new Error("Can not access image data");{let a,u,d;(n==null?void 0:n.tensorLayout)!==void 0&&n.tensorLayout==="NHWC"?(a=t.dims[2],u=t.dims[1],d=t.dims[3]):(a=t.dims[3],u=t.dims[2],d=t.dims[1]);const h=n!==void 0&&n.format!==void 0?n.format:"RGB",p=n==null?void 0:n.norm;let l,i;p===void 0||p.mean===void 0?l=[255,255,255,255]:typeof p.mean=="number"?l=[p.mean,p.mean,p.mean,p.mean]:(l=[p.mean[0],p.mean[1],p.mean[2],255],p.mean[3]!==void 0&&(l[3]=p.mean[3])),p===void 0||p.bias===void 0?i=[0,0,0,0]:typeof p.bias=="number"?i=[p.bias,p.bias,p.bias,p.bias]:(i=[p.bias[0],p.bias[1],p.bias[2],0],p.bias[3]!==void 0&&(i[3]=p.bias[3]));const c=u*a;if(n!==void 0&&(n.format!==void 0&&d===4&&n.format!=="RGBA"||d===3&&n.format!=="RGB"&&n.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");const f=4;let g=0,m=1,_=2,b=3,v=0,T=c,y=2*c,S=-1;h==="RGBA"?(v=0,T=c,y=2*c,S=3*c):h==="RGB"?(v=0,T=c,y=2*c):h==="RBG"&&(v=0,y=c,T=2*c),o=r.createImageData(a,u);for(let w=0;w<u*a;g+=f,m+=f,_+=f,b+=f,w++)o.data[g]=(t.data[v++]-i[0])*l[0],o.data[m]=(t.data[T++]-i[1])*l[1],o.data[_]=(t.data[y++]-i[2])*l[2],o.data[b]=S===-1?255:(t.data[S++]-i[3])*l[3]}return o}},4866:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tensorFromImage=e.bufferToTensor=void 0;const n=t(963);e.bufferToTensor=(r,o)=>{if(r===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:u}=o,d=o.norm??{mean:255,bias:0};let h,p;h=typeof d.mean=="number"?[d.mean,d.mean,d.mean,d.mean]:[d.mean[0],d.mean[1],d.mean[2],d.mean[3]??255],p=typeof d.bias=="number"?[d.bias,d.bias,d.bias,d.bias]:[d.bias[0],d.bias[1],d.bias[2],d.bias[3]??0];const l=o.format!==void 0?o.format:"RGBA",i=o.tensorFormat!==void 0&&o.tensorFormat!==void 0?o.tensorFormat:"RGB",c=a*u,f=i==="RGBA"?new Float32Array(4*c):new Float32Array(3*c);let g=4,m=0,_=1,b=2,v=3,T=0,y=c,S=2*c,w=-1;l==="RGB"&&(g=3,m=0,_=1,b=2,v=-1),i==="RGBA"?w=3*c:i==="RBG"?(T=0,S=c,y=2*c):i==="BGR"&&(S=0,y=c,T=2*c);for(let k=0;k<c;k++,m+=g,b+=g,_+=g,v+=g)f[T++]=(r[m]+p[0])/h[0],f[y++]=(r[_]+p[1])/h[1],f[S++]=(r[b]+p[2])/h[2],w!==-1&&v!==-1&&(f[w++]=(r[v]+p[3])/h[3]);return i==="RGBA"?new n.Tensor("float32",f,[1,4,a,u]):new n.Tensor("float32",f,[1,3,a,u])},e.tensorFromImage=async(r,o)=>{const a=typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement,u=typeof ImageData<"u"&&r instanceof ImageData,d=typeof ImageBitmap<"u"&&r instanceof ImageBitmap,h=typeof r=="string";let p,l=o??{};if(a){const i=document.createElement("canvas");i.width=r.width,i.height=r.height;const c=i.getContext("2d");if(c==null)throw new Error("Can not access image data");{let f=r.height,g=r.width;if(o!==void 0&&o.resizedHeight!==void 0&&o.resizedWidth!==void 0&&(f=o.resizedHeight,g=o.resizedWidth),o!==void 0){if(l=o,o.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");l.tensorFormat="RGBA",l.height=f,l.width=g}else l.tensorFormat="RGBA",l.height=f,l.width=g;c.drawImage(r,0,0),p=c.getImageData(0,0,g,f).data}}else{if(!u){if(d){if(o===void 0)throw new Error("Please provide image config with format for Imagebitmap");const i=document.createElement("canvas");i.width=r.width,i.height=r.height;const c=i.getContext("2d");if(c!=null){const f=r.height,g=r.width;return c.drawImage(r,0,0,g,f),p=c.getImageData(0,0,g,f).data,l.height=f,l.width=g,(0,e.bufferToTensor)(p,l)}throw new Error("Can not access image data")}if(h)return new Promise((i,c)=>{const f=document.createElement("canvas"),g=f.getContext("2d");if(!r||!g)return c();const m=new Image;m.crossOrigin="Anonymous",m.src=r,m.onload=()=>{f.width=m.width,f.height=m.height,g.drawImage(m,0,0,f.width,f.height);const _=g.getImageData(0,0,f.width,f.height);l.height=f.height,l.width=f.width,i((0,e.bufferToTensor)(_.data,l))}});throw new Error("Input data provided is not supported - aborted tensor creation")}{let i,c;if(o!==void 0&&o.resizedWidth!==void 0&&o.resizedHeight!==void 0?(i=o.resizedHeight,c=o.resizedWidth):(i=r.height,c=r.width),o!==void 0&&(l=o),l.format="RGBA",l.height=i,l.width=c,o!==void 0){const f=document.createElement("canvas");f.width=c,f.height=i;const g=f.getContext("2d");if(g==null)throw new Error("Can not access image data");g.putImageData(r,0,0),p=g.getImageData(0,0,c,i).data}else p=r.data}}if(p!==void 0)return(0,e.bufferToTensor)(p,l);throw new Error("Input data provided is not supported - aborted tensor creation")}},5957:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Tensor=void 0;const n=t(2350),r=t(4866),o=t(106),a=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["float16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),u=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]);let d=!1;e.Tensor=class{constructor(h,p,l){let i,c,f;if((()=>{if(!d){d=!0;const m=typeof BigInt64Array<"u"&&typeof BigInt64Array.from=="function",_=typeof BigUint64Array<"u"&&typeof BigUint64Array.from=="function";m&&(a.set("int64",BigInt64Array),u.set(BigInt64Array,"int64")),_&&(a.set("uint64",BigUint64Array),u.set(BigUint64Array,"uint64"))}})(),typeof h=="string")if(i=h,f=l,h==="string"){if(!Array.isArray(p))throw new TypeError("A string tensor's data must be a string array.");c=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.");c=h==="uint64"||h==="int64"?m.from(p,BigInt):m.from(p)}else{if(!(p instanceof m))throw new TypeError(`A ${i} tensor's data must be type of ${m}`);c=p}}else if(f=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")i="string",c=h;else{if(m!=="boolean")throw new TypeError(`Invalid element type of data array: ${m}.`);i="bool",c=Uint8Array.from(h)}}else{const m=u.get(h.constructor);if(m===void 0)throw new TypeError(`Unsupported type for tensor data: ${h.constructor}.`);i=m,c=h}if(f===void 0)f=[c.length];else if(!Array.isArray(f))throw new TypeError("A tensor's dims must be a number array");const g=(0,o.calculateSize)(f);if(g!==c.length)throw new Error(`Tensor's size(${g}) does not match data length(${c.length}).`);this.dims=f,this.type=i,this.data=c,this.size=g}static async fromImage(h,p){return(0,r.tensorFromImage)(h,p)}toDataURL(h){return(0,n.tensorToDataURL)(this,h)}toImageData(h){return(0,n.tensorToImageData)(this,h)}reshape(h){return(0,o.tensorReshape)(this,h)}}},106:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tensorReshape=e.calculateSize=void 0;const n=t(963);e.calculateSize=r=>{let o=1;for(let a=0;a<r.length;a++){const u=r[a];if(typeof u!="number"||!Number.isSafeInteger(u))throw new TypeError(`dims[${a}] must be an integer, got: ${u}`);if(u<0)throw new RangeError(`dims[${a}] must be a non-negative integer, got: ${u}`);o*=u}return o},e.tensorReshape=(r,o)=>new n.Tensor(r.type,r.data,o)},963:(s,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Tensor=void 0;const n=t(5957);e.Tensor=n.Tensor},9104:(s,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.version=void 0,e.version="1.16.3"},1583:(s,e)=>{var t,n=function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.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(x,A,L){this.low=0|x,this.high=0|A,this.unsigned=!!L}function u(x){return(x&&x.__isLong__)===!0}function d(x){var A=Math.clz32(x&-x);return x?31-A:A}a.prototype.__isLong__,Object.defineProperty(a.prototype,"__isLong__",{value:!0}),a.isLong=u;var h={},p={};function l(x,A){var L,B,H;return A?(H=0<=(x>>>=0)&&x<256)&&(B=p[x])?B:(L=c(x,0,!0),H&&(p[x]=L),L):(H=-128<=(x|=0)&&x<128)&&(B=h[x])?B:(L=c(x,x<0?-1:0,!1),H&&(h[x]=L),L)}function i(x,A){if(isNaN(x))return A?S:y;if(A){if(x<0)return S;if(x>=b)return F}else{if(x<=-v)return C;if(x+1>=v)return I}return x<0?i(-x,A).neg():c(x%_|0,x/_|0,A)}function c(x,A,L){return new a(x,A,L)}a.fromInt=l,a.fromNumber=i,a.fromBits=c;var f=Math.pow;function g(x,A,L){if(x.length===0)throw Error("empty string");if(typeof A=="number"?(L=A,A=!1):A=!!A,x==="NaN"||x==="Infinity"||x==="+Infinity"||x==="-Infinity")return A?S:y;if((L=L||10)<2||36<L)throw RangeError("radix");var B;if((B=x.indexOf("-"))>0)throw Error("interior hyphen");if(B===0)return g(x.substring(1),A,L).neg();for(var H=i(f(L,8)),J=y,X=0;X<x.length;X+=8){var ee=Math.min(8,x.length-X),Q=parseInt(x.substring(X,X+ee),L);if(ee<8){var re=i(f(L,ee));J=J.mul(re).add(i(Q))}else J=(J=J.mul(H)).add(i(Q))}return J.unsigned=A,J}function m(x,A){return typeof x=="number"?i(x,A):typeof x=="string"?g(x,A):c(x.low,x.high,typeof A=="boolean"?A:x.unsigned)}a.fromString=g,a.fromValue=m;var _=4294967296,b=_*_,v=b/2,T=l(1<<24),y=l(0);a.ZERO=y;var S=l(0,!0);a.UZERO=S;var w=l(1);a.ONE=w;var k=l(1,!0);a.UONE=k;var P=l(-1);a.NEG_ONE=P;var I=c(-1,2147483647,!1);a.MAX_VALUE=I;var F=c(-1,-1,!0);a.MAX_UNSIGNED_VALUE=F;var C=c(0,-2147483648,!1);a.MIN_VALUE=C;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(x){if((x=x||10)<2||36<x)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(C)){var A=i(x),L=this.div(A),B=L.mul(A).sub(this);return L.toString(x)+B.toInt().toString(x)}return"-"+this.neg().toString(x)}for(var H=i(f(x,6),this.unsigned),J=this,X="";;){var ee=J.div(H),Q=(J.sub(ee.mul(H)).toInt()>>>0).toString(x);if((J=ee).isZero())return Q+X;for(;Q.length<6;)Q="0"+Q;X=""+Q+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(C)?64:this.neg().getNumBitsAbs();for(var x=this.high!=0?this.high:this.low,A=31;A>0&&!(x&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(x){return u(x)||(x=m(x)),(this.unsigned===x.unsigned||this.high>>>31!=1||x.high>>>31!=1)&&this.high===x.high&&this.low===x.low},E.eq=E.equals,E.notEquals=function(x){return!this.eq(x)},E.neq=E.notEquals,E.ne=E.notEquals,E.lessThan=function(x){return this.comp(x)<0},E.lt=E.lessThan,E.lessThanOrEqual=function(x){return this.comp(x)<=0},E.lte=E.lessThanOrEqual,E.le=E.lessThanOrEqual,E.greaterThan=function(x){return this.comp(x)>0},E.gt=E.greaterThan,E.greaterThanOrEqual=function(x){return this.comp(x)>=0},E.gte=E.greaterThanOrEqual,E.ge=E.greaterThanOrEqual,E.compare=function(x){if(u(x)||(x=m(x)),this.eq(x))return 0;var A=this.isNegative(),L=x.isNegative();return A&&!L?-1:!A&&L?1:this.unsigned?x.high>>>0>this.high>>>0||x.high===this.high&&x.low>>>0>this.low>>>0?-1:1:this.sub(x).isNegative()?-1:1},E.comp=E.compare,E.negate=function(){return!this.unsigned&&this.eq(C)?C:this.not().add(w)},E.neg=E.negate,E.add=function(x){u(x)||(x=m(x));var A=this.high>>>16,L=65535&this.high,B=this.low>>>16,H=65535&this.low,J=x.high>>>16,X=65535&x.high,ee=x.low>>>16,Q=0,re=0,oe=0,ce=0;return oe+=(ce+=H+(65535&x.low))>>>16,re+=(oe+=B+ee)>>>16,Q+=(re+=L+X)>>>16,Q+=A+J,c((oe&=65535)<<16|(ce&=65535),(Q&=65535)<<16|(re&=65535),this.unsigned)},E.subtract=function(x){return u(x)||(x=m(x)),this.add(x.neg())},E.sub=E.subtract,E.multiply=function(x){if(this.isZero())return this;if(u(x)||(x=m(x)),o)return c(o.mul(this.low,this.high,x.low,x.high),o.get_high(),this.unsigned);if(x.isZero())return this.unsigned?S:y;if(this.eq(C))return x.isOdd()?C:y;if(x.eq(C))return this.isOdd()?C:y;if(this.isNegative())return x.isNegative()?this.neg().mul(x.neg()):this.neg().mul(x).neg();if(x.isNegative())return this.mul(x.neg()).neg();if(this.lt(T)&&x.lt(T))return i(this.toNumber()*x.toNumber(),this.unsigned);var A=this.high>>>16,L=65535&this.high,B=this.low>>>16,H=65535&this.low,J=x.high>>>16,X=65535&x.high,ee=x.low>>>16,Q=65535&x.low,re=0,oe=0,ce=0,fe=0;return ce+=(fe+=H*Q)>>>16,oe+=(ce+=B*Q)>>>16,ce&=65535,oe+=(ce+=H*ee)>>>16,re+=(oe+=L*Q)>>>16,oe&=65535,re+=(oe+=B*ee)>>>16,oe&=65535,re+=(oe+=H*X)>>>16,re+=A*Q+L*ee+B*X+H*J,c((ce&=65535)<<16|(fe&=65535),(re&=65535)<<16|(oe&=65535),this.unsigned)},E.mul=E.multiply,E.divide=function(x){if(u(x)||(x=m(x)),x.isZero())throw Error("division by zero");var A,L,B;if(o)return this.unsigned||this.high!==-2147483648||x.low!==-1||x.high!==-1?c((this.unsigned?o.div_u:o.div_s)(this.low,this.high,x.low,x.high),o.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?S:y;if(this.unsigned){if(x.unsigned||(x=x.toUnsigned()),x.gt(this))return S;if(x.gt(this.shru(1)))return k;B=S}else{if(this.eq(C))return x.eq(w)||x.eq(P)?C:x.eq(C)?w:(A=this.shr(1).div(x).shl(1)).eq(y)?x.isNegative()?w:P:(L=this.sub(x.mul(A)),B=A.add(L.div(x)));if(x.eq(C))return this.unsigned?S:y;if(this.isNegative())return x.isNegative()?this.neg().div(x.neg()):this.neg().div(x).neg();if(x.isNegative())return this.div(x.neg()).neg();B=y}for(L=this;L.gte(x);){A=Math.max(1,Math.floor(L.toNumber()/x.toNumber()));for(var H=Math.ceil(Math.log(A)/Math.LN2),J=H<=48?1:f(2,H-48),X=i(A),ee=X.mul(x);ee.isNegative()||ee.gt(L);)ee=(X=i(A-=J,this.unsigned)).mul(x);X.isZero()&&(X=w),B=B.add(X),L=L.sub(ee)}return B},E.div=E.divide,E.modulo=function(x){return u(x)||(x=m(x)),o?c((this.unsigned?o.rem_u:o.rem_s)(this.low,this.high,x.low,x.high),o.get_high(),this.unsigned):this.sub(this.div(x).mul(x))},E.mod=E.modulo,E.rem=E.modulo,E.not=function(){return c(~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?d(this.low):d(this.high)+32},E.ctz=E.countTrailingZeros,E.and=function(x){return u(x)||(x=m(x)),c(this.low&x.low,this.high&x.high,this.unsigned)},E.or=function(x){return u(x)||(x=m(x)),c(this.low|x.low,this.high|x.high,this.unsigned)},E.xor=function(x){return u(x)||(x=m(x)),c(this.low^x.low,this.high^x.high,this.unsigned)},E.shiftLeft=function(x){return u(x)&&(x=x.toInt()),(x&=63)==0?this:x<32?c(this.low<<x,this.high<<x|this.low>>>32-x,this.unsigned):c(0,this.low<<x-32,this.unsigned)},E.shl=E.shiftLeft,E.shiftRight=function(x){return u(x)&&(x=x.toInt()),(x&=63)==0?this:x<32?c(this.low>>>x|this.high<<32-x,this.high>>x,this.unsigned):c(this.high>>x-32,this.high>=0?0:-1,this.unsigned)},E.shr=E.shiftRight,E.shiftRightUnsigned=function(x){return u(x)&&(x=x.toInt()),(x&=63)==0?this:x<32?c(this.low>>>x|this.high<<32-x,this.high>>>x,this.unsigned):c(x===32?this.high:this.high>>>x-32,0,this.unsigned)},E.shru=E.shiftRightUnsigned,E.shr_u=E.shiftRightUnsigned,E.rotateLeft=function(x){var A;return u(x)&&(x=x.toInt()),(x&=63)==0?this:x===32?c(this.high,this.low,this.unsigned):x<32?(A=32-x,c(this.low<<x|this.high>>>A,this.high<<x|this.low>>>A,this.unsigned)):(A=32-(x-=32),c(this.high<<x|this.low>>>A,this.low<<x|this.high>>>A,this.unsigned))},E.rotl=E.rotateLeft,E.rotateRight=function(x){var A;return u(x)&&(x=x.toInt()),(x&=63)==0?this:x===32?c(this.high,this.low,this.unsigned):x<32?(A=32-x,c(this.high<<A|this.low>>>x,this.low<<A|this.high>>>x,this.unsigned)):(A=32-(x-=32),c(this.low<<A|this.high>>>x,this.high<<A|this.low>>>x,this.unsigned))},E.rotr=E.rotateRight,E.toSigned=function(){return this.unsigned?c(this.low,this.high,!1):this},E.toUnsigned=function(){return this.unsigned?this:c(this.low,this.high,!0)},E.toBytes=function(x){return x?this.toBytesLE():this.toBytesBE()},E.toBytesLE=function(){var x=this.high,A=this.low;return[255&A,A>>>8&255,A>>>16&255,A>>>24,255&x,x>>>8&255,x>>>16&255,x>>>24]},E.toBytesBE=function(){var x=this.high,A=this.low;return[x>>>24,x>>>16&255,x>>>8&255,255&x,A>>>24,A>>>16&255,A>>>8&255,255&A]},a.fromBytes=function(x,A,L){return L?a.fromBytesLE(x,A):a.fromBytesBE(x,A)},a.fromBytesLE=function(x,A){return new a(x[0]|x[1]<<8|x[2]<<16|x[3]<<24,x[4]|x[5]<<8|x[6]<<16|x[7]<<24,A)},a.fromBytesBE=function(x,A){return new a(x[4]<<24|x[5]<<16|x[6]<<8|x[7],x[0]<<24|x[1]<<16|x[2]<<8|x[3],A)};var $=a;return r.default=$,"default"in r?r.default:r}({});(t=(function(){return n}).apply(e,[]))===void 0||(s.exports=t)},5686:(s,e,t)=>{t.r(e),t.d(e,{flatbuffers:()=>n});var n={};n.Offset,n.Table,n.SIZEOF_SHORT=2,n.SIZEOF_INT=4,n.FILE_IDENTIFIER_LENGTH=4,n.SIZE_PREFIX_LENGTH=4,n.Encoding={UTF8_BYTES:1,UTF16_STRING:2},n.int32=new Int32Array(2),n.float32=new Float32Array(n.int32.buffer),n.float64=new Float64Array(n.int32.buffer),n.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,n.Long=function(r,o){this.low=0|r,this.high=0|o},n.Long.create=function(r,o){return r==0&&o==0?n.Long.ZERO:new n.Long(r,o)},n.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},n.Long.prototype.equals=function(r){return this.low==r.low&&this.high==r.high},n.Long.ZERO=new n.Long(0,0),n.Builder=function(r){if(r)o=r;else var o=1024;this.bb=n.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},n.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},n.Builder.prototype.forceDefaults=function(r){this.force_defaults=r},n.Builder.prototype.dataBuffer=function(){return this.bb},n.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},n.Builder.prototype.prep=function(r,o){r>this.minalign&&(this.minalign=r);for(var a=1+~(this.bb.capacity()-this.space+o)&r-1;this.space<a+r+o;){var u=this.bb.capacity();this.bb=n.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-u}this.pad(a)},n.Builder.prototype.pad=function(r){for(var o=0;o<r;o++)this.bb.writeInt8(--this.space,0)},n.Builder.prototype.writeInt8=function(r){this.bb.writeInt8(this.space-=1,r)},n.Builder.prototype.writeInt16=function(r){this.bb.writeInt16(this.space-=2,r)},n.Builder.prototype.writeInt32=function(r){this.bb.writeInt32(this.space-=4,r)},n.Builder.prototype.writeInt64=function(r){this.bb.writeInt64(this.space-=8,r)},n.Builder.prototype.writeFloat32=function(r){this.bb.writeFloat32(this.space-=4,r)},n.Builder.prototype.writeFloat64=function(r){this.bb.writeFloat64(this.space-=8,r)},n.Builder.prototype.addInt8=function(r){this.prep(1,0),this.writeInt8(r)},n.Builder.prototype.addInt16=function(r){this.prep(2,0),this.writeInt16(r)},n.Builder.prototype.addInt32=function(r){this.prep(4,0),this.writeInt32(r)},n.Builder.prototype.addInt64=function(r){this.prep(8,0),this.writeInt64(r)},n.Builder.prototype.addFloat32=function(r){this.prep(4,0),this.writeFloat32(r)},n.Builder.prototype.addFloat64=function(r){this.prep(8,0),this.writeFloat64(r)},n.Builder.prototype.addFieldInt8=function(r,o,a){(this.force_defaults||o!=a)&&(this.addInt8(o),this.slot(r))},n.Builder.prototype.addFieldInt16=function(r,o,a){(this.force_defaults||o!=a)&&(this.addInt16(o),this.slot(r))},n.Builder.prototype.addFieldInt32=function(r,o,a){(this.force_defaults||o!=a)&&(this.addInt32(o),this.slot(r))},n.Builder.prototype.addFieldInt64=function(r,o,a){!this.force_defaults&&o.equals(a)||(this.addInt64(o),this.slot(r))},n.Builder.prototype.addFieldFloat32=function(r,o,a){(this.force_defaults||o!=a)&&(this.addFloat32(o),this.slot(r))},n.Builder.prototype.addFieldFloat64=function(r,o,a){(this.force_defaults||o!=a)&&(this.addFloat64(o),this.slot(r))},n.Builder.prototype.addFieldOffset=function(r,o,a){(this.force_defaults||o!=a)&&(this.addOffset(o),this.slot(r))},n.Builder.prototype.addFieldStruct=function(r,o,a){o!=a&&(this.nested(o),this.slot(r))},n.Builder.prototype.nested=function(r){if(r!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},n.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},n.Builder.prototype.slot=function(r){this.vtable[r]=this.offset()},n.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},n.Builder.growByteBuffer=function(r){var o=r.capacity();if(3221225472&o)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var a=o<<1,u=n.ByteBuffer.allocate(a);return u.setPosition(a-o),u.bytes().set(r.bytes(),a-o),u},n.Builder.prototype.addOffset=function(r){this.prep(n.SIZEOF_INT,0),this.writeInt32(this.offset()-r+n.SIZEOF_INT)},n.Builder.prototype.startObject=function(r){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=r;for(var o=0;o<r;o++)this.vtable[o]=0;this.isNested=!0,this.object_start=this.offset()},n.Builder.prototype.endObject=function(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var r=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?r-this.vtable[o]:0);this.addInt16(r-this.object_start);var u=(a+2)*n.SIZEOF_SHORT;this.addInt16(u);var d=0,h=this.space;e:for(o=0;o<this.vtables.length;o++){var p=this.bb.capacity()-this.vtables[o];if(u==this.bb.readInt16(p)){for(var l=n.SIZEOF_SHORT;l<u;l+=n.SIZEOF_SHORT)if(this.bb.readInt16(h+l)!=this.bb.readInt16(p+l))continue e;d=this.vtables[o];break}}return d?(this.space=this.bb.capacity()-r,this.bb.writeInt32(this.space,d-r)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-r,this.offset()-r)),this.isNested=!1,r},n.Builder.prototype.finish=function(r,o,a){var u=a?n.SIZE_PREFIX_LENGTH:0;if(o){var d=o;if(this.prep(this.minalign,n.SIZEOF_INT+n.FILE_IDENTIFIER_LENGTH+u),d.length!=n.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+n.FILE_IDENTIFIER_LENGTH);for(var h=n.FILE_IDENTIFIER_LENGTH-1;h>=0;h--)this.writeInt8(d.charCodeAt(h))}this.prep(this.minalign,n.SIZEOF_INT+u),this.addOffset(r),u&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},n.Builder.prototype.finishSizePrefixed=function(r,o){this.finish(r,o,!0)},n.Builder.prototype.requiredField=function(r,o){var a=this.bb.capacity()-r,u=a-this.bb.readInt32(a);if(this.bb.readInt16(u+o)==0)throw new Error("FlatBuffers: field "+o+" must be set")},n.Builder.prototype.startVector=function(r,o,a){this.notNested(),this.vector_num_elems=o,this.prep(n.SIZEOF_INT,r*o),this.prep(a,r*o)},n.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},n.Builder.prototype.createString=function(r){if(r instanceof Uint8Array)var o=r;else{o=[];for(var a=0;a<r.length;){var u,d=r.charCodeAt(a++);(u=d<55296||d>=56320?d:(d<<10)+r.charCodeAt(a++)+-56613888)<128?o.push(u):(u<2048?o.push(u>>6&31|192):(u<65536?o.push(u>>12&15|224):o.push(u>>18&7|240,u>>12&63|128),o.push(u>>6&63|128)),o.push(63&u|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()},n.Builder.prototype.createLong=function(r,o){return n.Long.create(r,o)},n.ByteBuffer=function(r){this.bytes_=r,this.position_=0},n.ByteBuffer.allocate=function(r){return new n.ByteBuffer(new Uint8Array(r))},n.ByteBuffer.prototype.clear=function(){this.position_=0},n.ByteBuffer.prototype.bytes=function(){return this.bytes_},n.ByteBuffer.prototype.position=function(){return this.position_},n.ByteBuffer.prototype.setPosition=function(r){this.position_=r},n.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},n.ByteBuffer.prototype.readInt8=function(r){return this.readUint8(r)<<24>>24},n.ByteBuffer.prototype.readUint8=function(r){return this.bytes_[r]},n.ByteBuffer.prototype.readInt16=function(r){return this.readUint16(r)<<16>>16},n.ByteBuffer.prototype.readUint16=function(r){return this.bytes_[r]|this.bytes_[r+1]<<8},n.ByteBuffer.prototype.readInt32=function(r){return this.bytes_[r]|this.bytes_[r+1]<<8|this.bytes_[r+2]<<16|this.bytes_[r+3]<<24},n.ByteBuffer.prototype.readUint32=function(r){return this.readInt32(r)>>>0},n.ByteBuffer.prototype.readInt64=function(r){return new n.Long(this.readInt32(r),this.readInt32(r+4))},n.ByteBuffer.prototype.readUint64=function(r){return new n.Long(this.readUint32(r),this.readUint32(r+4))},n.ByteBuffer.prototype.readFloat32=function(r){return n.int32[0]=this.readInt32(r),n.float32[0]},n.ByteBuffer.prototype.readFloat64=function(r){return n.int32[n.isLittleEndian?0:1]=this.readInt32(r),n.int32[n.isLittleEndian?1:0]=this.readInt32(r+4),n.float64[0]},n.ByteBuffer.prototype.writeInt8=function(r,o){this.bytes_[r]=o},n.ByteBuffer.prototype.writeUint8=function(r,o){this.bytes_[r]=o},n.ByteBuffer.prototype.writeInt16=function(r,o){this.bytes_[r]=o,this.bytes_[r+1]=o>>8},n.ByteBuffer.prototype.writeUint16=function(r,o){this.bytes_[r]=o,this.bytes_[r+1]=o>>8},n.ByteBuffer.prototype.writeInt32=function(r,o){this.bytes_[r]=o,this.bytes_[r+1]=o>>8,this.bytes_[r+2]=o>>16,this.bytes_[r+3]=o>>24},n.ByteBuffer.prototype.writeUint32=function(r,o){this.bytes_[r]=o,this.bytes_[r+1]=o>>8,this.bytes_[r+2]=o>>16,this.bytes_[r+3]=o>>24},n.ByteBuffer.prototype.writeInt64=function(r,o){this.writeInt32(r,o.low),this.writeInt32(r+4,o.high)},n.ByteBuffer.prototype.writeUint64=function(r,o){this.writeUint32(r,o.low),this.writeUint32(r+4,o.high)},n.ByteBuffer.prototype.writeFloat32=function(r,o){n.float32[0]=o,this.writeInt32(r,n.int32[0])},n.ByteBuffer.prototype.writeFloat64=function(r,o){n.float64[0]=o,this.writeInt32(r,n.int32[n.isLittleEndian?0:1]),this.writeInt32(r+4,n.int32[n.isLittleEndian?1:0])},n.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+n.SIZEOF_INT+n.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var r="",o=0;o<n.FILE_IDENTIFIER_LENGTH;o++)r+=String.fromCharCode(this.readInt8(this.position_+n.SIZEOF_INT+o));return r},n.ByteBuffer.prototype.__offset=function(r,o){var a=r-this.readInt32(r);return o<this.readInt16(a)?this.readInt16(a+o):0},n.ByteBuffer.prototype.__union=function(r,o){return r.bb_pos=o+this.readInt32(o),r.bb=this,r},n.ByteBuffer.prototype.__string=function(r,o){r+=this.readInt32(r);var a=this.readInt32(r),u="",d=0;if(r+=n.SIZEOF_INT,o===n.Encoding.UTF8_BYTES)return this.bytes_.subarray(r,r+a);for(;d<a;){var h,p=this.readUint8(r+d++);if(p<192)h=p;else{var l=this.readUint8(r+d++);if(p<224)h=(31&p)<<6|63&l;else{var i=this.readUint8(r+d++);h=p<240?(15&p)<<12|(63&l)<<6|63&i:(7&p)<<18|(63&l)<<12|(63&i)<<6|63&this.readUint8(r+d++)}}h<65536?u+=String.fromCharCode(h):(h-=65536,u+=String.fromCharCode(55296+(h>>10),56320+(1023&h)))}return u},n.ByteBuffer.prototype.__indirect=function(r){return r+this.readInt32(r)},n.ByteBuffer.prototype.__vector=function(r){return r+this.readInt32(r)+n.SIZEOF_INT},n.ByteBuffer.prototype.__vector_len=function(r){return this.readInt32(r+this.readInt32(r))},n.ByteBuffer.prototype.__has_identifier=function(r){if(r.length!=n.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+n.FILE_IDENTIFIER_LENGTH);for(var o=0;o<n.FILE_IDENTIFIER_LENGTH;o++)if(r.charCodeAt(o)!=this.readInt8(this.position_+n.SIZEOF_INT+o))return!1;return!0},n.ByteBuffer.prototype.createLong=function(r,o){return n.Long.create(r,o)}}},__webpack_module_cache__={};function __webpack_require__(s){var e=__webpack_module_cache__[s];if(e!==void 0)return e.exports;var t=__webpack_module_cache__[s]={exports:{}};return __webpack_modules__[s].call(t.exports,t,t.exports,__webpack_require__),t.exports}__webpack_require__.n=s=>{var e=s&&s.__esModule?()=>s.default:()=>s;return __webpack_require__.d(e,{a:e}),e},__webpack_require__.d=(s,e)=>{for(var t in e)__webpack_require__.o(e,t)&&!__webpack_require__.o(s,t)&&Object.defineProperty(s,t,{enumerable:!0,get:e[t]})},__webpack_require__.o=(s,e)=>Object.prototype.hasOwnProperty.call(s,e),__webpack_require__.r=s=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__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(){nt(this,"onnxModel");nt(this,"previousMask",null);nt(this,"imageLongSideLength",1024);nt(this,"predictionThreshold",0)}async init(e){this.onnxModel=await ort_minExports.InferenceSession.create(e)}getScalingFactor(e,t){return this.imageLongSideLength/Math.max(e,t)}getPreviousMask(){let e,t;return this.previousMask?(e=this.previousMask,t=new ort_minExports.Tensor("float32",[1])):(e=new ort_minExports.Tensor("float32",new Float32Array(256*256),[1,1,256,256]),t=new ort_minExports.Tensor("float32",[0])),[e,t]}preProcessInputs(e,t,n,r){const o=this.getScalingFactor(n,r),a=e==null?void 0:e.length,u=t?2:1,d=new Float32Array(2*(a+u)),h=new Float32Array(a+u);for(let i=0;i<a;i++)d[2*i]=e[i].x*o,d[2*i+1]=e[i].y*o,h[i]=e[i].label;t?(d[2*a]=Math.min(t.x,t.x+t.width)*o,d[2*a+1]=Math.min(t.y,t.y+t.height)*o,h[a]=2,d[2*a+2]=Math.max(t.x,t.x+t.width)*o,d[2*a+3]=Math.max(t.y,t.y+t.height)*o,h[a+1]=3):(d[2*a]=0,d[2*a+1]=0,h[a]=-1);const p=new ort_minExports.Tensor("float32",d,[1,a+u,2]),l=new ort_minExports.Tensor("float32",h,[1,a+u]);return{points:p,labels:l}}async segmentImage(e){const t=e.image.naturalWidth,n=e.image.naturalHeight,r=new ort_minExports.Tensor("float32",[n,t]),o=this.preProcessInputs(e.points,e.box,t,n),a=this.getPreviousMask(),u={image_embeddings:e.embedding,point_coords:o.points,point_labels:o.labels,orig_im_size:r,mask_input:a[0],has_mask_input:a[1]},d=Date.now(),h=await this.onnxModel.run(u);console.log("SAM.segmentImage in",Date.now()-d,"ms"),this.previousMask=h.low_res_masks;const p=maskDataToFortranArrayToRle(h.masks.data,n,t),l=generatePolygonSegments(p,n);return{masksImageSVG:convertSegmentsToSVG(l),rle:{counts:p,size:[n,t]},masks:h.mask}}inputNames(){return this.onnxModel.inputNames}outputNames(){return this.onnxModel.outputNames}reset(){this.previousMask=null}}const GROUND_TRUTH="Ground Truth",PRE_ANNOTATION="Pre-annotation",EXISTING_SOURCE_IDS=[GROUND_TRUTH,PRE_ANNOTATION],HIGHLIGHTED_BOX_STROKE_FACTOR=4,HIGHLIGHTED_MASK_STROKE_FACTOR=2,NOT_ANNOTATION_ITEM_OPACITY=.3,DEFAULT_FEATURE="category",defaultObjectFeatures={[DEFAULT_FEATURE]:{name:"category",dtype:"str",label:"category"}},defaultSceneFeatures={label:{name:"label",dtype:"str",value:"None"}},defineTooltip=s=>{var n,r;if(!s.bbox)return null;const e=s.bbox.confidence!=0&&s.source_id!==GROUND_TRUTH?" "+s.bbox.confidence.toFixed(2):"";return typeof((n=s.features[DEFAULT_FEATURE])==null?void 0:n.value)=="string"?((r=s.features[DEFAULT_FEATURE])==null?void 0:r.value)+e:null},mapObjectToBBox=(s,e)=>{var h,p,l,i,c,f;if(!s.bbox||s.source_id===PRE_ANNOTATION&&s.highlighted!=="self")return;const t=((h=e==null?void 0:e[s.view_id])==null?void 0:h.features.height.value)||1,n=((p=e==null?void 0:e[s.view_id])==null?void 0:p.features.width.value)||1,r=s.bbox.coords[0]*n,o=s.bbox.coords[1]*t,a=s.bbox.coords[2]*n,u=s.bbox.coords[3]*t,d=defineTooltip(s);return{id:s.id,viewId:s.view_id,catId:((l=s.features.category_id)==null?void 0:l.value)||1,bbox:[r,o,a,u],tooltip:d,opacity:s.highlighted==="none"?NOT_ANNOTATION_ITEM_OPACITY:1,visible:!((i=s.bbox.displayControl)!=null&&i.hidden)&&!((c=s.displayControl)!=null&&c.hidden),editing:(f=s.displayControl)==null?void 0:f.editing,strokeFactor:s.highlighted==="self"?HIGHLIGHTED_BOX_STROKE_FACTOR:1,highlighted:s.highlighted}},mapObjectToMasks=s=>{var o,a,u,d;if(!s.mask||s.review_state||s.source_id===PRE_ANNOTATION&&s.review_state==="accepted")return;const e=s.mask.counts,t=s.mask.size,n=generatePolygonSegments(e,t[0]),r=convertSegmentsToSVG(n);return{id:s.id,viewId:s.view_id,svg:r,rle:s.mask,catId:((o=s.features.category_id)==null?void 0:o.value)||1,visible:!((a=s.mask.displayControl)!=null&&a.hidden)&&!((u=s.displayControl)!=null&&u.hidden),editing:(d=s.displayControl)==null?void 0:d.editing,opacity:s.highlighted==="none"?NOT_ANNOTATION_ITEM_OPACITY:1,strokeFactor:s.highlighted==="self"?HIGHLIGHTED_MASK_STROKE_FACTOR:1,highlighted:s.highlighted}},toggleObjectDisplayControl=(s,e,t,n)=>(t.includes("bbox")&&s.bbox&&(s.bbox.displayControl={...s.bbox.displayControl,[e]:n}),t.includes("mask")&&s.mask&&(s.mask.displayControl={...s.mask.displayControl,[e]:n}),t.includes("bbox")&&t.includes("mask")&&(s.displayControl={...s.displayControl,[e]:n}),s),sortObjectsByModel=s=>s.reduce((e,t)=>t.source_id===PRE_ANNOTATION?(t.review_state||(e[PRE_ANNOTATION]=[t,...e[PRE_ANNOTATION]]),e):(e[t.source_id]=[t,...e[t.source_id]||[]],e),{[GROUND_TRUTH]:[],[PRE_ANNOTATION]:[]}),updateExistingObject=(s,e)=>s.map(t=>(e==null?void 0:e.status)!=="editing"||(e.highlighted==="all"&&(t.highlighted="all"),e.highlighted==="self"&&(t.highlighted=e.shapeId===t.id?"self":"none"),e.shapeId!==t.id)?t:e.type==="mask"&&t.mask?{...t,mask:{...t.mask,counts:e.counts}}:e.type==="rectangle"&&t.bbox?{...t,bbox:{...t.bbox,coords:e.coords}}:t),getObjectsToPreAnnotate=s=>s.filter(e=>e.source_id===PRE_ANNOTATION&&!e.review_state),sortAndFilterObjectsToAnnotate=(s,e)=>s.filter(t=>{var r;return(((r=t.bbox)==null?void 0:r.confidence)||0)>=e[0]}).sort((t,n)=>{var a,u;const r=((a=t.bbox)==null?void 0:a.coords[0])||0,o=((u=n.bbox)==null?void 0:u.coords[0])||0;return r-o}),mapObjectWithNewStatus=(s,e,t,n={})=>{var o;const r=(o=e[1])==null?void 0:o.id;return s.map(a=>{var u;return a.id===r?a.highlighted="self":a.highlighted="none",a.id===((u=e[0])==null?void 0:u.id)&&(a.review_state=t,Object.keys(n||{}).forEach(d=>{a.features[d]&&(a.features[d].value=n[d])})),a})},createObjectCardId=s=>`object-${s.id}`;/**
 * @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(),selectedTool=writable(),itemObjects=writable([]),interactiveSegmenterModel=writable(),itemMetas=writable(),canSave=writable(!1),preAnnotationIsActive=writable(!1),modelsStore=writable({currentModalOpen:"none",selectedModelName:""}),itemBboxes=derived([itemObjects,itemMetas],([s,e])=>s.reduce((t,n)=>{const r=mapObjectToBBox(n,e==null?void 0:e.views);return t=[...t,...r?[r]:[]],t},[])),itemMasks=derived(itemObjects,s=>s.reduce((e,t)=>{const n=mapObjectToMasks(t);return e=[...e,...n?[n]:[]],e},[]));function create_default_slot_6(s){let e,t;return e=new Mouse_pointer({}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_default_slot_5$3(s){let e,t;return e=new Square({}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_default_slot_4$3(s){let e,t;return e=new Share_2({}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_default_slot_3$4(s){let e,t,n,r;return e=new Brush({}),n=new MagicIcon({}),{c(){create_component(e.$$.fragment),t=space(),create_component(n.$$.fragment)},l(o){claim_component(e.$$.fragment,o),t=claim_space(o),claim_component(n.$$.fragment,o)},m(o,a){mount_component(e,o,a),insert_hydration(o,t,a),mount_component(n,o,a),r=!0},i(o){r||(transition_in(e.$$.fragment,o),transition_in(n.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(n.$$.fragment,o),r=!1},d(o){o&&detach(t),destroy_component(e,o),destroy_component(n,o)}}}function create_if_block$n(s){var u,d,h;let e,t,n,r,o,a;return e=new TooltipIconButton({props:{tooltipContent:s[2].name,selected:((u=s[0])==null?void 0:u.type)==="POINT_SELECTION"&&!!s[0].label,$$slots:{default:[create_default_slot_2$4]},$$scope:{ctx:s}}}),e.$on("click",s[11]),n=new TooltipIconButton({props:{tooltipContent:s[3].name,selected:((d=s[0])==null?void 0:d.type)==="POINT_SELECTION"&&!s[0].label,$$slots:{default:[create_default_slot_1$7]},$$scope:{ctx:s}}}),n.$on("click",s[12]),o=new TooltipIconButton({props:{tooltipContent:s[1].name,selected:((h=s[0])==null?void 0:h.type)==="RECTANGLE"&&s[0].isSmart,$$slots:{default:[create_default_slot$f]},$$scope:{ctx:s}}}),o.$on("click",s[13]),{c(){create_component(e.$$.fragment),t=space(),create_component(n.$$.fragment),r=space(),create_component(o.$$.fragment)},l(p){claim_component(e.$$.fragment,p),t=claim_space(p),claim_component(n.$$.fragment,p),r=claim_space(p),claim_component(o.$$.fragment,p)},m(p,l){mount_component(e,p,l),insert_hydration(p,t,l),mount_component(n,p,l),insert_hydration(p,r,l),mount_component(o,p,l),a=!0},p(p,l){var g,m,_;const i={};l&4&&(i.tooltipContent=p[2].name),l&1&&(i.selected=((g=p[0])==null?void 0:g.type)==="POINT_SELECTION"&&!!p[0].label),l&16384&&(i.$$scope={dirty:l,ctx:p}),e.$set(i);const c={};l&8&&(c.tooltipContent=p[3].name),l&1&&(c.selected=((m=p[0])==null?void 0:m.type)==="POINT_SELECTION"&&!p[0].label),l&16384&&(c.$$scope={dirty:l,ctx:p}),n.$set(c);const f={};l&2&&(f.tooltipContent=p[1].name),l&1&&(f.selected=((_=p[0])==null?void 0:_.type)==="RECTANGLE"&&p[0].isSmart),l&16384&&(f.$$scope={dirty:l,ctx:p}),o.$set(f)},i(p){a||(transition_in(e.$$.fragment,p),transition_in(n.$$.fragment,p),transition_in(o.$$.fragment,p),a=!0)},o(p){transition_out(e.$$.fragment,p),transition_out(n.$$.fragment,p),transition_out(o.$$.fragment,p),a=!1},d(p){p&&(detach(t),detach(r)),destroy_component(e,p),destroy_component(n,p),destroy_component(o,p)}}}function create_default_slot_2$4(s){let e,t,n,r;return e=new Plus_circle({}),n=new MagicIcon({}),{c(){create_component(e.$$.fragment),t=space(),create_component(n.$$.fragment)},l(o){claim_component(e.$$.fragment,o),t=claim_space(o),claim_component(n.$$.fragment,o)},m(o,a){mount_component(e,o,a),insert_hydration(o,t,a),mount_component(n,o,a),r=!0},i(o){r||(transition_in(e.$$.fragment,o),transition_in(n.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(n.$$.fragment,o),r=!1},d(o){o&&detach(t),destroy_component(e,o),destroy_component(n,o)}}}function create_default_slot_1$7(s){let e,t,n,r;return e=new Minus_circle({}),n=new MagicIcon({}),{c(){create_component(e.$$.fragment),t=space(),create_component(n.$$.fragment)},l(o){claim_component(e.$$.fragment,o),t=claim_space(o),claim_component(n.$$.fragment,o)},m(o,a){mount_component(e,o,a),insert_hydration(o,t,a),mount_component(n,o,a),r=!0},i(o){r||(transition_in(e.$$.fragment,o),transition_in(n.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(n.$$.fragment,o),r=!1},d(o){o&&detach(t),destroy_component(e,o),destroy_component(n,o)}}}function create_default_slot$f(s){let e,t,n,r;return e=new Square({}),n=new MagicIcon({}),{c(){create_component(e.$$.fragment),t=space(),create_component(n.$$.fragment)},l(o){claim_component(e.$$.fragment,o),t=claim_space(o),claim_component(n.$$.fragment,o)},m(o,a){mount_component(e,o,a),insert_hydration(o,t,a),mount_component(n,o,a),r=!0},i(o){r||(transition_in(e.$$.fragment,o),transition_in(n.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(n.$$.fragment,o),r=!1},d(o){o&&detach(t),destroy_component(e,o),destroy_component(n,o)}}}function create_fragment$v(s){var g,m,_;let e,t,n,r,o,a,u,d,h,p,l,i,c;n=new TooltipIconButton({props:{tooltipContent:panTool.name,selected:((g=s[0])==null?void 0:g.type)==="PAN",$$slots:{default:[create_default_slot_6]},$$scope:{ctx:s}}}),n.$on("click",s[8]),o=new TooltipIconButton({props:{tooltipContent:rectangleTool.name,selected:((m=s[0])==null?void 0:m.type)==="RECTANGLE"&&!s[0].isSmart,$$slots:{default:[create_default_slot_5$3]},$$scope:{ctx:s}}}),o.$on("click",s[9]),u=new TooltipIconButton({props:{tooltipContent:polygonTool.name,selected:((_=s[0])==null?void 0:_.type)==="POLYGON",$$slots:{default:[create_default_slot_4$3]},$$scope:{ctx:s}}}),u.$on("click",s[10]),p=new TooltipIconButton({props:{tooltipContent:"Use a smart segmentation model",$$slots:{default:[create_default_slot_3$4]},$$scope:{ctx:s}}}),p.$on("click",s[6]);let f=s[4]&&create_if_block$n(s);return{c(){e=element("div"),t=element("div"),create_component(n.$$.fragment),r=space(),create_component(o.$$.fragment),a=space(),create_component(u.$$.fragment),d=space(),h=element("div"),create_component(p.$$.fragment),l=space(),f&&f.c(),this.h()},l(b){e=claim_element(b,"DIV",{class:!0});var v=children(e);t=claim_element(v,"DIV",{class:!0});var T=children(t);claim_component(n.$$.fragment,T),r=claim_space(T),claim_component(o.$$.fragment,T),a=claim_space(T),claim_component(u.$$.fragment,T),T.forEach(detach),d=claim_space(v),h=claim_element(v,"DIV",{class:!0});var y=children(h);claim_component(p.$$.fragment,y),l=claim_space(y),f&&f.l(y),y.forEach(detach),v.forEach(detach),this.h()},h(){attr(t,"class","flex items-center flex-col gap-4"),attr(h,"class",i=cn("flex items-center flex-col gap-4 mt-4",{"bg-slate-200 rounded-sm":s[4]})),attr(e,"class","h-full shadow-md bg-popover py-4 px-2 w-16 border-l border-slate-200 z-10")},m(b,v){insert_hydration(b,e,v),append_hydration(e,t),mount_component(n,t,null),append_hydration(t,r),mount_component(o,t,null),append_hydration(t,a),mount_component(u,t,null),append_hydration(e,d),append_hydration(e,h),mount_component(p,h,null),append_hydration(h,l),f&&f.m(h,null),c=!0},p(b,[v]){var k,P,I;const T={};v&1&&(T.selected=((k=b[0])==null?void 0:k.type)==="PAN"),v&16384&&(T.$$scope={dirty:v,ctx:b}),n.$set(T);const y={};v&1&&(y.selected=((P=b[0])==null?void 0:P.type)==="RECTANGLE"&&!b[0].isSmart),v&16384&&(y.$$scope={dirty:v,ctx:b}),o.$set(y);const S={};v&1&&(S.selected=((I=b[0])==null?void 0:I.type)==="POLYGON"),v&16384&&(S.$$scope={dirty:v,ctx:b}),u.$set(S);const w={};v&16384&&(w.$$scope={dirty:v,ctx:b}),p.$set(w),b[4]?f?(f.p(b,v),v&16&&transition_in(f,1)):(f=create_if_block$n(b),f.c(),transition_in(f,1),f.m(h,null)):f&&(group_outros(),transition_out(f,1,1,()=>{f=null}),check_outros()),(!c||v&16&&i!==(i=cn("flex items-center flex-col gap-4 mt-4",{"bg-slate-200 rounded-sm":b[4]})))&&attr(h,"class",i)},i(b){c||(transition_in(n.$$.fragment,b),transition_in(o.$$.fragment,b),transition_in(u.$$.fragment,b),transition_in(p.$$.fragment,b),transition_in(f),c=!0)},o(b){transition_out(n.$$.fragment,b),transition_out(o.$$.fragment,b),transition_out(u.$$.fragment,b),transition_out(p.$$.fragment,b),transition_out(f),c=!1},d(b){b&&detach(e),destroy_component(n),destroy_component(o),destroy_component(u),destroy_component(p),f&&f.d()}}}function instance$z(s,e,t){let n;component_subscribe(s,selectedTool,f=>t(0,n=f));let r=null,o=!1;const a=f=>{f!==n&&selectedTool.set(f)},u=()=>{o?a(panTool):(a(addSmartPointTool),modelsStore.update(f=>({...f,currentModalOpen:"selectModel"}))),t(4,o=!o)};interactiveSegmenterModel.subscribe(f=>{f&&(t(2,addSmartPointTool.postProcessor=f,addSmartPointTool),t(3,removeSmartPointTool.postProcessor=f,removeSmartPointTool),t(1,smartRectangleTool.postProcessor=f,smartRectangleTool))}),onMount(()=>{a(panTool)});const d=()=>a(panTool),h=()=>a(rectangleTool),p=()=>a(polygonTool),l=()=>a(addSmartPointTool),i=()=>a(removeSmartPointTool),c=()=>a(smartRectangleTool);return s.$$.update=()=>{s.$$.dirty&129&&((!(r!=null&&r.isSmart)||!(n!=null&&n.isSmart))&&newShape.set({status:"none"}),t(7,r=n))},[n,smartRectangleTool,addSmartPointTool,removeSmartPointTool,o,a,u,r,d,h,p,l,i,c]}class Toolbar extends SvelteComponent{constructor(e){super(),init(this,e,instance$z,create_fragment$v,safe_not_equal,{})}}function get_each_context$6(s,e,t){const n=s.slice();return n[18]=e[t],n}function create_default_slot_5$2(s){let e,t,n,r,o,a=[{type:"button"},s[21],{class:n=cn("py-0 rounded-md bg-transparent flex h-10 items-center border border-input bg-white px-3 text-sm ring-offset-background w-full",s[3])}],u={};for(let d=0;d<a.length;d+=1)u=assign(u,a[d]);return{c(){e=element("button"),t=text(s[6]),this.h()},l(d){e=claim_element(d,"BUTTON",{type:!0,class:!0});var h=children(e);t=claim_text(h,s[6]),h.forEach(detach),this.h()},h(){set_attributes(e,u)},m(d,h){insert_hydration(d,e,h),append_hydration(e,t),e.autofocus&&e.focus(),r||(o=action_destroyer(s[21].action(e)),r=!0)},p(d,h){h&64&&set_data_maybe_contenteditable(t,d[6],u.contenteditable),set_attributes(e,u=get_spread_update(a,[{type:"button"},h&2097152&&d[21],h&8&&n!==(n=cn("py-0 rounded-md bg-transparent flex h-10 items-center border border-input bg-white px-3 text-sm ring-offset-background w-full",d[3]))&&{class:n}]))},d(d){d&&detach(e),r=!1,o()}}}function create_if_block$m(s){let e,t,n;function r(a){s[12](a)}let o={placeholder:s[2]};return s[7]!==void 0&&(o.value=s[7]),e=new Command_input({props:o}),binding_callbacks.push(()=>bind(e,"value",r)),e.$on("change",s[13]),e.$on("input",s[9]),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,u){mount_component(e,a,u),n=!0},p(a,u){const d={};u&4&&(d.placeholder=a[2]),!t&&u&128&&(t=!0,d.value=a[7],add_flush_callback(()=>t=!1)),e.$set(d)},i(a){n||(transition_in(e.$$.fragment,a),n=!0)},o(a){transition_out(e.$$.fragment,a),n=!1},d(a){destroy_component(e,a)}}}function create_default_slot_4$2(s){let e,t,n=s[18].label+"",r,o,a;return e=new Check({props:{class:cn("mr-2 h-4 w-4",s[1]!==s[18].value&&"text-transparent")}}),{c(){create_component(e.$$.fragment),t=space(),r=text(n),o=space()},l(u){claim_component(e.$$.fragment,u),t=claim_space(u),r=claim_text(u,n),o=claim_space(u)},m(u,d){mount_component(e,u,d),insert_hydration(u,t,d),insert_hydration(u,r,d),insert_hydration(u,o,d),a=!0},p(u,d){const h={};d&3&&(h.class=cn("mr-2 h-4 w-4",u[1]!==u[18].value&&"text-transparent")),e.$set(h),(!a||d&1)&&n!==(n=u[18].label+"")&&set_data(r,n)},i(u){a||(transition_in(e.$$.fragment,u),a=!0)},o(u){transition_out(e.$$.fragment,u),a=!1},d(u){u&&(detach(t),detach(r),detach(o)),destroy_component(e,u)}}}function create_each_block$6(s){let e,t;function n(...r){return s[14](s[17],...r)}return e=new Command_item({props:{value:s[18].value,onSelect:n,$$slots:{default:[create_default_slot_4$2]},$$scope:{ctx:s}}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,o){mount_component(e,r,o),t=!0},p(r,o){s=r;const a={};o&1&&(a.value=s[18].value),o&131072&&(a.onSelect=n),o&4194307&&(a.$$scope={dirty:o,ctx:s}),e.$set(a)},i(r){t||(transition_in(e.$$.fragment,r),t=!0)},o(r){transition_out(e.$$.fragment,r),t=!1},d(r){destroy_component(e,r)}}}function create_default_slot_3$3(s){let e,t,n=ensure_array_like(s[0]),r=[];for(let a=0;a<n.length;a+=1)r[a]=create_each_block$6(get_each_context$6(s,n,a));const o=a=>transition_out(r[a],1,1,()=>{r[a]=null});return{c(){for(let a=0;a<r.length;a+=1)r[a].c();e=empty()},l(a){for(let u=0;u<r.length;u+=1)r[u].l(a);e=empty()},m(a,u){for(let d=0;d<r.length;d+=1)r[d]&&r[d].m(a,u);insert_hydration(a,e,u),t=!0},p(a,u){if(u&131331){n=ensure_array_like(a[0]);let d;for(d=0;d<n.length;d+=1){const h=get_each_context$6(a,n,d);r[d]?(r[d].p(h,u),transition_in(r[d],1)):(r[d]=create_each_block$6(h),r[d].c(),transition_in(r[d],1),r[d].m(e.parentNode,e))}for(group_outros(),d=n.length;d<r.length;d+=1)o(d);check_outros()}},i(a){if(!t){for(let u=0;u<n.length;u+=1)transition_in(r[u]);t=!0}},o(a){r=r.filter(Boolean);for(let u=0;u<r.length;u+=1)transition_out(r[u]);t=!1},d(a){a&&detach(e),destroy_each(r,a)}}}function create_default_slot_2$3(s){let e,t,n,r=s[4]&&create_if_block$m(s);return t=new Command_list({props:{$$slots:{default:[create_default_slot_3$3]},$$scope:{ctx:s}}}),{c(){r&&r.c(),e=space(),create_component(t.$$.fragment)},l(o){r&&r.l(o),e=claim_space(o),claim_component(t.$$.fragment,o)},m(o,a){r&&r.m(o,a),insert_hydration(o,e,a),mount_component(t,o,a),n=!0},p(o,a){o[4]?r?(r.p(o,a),a&16&&transition_in(r,1)):(r=create_if_block$m(o),r.c(),transition_in(r,1),r.m(e.parentNode,e)):r&&(group_outros(),transition_out(r,1,1,()=>{r=null}),check_outros());const u={};a&4325379&&(u.$$scope={dirty:a,ctx:o}),t.$set(u)},i(o){n||(transition_in(r),transition_in(t.$$.fragment,o),n=!0)},o(o){transition_out(r),transition_out(t.$$.fragment,o),n=!1},d(o){o&&detach(e),r&&r.d(o),destroy_component(t,o)}}}function create_default_slot_1$6(s){let e,t;return e=new Command({props:{$$slots:{default:[create_default_slot_2$3]},$$scope:{ctx:s}}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p(n,r){const o={};r&4325527&&(o.$$scope={dirty:r,ctx:n}),e.$set(o)},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_default_slot$e(s){let e,t,n,r;return e=new Trigger({props:{asChild:!0,$$slots:{default:[create_default_slot_5$2,({builder:o})=>({21:o}),({builder:o})=>o?2097152:0]},$$scope:{ctx:s}}}),n=new Popover_content({props:{class:"p-0 ",tabindex:-1,$$slots:{default:[create_default_slot_1$6]},$$scope:{ctx:s}}}),{c(){create_component(e.$$.fragment),t=space(),create_component(n.$$.fragment)},l(o){claim_component(e.$$.fragment,o),t=claim_space(o),claim_component(n.$$.fragment,o)},m(o,a){mount_component(e,o,a),insert_hydration(o,t,a),mount_component(n,o,a),r=!0},p(o,a){const u={};a&6291528&&(u.$$scope={dirty:a,ctx:o}),e.$set(u);const d={};a&4325527&&(d.$$scope={dirty:a,ctx:o}),n.$set(d)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(n.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(n.$$.fragment,o),r=!1},d(o){o&&detach(t),destroy_component(e,o),destroy_component(n,o)}}}function create_fragment$u(s){let e,t,n;function r(a){s[15](a)}let o={$$slots:{default:[create_default_slot$e,({ids:a})=>({17:a}),({ids:a})=>a?131072:0]},$$scope:{ctx:s}};return s[5]!==void 0&&(o.open=s[5]),e=new Root({props:o}),binding_callbacks.push(()=>bind(e,"open",r)),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,u){mount_component(e,a,u),n=!0},p(a,[u]){const d={};u&4325599&&(d.$$scope={dirty:u,ctx:a}),!t&&u&32&&(t=!0,d.open=a[5],add_flush_callback(()=>t=!1)),e.$set(d)},i(a){n||(transition_in(e.$$.fragment,a),n=!0)},o(a){transition_out(e.$$.fragment,a),n=!1},d(a){destroy_component(e,a)}}}function instance$y(s,e,t){let{onTextInputChange:n}=e,{featureList:r=[]}=e,{placeholder:o="Select a feature"}=e,{value:a=""}=e,{autofocus:u=!1}=e,{className:d=""}=e,{isInputEnabled:h=!0}=e,p=u,l=a||o,i=a;function c(T){t(5,p=!1),tick().then(()=>{var y;(y=document.getElementById(T))==null||y.focus()}).catch(y=>console.error(y))}const f=(T,y)=>{t(1,a=T),n(a),c(y)},g=()=>{var y;!((y=r.find(S=>S.value===i))==null?void 0:y.label)&&i&&t(0,r=[...r,{value:i,label:i}])};function m(T){i=T,t(7,i)}const _=()=>console.log("changed"),b=(T,y)=>f(y,T.trigger);function v(T){p=T,t(5,p)}return s.$$set=T=>{"onTextInputChange"in T&&t(10,n=T.onTextInputChange),"featureList"in T&&t(0,r=T.featureList),"placeholder"in T&&t(2,o=T.placeholder),"value"in T&&t(1,a=T.value),"autofocus"in T&&t(11,u=T.autofocus),"className"in T&&t(3,d=T.className),"isInputEnabled"in T&&t(4,h=T.isInputEnabled)},s.$$.update=()=>{var T;s.$$.dirty&7&&t(6,l=((T=r.find(y=>y.value===a))==null?void 0:T.label)??o)},[r,a,o,d,h,p,l,i,f,g,n,u,m,_,b,v]}class AutoCompleteFeatureInput extends SvelteComponent{constructor(e){super(),init(this,e,instance$y,create_fragment$u,safe_not_equal,{onTextInputChange:10,featureList:0,placeholder:2,value:1,autofocus:11,className:3,isInputEnabled:4})}}var util;(function(s){s.assertEqual=r=>r;function e(r){}s.assertIs=e;function t(r){throw new Error}s.assertNever=t,s.arrayToEnum=r=>{const o={};for(const a of r)o[a]=a;return o},s.getValidEnumValues=r=>{const o=s.objectKeys(r).filter(u=>typeof r[r[u]]!="number"),a={};for(const u of o)a[u]=r[u];return s.objectValues(a)},s.objectValues=r=>s.objectKeys(r).map(function(o){return r[o]}),s.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const o=[];for(const a in r)Object.prototype.hasOwnProperty.call(r,a)&&o.push(a);return o},s.find=(r,o)=>{for(const a of r)if(o(a))return a},s.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function n(r,o=" | "){return r.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}s.joinValues=n,s.jsonStringifyReplacer=(r,o)=>typeof o=="bigint"?o.toString():o})(util||(util={}));var objectUtil;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(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=s=>{switch(typeof s){case"undefined":return ZodParsedType.undefined;case"string":return ZodParsedType.string;case"number":return isNaN(s)?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(s)?ZodParsedType.array:s===null?ZodParsedType.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?ZodParsedType.promise:typeof Map<"u"&&s instanceof Map?ZodParsedType.map:typeof Set<"u"&&s instanceof Set?ZodParsedType.set:typeof Date<"u"&&s 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=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");class ZodError extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(o){return o.message},n={_errors:[]},r=o=>{for(const a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(r);else if(a.code==="invalid_return_type")r(a.returnTypeError);else if(a.code==="invalid_arguments")r(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let u=n,d=0;for(;d<a.path.length;){const h=a.path[d];d===a.path.length-1?(u[h]=u[h]||{_errors:[]},u[h]._errors.push(t(a))):u[h]=u[h]||{_errors:[]},u=u[h],d++}}};return r(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,util.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}ZodError.create=s=>new ZodError(s);const errorMap=(s,e)=>{let t;switch(s.code){case ZodIssueCode.invalid_type:s.received===ZodParsedType.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case ZodIssueCode.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,util.jsonStringifyReplacer)}`;break;case ZodIssueCode.unrecognized_keys:t=`Unrecognized key(s) in object: ${util.joinValues(s.keys,", ")}`;break;case ZodIssueCode.invalid_union:t="Invalid input";break;case ZodIssueCode.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${util.joinValues(s.options)}`;break;case ZodIssueCode.invalid_enum_value:t=`Invalid enum value. Expected ${util.joinValues(s.options)}, received '${s.received}'`;break;case ZodIssueCode.invalid_arguments:t="Invalid function arguments";break;case ZodIssueCode.invalid_return_type:t="Invalid function return type";break;case ZodIssueCode.invalid_date:t="Invalid date";break;case ZodIssueCode.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:util.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case ZodIssueCode.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case ZodIssueCode.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case ZodIssueCode.custom:t="Invalid input";break;case ZodIssueCode.invalid_intersection_types:t="Intersection results could not be merged";break;case ZodIssueCode.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case ZodIssueCode.not_finite:t="Number must be finite";break;default:t=e.defaultError,util.assertNever(s)}return{message:t}};let overrideErrorMap=errorMap;function setErrorMap(s){overrideErrorMap=s}function getErrorMap(){return overrideErrorMap}const makeIssue=s=>{const{data:e,path:t,errorMaps:n,issueData:r}=s,o=[...t,...r.path||[]],a={...r,path:o};let u="";const d=n.filter(h=>!!h).slice().reverse();for(const h of d)u=h(a,{data:e,defaultError:u}).message;return{...r,path:o,message:r.message||u}},EMPTY_PATH=[];function addIssueToContext(s,e){const t=makeIssue({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,getErrorMap(),errorMap].filter(n=>!!n)});s.common.issues.push(t)}class ParseStatus{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const r of t){if(r.status==="aborted")return INVALID;r.status==="dirty"&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const r of t)n.push({key:await r.key,value:await r.value});return ParseStatus.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){const{key:o,value:a}=r;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"||r.alwaysSet)&&(n[o.value]=a.value)}return{status:e.value,value:n}}}const INVALID=Object.freeze({status:"aborted"}),DIRTY=s=>({status:"dirty",value:s}),OK=s=>({status:"valid",value:s}),isAborted=s=>s.status==="aborted",isDirty=s=>s.status==="dirty",isValid=s=>s.status==="valid",isAsync=s=>typeof Promise<"u"&&s instanceof Promise;var errorUtil;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(errorUtil||(errorUtil={}));class ParseInputLazyPath{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}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=(s,e)=>{if(isValid(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new ZodError(s.common.issues);return this._error=t,this._error}}};function processCreateParams(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:r}=s;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(a,u)=>a.code!=="invalid_type"?{message:u.defaultError}:typeof u.data>"u"?{message:n??u.defaultError}:{message:t??u.defaultError},description:r}}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,t){return t||{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 t=this._parse(e);if(isAsync(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const r={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:getParsedType(e)},o=this._parseSync({data:e,path:r.path,parent:r});return handleResult(r,o)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:getParsedType(e)},r=this._parse({data:e,path:n.path,parent:n}),o=await(isAsync(r)?r:Promise.resolve(r));return handleResult(n,o)}refine(e,t){const n=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,o)=>{const a=e(r),u=()=>o.addIssue({code:ZodIssueCode.custom,...n(r)});return typeof Promise<"u"&&a instanceof Promise?a.then(d=>d?!0:(u(),!1)):a?!0:(u(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t=="function"?t(n,r):t),!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 t=typeof e=="function"?e:()=>e;return new ZodDefault({...processCreateParams(this._def),innerType:this,defaultValue:t,typeName:ZodFirstPartyTypeKind.ZodDefault})}brand(){return new ZodBranded({typeName:ZodFirstPartyTypeKind.ZodBranded,type:this,...processCreateParams(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ZodCatch({...processCreateParams(this._def),innerType:this,catchValue:t,typeName:ZodFirstPartyTypeKind.ZodCatch})}describe(e){const t=this.constructor;return new t({...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=s=>s.precision?s.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}Z$`):s.precision===0?s.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$"):s.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(s,e){return!!((e==="v4"||!e)&&ipv4Regex.test(s)||(e==="v6"||!e)&&ipv6Regex.test(s))}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 n=new ParseStatus;let r;for(const o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")e.data.length>o.value&&(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){const a=e.data.length>o.value,u=e.data.length<o.value;(a||u)&&(r=this._getOrReturnCtx(e,r),a?addIssueToContext(r,{code:ZodIssueCode.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):u&&addIssueToContext(r,{code:ZodIssueCode.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")emailRegex.test(e.data)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{validation:"email",code:ZodIssueCode.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")emojiRegex||(emojiRegex=new RegExp(_emojiRegex,"u")),emojiRegex.test(e.data)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{validation:"emoji",code:ZodIssueCode.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")uuidRegex.test(e.data)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{validation:"uuid",code:ZodIssueCode.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")cuidRegex.test(e.data)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{validation:"cuid",code:ZodIssueCode.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")cuid2Regex.test(e.data)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{validation:"cuid2",code:ZodIssueCode.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")ulidRegex.test(e.data)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{validation:"ulid",code:ZodIssueCode.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),addIssueToContext(r,{validation:"url",code:ZodIssueCode.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{validation:"regex",code:ZodIssueCode.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.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)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?datetimeRegex(o).test(e.data)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="ip"?isValidIP(e.data,o.version)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{validation:"ip",code:ZodIssueCode.invalid_string,message:o.message}),n.dirty()):util.assertNever(o);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(r=>e.test(r),{validation:t,code:ZodIssueCode.invalid_string,...errorUtil.errToObj(n)})}_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 t;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:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...errorUtil.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...errorUtil.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...errorUtil.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...errorUtil.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...errorUtil.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...errorUtil.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...errorUtil.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...errorUtil.errToObj(t)})}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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ZodString.create=s=>{var e;return new ZodString({checks:[],typeName:ZodFirstPartyTypeKind.ZodString,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...processCreateParams(s)})};function floatSafeRemainder(s,e){const t=(s.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=t>n?t:n,o=parseInt(s.toFixed(r).replace(".","")),a=parseInt(e.toFixed(r).replace(".",""));return o%a/Math.pow(10,r)}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 n;const r=new ParseStatus;for(const o of this._def.checks)o.kind==="int"?util.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:"integer",received:"float",message:o.message}),r.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{code:ZodIssueCode.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),r.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{code:ZodIssueCode.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),r.dirty()):o.kind==="multipleOf"?floatSafeRemainder(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{code:ZodIssueCode.not_multiple_of,multipleOf:o.value,message:o.message}),r.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{code:ZodIssueCode.not_finite,message:o.message}),r.dirty()):util.assertNever(o);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,errorUtil.toString(t))}gt(e,t){return this.setLimit("min",e,!1,errorUtil.toString(t))}lte(e,t){return this.setLimit("max",e,!0,errorUtil.toString(t))}lt(e,t){return this.setLimit("max",e,!1,errorUtil.toString(t))}setLimit(e,t,n,r){return new ZodNumber({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:errorUtil.toString(r)}]})}_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,t){return this._addCheck({kind:"multipleOf",value:e,message:errorUtil.toString(t)})}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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.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,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ZodNumber.create=s=>new ZodNumber({checks:[],typeName:ZodFirstPartyTypeKind.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...processCreateParams(s)});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 n;const r=new ParseStatus;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{code:ZodIssueCode.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),r.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{code:ZodIssueCode.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),r.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),addIssueToContext(n,{code:ZodIssueCode.not_multiple_of,multipleOf:o.value,message:o.message}),r.dirty()):util.assertNever(o);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,errorUtil.toString(t))}gt(e,t){return this.setLimit("min",e,!1,errorUtil.toString(t))}lte(e,t){return this.setLimit("max",e,!0,errorUtil.toString(t))}lt(e,t){return this.setLimit("max",e,!1,errorUtil.toString(t))}setLimit(e,t,n,r){return new ZodBigInt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:errorUtil.toString(r)}]})}_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,t){return this._addCheck({kind:"multipleOf",value:e,message:errorUtil.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ZodBigInt.create=s=>{var e;return new ZodBigInt({checks:[],typeName:ZodFirstPartyTypeKind.ZodBigInt,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...processCreateParams(s)})};class ZodBoolean extends ZodType{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ZodParsedType.boolean){const n=this._getOrReturnCtx(e);return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.boolean,received:n.parsedType}),INVALID}return OK(e.data)}}ZodBoolean.create=s=>new ZodBoolean({typeName:ZodFirstPartyTypeKind.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...processCreateParams(s)});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 n=new ParseStatus;let r;for(const o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):util.assertNever(o);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ZodDate({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:errorUtil.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:errorUtil.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ZodDate.create=s=>new ZodDate({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:ZodFirstPartyTypeKind.ZodDate,...processCreateParams(s)});class ZodSymbol extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.symbol){const n=this._getOrReturnCtx(e);return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.symbol,received:n.parsedType}),INVALID}return OK(e.data)}}ZodSymbol.create=s=>new ZodSymbol({typeName:ZodFirstPartyTypeKind.ZodSymbol,...processCreateParams(s)});class ZodUndefined extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.undefined){const n=this._getOrReturnCtx(e);return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.undefined,received:n.parsedType}),INVALID}return OK(e.data)}}ZodUndefined.create=s=>new ZodUndefined({typeName:ZodFirstPartyTypeKind.ZodUndefined,...processCreateParams(s)});class ZodNull extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.null){const n=this._getOrReturnCtx(e);return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.null,received:n.parsedType}),INVALID}return OK(e.data)}}ZodNull.create=s=>new ZodNull({typeName:ZodFirstPartyTypeKind.ZodNull,...processCreateParams(s)});class ZodAny extends ZodType{constructor(){super(...arguments),this._any=!0}_parse(e){return OK(e.data)}}ZodAny.create=s=>new ZodAny({typeName:ZodFirstPartyTypeKind.ZodAny,...processCreateParams(s)});class ZodUnknown extends ZodType{constructor(){super(...arguments),this._unknown=!0}_parse(e){return OK(e.data)}}ZodUnknown.create=s=>new ZodUnknown({typeName:ZodFirstPartyTypeKind.ZodUnknown,...processCreateParams(s)});class ZodNever extends ZodType{_parse(e){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.never,received:t.parsedType}),INVALID}}ZodNever.create=s=>new ZodNever({typeName:ZodFirstPartyTypeKind.ZodNever,...processCreateParams(s)});class ZodVoid extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.undefined){const n=this._getOrReturnCtx(e);return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.void,received:n.parsedType}),INVALID}return OK(e.data)}}ZodVoid.create=s=>new ZodVoid({typeName:ZodFirstPartyTypeKind.ZodVoid,...processCreateParams(s)});class ZodArray extends ZodType{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==ZodParsedType.array)return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.array,received:t.parsedType}),INVALID;if(r.exactLength!==null){const a=t.data.length>r.exactLength.value,u=t.data.length<r.exactLength.value;(a||u)&&(addIssueToContext(t,{code:a?ZodIssueCode.too_big:ZodIssueCode.too_small,minimum:u?r.exactLength.value:void 0,maximum:a?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(addIssueToContext(t,{code:ZodIssueCode.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(addIssueToContext(t,{code:ZodIssueCode.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,u)=>r.type._parseAsync(new ParseInputLazyPath(t,a,t.path,u)))).then(a=>ParseStatus.mergeArray(n,a));const o=[...t.data].map((a,u)=>r.type._parseSync(new ParseInputLazyPath(t,a,t.path,u)));return ParseStatus.mergeArray(n,o)}get element(){return this._def.type}min(e,t){return new ZodArray({...this._def,minLength:{value:e,message:errorUtil.toString(t)}})}max(e,t){return new ZodArray({...this._def,maxLength:{value:e,message:errorUtil.toString(t)}})}length(e,t){return new ZodArray({...this._def,exactLength:{value:e,message:errorUtil.toString(t)}})}nonempty(e){return this.min(1,e)}}ZodArray.create=(s,e)=>new ZodArray({type:s,minLength:null,maxLength:null,exactLength:null,typeName:ZodFirstPartyTypeKind.ZodArray,...processCreateParams(e)});function deepPartialify(s){if(s instanceof ZodObject){const e={};for(const t in s.shape){const n=s.shape[t];e[t]=ZodOptional.create(deepPartialify(n))}return new ZodObject({...s._def,shape:()=>e})}else return s instanceof ZodArray?new ZodArray({...s._def,type:deepPartialify(s.element)}):s instanceof ZodOptional?ZodOptional.create(deepPartialify(s.unwrap())):s instanceof ZodNullable?ZodNullable.create(deepPartialify(s.unwrap())):s instanceof ZodTuple?ZodTuple.create(s.items.map(e=>deepPartialify(e))):s}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(),t=util.objectKeys(e);return this._cached={shape:e,keys:t}}_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:n,ctx:r}=this._processInputParams(e),{shape:o,keys:a}=this._getCached(),u=[];if(!(this._def.catchall instanceof ZodNever&&this._def.unknownKeys==="strip"))for(const h in r.data)a.includes(h)||u.push(h);const d=[];for(const h of a){const p=o[h],l=r.data[h];d.push({key:{status:"valid",value:h},value:p._parse(new ParseInputLazyPath(r,l,r.path,h)),alwaysSet:h in r.data})}if(this._def.catchall instanceof ZodNever){const h=this._def.unknownKeys;if(h==="passthrough")for(const p of u)d.push({key:{status:"valid",value:p},value:{status:"valid",value:r.data[p]}});else if(h==="strict")u.length>0&&(addIssueToContext(r,{code:ZodIssueCode.unrecognized_keys,keys:u}),n.dirty());else if(h!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const h=this._def.catchall;for(const p of u){const l=r.data[p];d.push({key:{status:"valid",value:p},value:h._parse(new ParseInputLazyPath(r,l,r.path,p)),alwaysSet:p in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const h=[];for(const p of d){const l=await p.key;h.push({key:l,value:await p.value,alwaysSet:p.alwaysSet})}return h}).then(h=>ParseStatus.mergeObjectSync(n,h)):ParseStatus.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return errorUtil.errToObj,new ZodObject({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var r,o,a,u;const d=(a=(o=(r=this._def).errorMap)===null||o===void 0?void 0:o.call(r,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(u=errorUtil.errToObj(e).message)!==null&&u!==void 0?u:d}:{message:d}}}:{}})}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,t){return this.augment({[e]:t})}catchall(e){return new ZodObject({...this._def,catchall:e})}pick(e){const t={};return util.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new ZodObject({...this._def,shape:()=>t})}omit(e){const t={};return util.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new ZodObject({...this._def,shape:()=>t})}deepPartial(){return deepPartialify(this)}partial(e){const t={};return util.objectKeys(this.shape).forEach(n=>{const r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional()}),new ZodObject({...this._def,shape:()=>t})}required(e){const t={};return util.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof ZodOptional;)o=o._def.innerType;t[n]=o}}),new ZodObject({...this._def,shape:()=>t})}keyof(){return createZodEnum(util.objectKeys(this.shape))}}ZodObject.create=(s,e)=>new ZodObject({shape:()=>s,unknownKeys:"strip",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(e)});ZodObject.strictCreate=(s,e)=>new ZodObject({shape:()=>s,unknownKeys:"strict",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(e)});ZodObject.lazycreate=(s,e)=>new ZodObject({shape:s,unknownKeys:"strip",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(e)});class ZodUnion extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function r(o){for(const u of o)if(u.result.status==="valid")return u.result;for(const u of o)if(u.result.status==="dirty")return t.common.issues.push(...u.ctx.common.issues),u.result;const a=o.map(u=>new ZodError(u.ctx.common.issues));return addIssueToContext(t,{code:ZodIssueCode.invalid_union,unionErrors:a}),INVALID}if(t.common.async)return Promise.all(n.map(async o=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await o._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(r);{let o;const a=[];for(const d of n){const h={...t,common:{...t.common,issues:[]},parent:null},p=d._parseSync({data:t.data,path:t.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 t.common.issues.push(...o.ctx.common.issues),o.result;const u=a.map(d=>new ZodError(d));return addIssueToContext(t,{code:ZodIssueCode.invalid_union,unionErrors:u}),INVALID}}get options(){return this._def.options}}ZodUnion.create=(s,e)=>new ZodUnion({options:s,typeName:ZodFirstPartyTypeKind.ZodUnion,...processCreateParams(e)});const getDiscriminator=s=>s instanceof ZodLazy?getDiscriminator(s.schema):s instanceof ZodEffects?getDiscriminator(s.innerType()):s instanceof ZodLiteral?[s.value]:s instanceof ZodEnum?s.options:s instanceof ZodNativeEnum?Object.keys(s.enum):s instanceof ZodDefault?getDiscriminator(s._def.innerType):s instanceof ZodUndefined?[void 0]:s instanceof ZodNull?[null]:null;class ZodDiscriminatedUnion extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ZodParsedType.object)return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:t.parsedType}),INVALID;const n=this.discriminator,r=t.data[n],o=this.optionsMap.get(r);return o?t.common.async?o._parseAsync({data:t.data,path:t.path,parent:t}):o._parseSync({data:t.data,path:t.path,parent:t}):(addIssueToContext(t,{code:ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const r=new Map;for(const o of t){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 u of a){if(r.has(u))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(u)}`);r.set(u,o)}}return new ZodDiscriminatedUnion({typeName:ZodFirstPartyTypeKind.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...processCreateParams(n)})}}function mergeValues(s,e){const t=getParsedType(s),n=getParsedType(e);if(s===e)return{valid:!0,data:s};if(t===ZodParsedType.object&&n===ZodParsedType.object){const r=util.objectKeys(e),o=util.objectKeys(s).filter(u=>r.indexOf(u)!==-1),a={...s,...e};for(const u of o){const d=mergeValues(s[u],e[u]);if(!d.valid)return{valid:!1};a[u]=d.data}return{valid:!0,data:a}}else if(t===ZodParsedType.array&&n===ZodParsedType.array){if(s.length!==e.length)return{valid:!1};const r=[];for(let o=0;o<s.length;o++){const a=s[o],u=e[o],d=mergeValues(a,u);if(!d.valid)return{valid:!1};r.push(d.data)}return{valid:!0,data:r}}else return t===ZodParsedType.date&&n===ZodParsedType.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class ZodIntersection extends ZodType{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(o,a)=>{if(isAborted(o)||isAborted(a))return INVALID;const u=mergeValues(o.value,a.value);return u.valid?((isDirty(o)||isDirty(a))&&t.dirty(),{status:t.value,value:u.data}):(addIssueToContext(n,{code:ZodIssueCode.invalid_intersection_types}),INVALID)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,a])=>r(o,a)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}ZodIntersection.create=(s,e,t)=>new ZodIntersection({left:s,right:e,typeName:ZodFirstPartyTypeKind.ZodIntersection,...processCreateParams(t)});class ZodTuple extends ZodType{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ZodParsedType.array)return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.array,received:n.parsedType}),INVALID;if(n.data.length<this._def.items.length)return addIssueToContext(n,{code:ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),INVALID;!this._def.rest&&n.data.length>this._def.items.length&&(addIssueToContext(n,{code:ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const o=[...n.data].map((a,u)=>{const d=this._def.items[u]||this._def.rest;return d?d._parse(new ParseInputLazyPath(n,a,n.path,u)):null}).filter(a=>!!a);return n.common.async?Promise.all(o).then(a=>ParseStatus.mergeArray(t,a)):ParseStatus.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new ZodTuple({...this._def,rest:e})}}ZodTuple.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ZodTuple({items:s,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:t,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=[],o=this._def.keyType,a=this._def.valueType;for(const u in n.data)r.push({key:o._parse(new ParseInputLazyPath(n,u,n.path,u)),value:a._parse(new ParseInputLazyPath(n,n.data[u],n.path,u))});return n.common.async?ParseStatus.mergeObjectAsync(t,r):ParseStatus.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof ZodType?new ZodRecord({keyType:e,valueType:t,typeName:ZodFirstPartyTypeKind.ZodRecord,...processCreateParams(n)}):new ZodRecord({keyType:ZodString.create(),valueType:e,typeName:ZodFirstPartyTypeKind.ZodRecord,...processCreateParams(t)})}}class ZodMap extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ZodParsedType.map)return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.map,received:n.parsedType}),INVALID;const r=this._def.keyType,o=this._def.valueType,a=[...n.data.entries()].map(([u,d],h)=>({key:r._parse(new ParseInputLazyPath(n,u,n.path,[h,"key"])),value:o._parse(new ParseInputLazyPath(n,d,n.path,[h,"value"]))}));if(n.common.async){const u=new Map;return Promise.resolve().then(async()=>{for(const d of a){const h=await d.key,p=await d.value;if(h.status==="aborted"||p.status==="aborted")return INVALID;(h.status==="dirty"||p.status==="dirty")&&t.dirty(),u.set(h.value,p.value)}return{status:t.value,value:u}})}else{const u=new Map;for(const d of a){const h=d.key,p=d.value;if(h.status==="aborted"||p.status==="aborted")return INVALID;(h.status==="dirty"||p.status==="dirty")&&t.dirty(),u.set(h.value,p.value)}return{status:t.value,value:u}}}}ZodMap.create=(s,e,t)=>new ZodMap({valueType:e,keyType:s,typeName:ZodFirstPartyTypeKind.ZodMap,...processCreateParams(t)});class ZodSet extends ZodType{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ZodParsedType.set)return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.set,received:n.parsedType}),INVALID;const r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(addIssueToContext(n,{code:ZodIssueCode.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(addIssueToContext(n,{code:ZodIssueCode.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const o=this._def.valueType;function a(d){const h=new Set;for(const p of d){if(p.status==="aborted")return INVALID;p.status==="dirty"&&t.dirty(),h.add(p.value)}return{status:t.value,value:h}}const u=[...n.data.values()].map((d,h)=>o._parse(new ParseInputLazyPath(n,d,n.path,h)));return n.common.async?Promise.all(u).then(d=>a(d)):a(u)}min(e,t){return new ZodSet({...this._def,minSize:{value:e,message:errorUtil.toString(t)}})}max(e,t){return new ZodSet({...this._def,maxSize:{value:e,message:errorUtil.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ZodSet.create=(s,e)=>new ZodSet({valueType:s,minSize:null,maxSize:null,typeName:ZodFirstPartyTypeKind.ZodSet,...processCreateParams(e)});class ZodFunction extends ZodType{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ZodParsedType.function)return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.function,received:t.parsedType}),INVALID;function n(u,d){return makeIssue({data:u,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,getErrorMap(),errorMap].filter(h=>!!h),issueData:{code:ZodIssueCode.invalid_arguments,argumentsError:d}})}function r(u,d){return makeIssue({data:u,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,getErrorMap(),errorMap].filter(h=>!!h),issueData:{code:ZodIssueCode.invalid_return_type,returnTypeError:d}})}const o={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ZodPromise){const u=this;return OK(async function(...d){const h=new ZodError([]),p=await u._def.args.parseAsync(d,o).catch(c=>{throw h.addIssue(n(d,c)),h}),l=await Reflect.apply(a,this,p);return await u._def.returns._def.type.parseAsync(l,o).catch(c=>{throw h.addIssue(r(l,c)),h})})}else{const u=this;return OK(function(...d){const h=u._def.args.safeParse(d,o);if(!h.success)throw new ZodError([n(d,h.error)]);const p=Reflect.apply(a,this,h.data),l=u._def.returns.safeParse(p,o);if(!l.success)throw new ZodError([r(p,l.error)]);return l.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,t,n){return new ZodFunction({args:e||ZodTuple.create([]).rest(ZodUnknown.create()),returns:t||ZodUnknown.create(),typeName:ZodFirstPartyTypeKind.ZodFunction,...processCreateParams(n)})}}class ZodLazy extends ZodType{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ZodLazy.create=(s,e)=>new ZodLazy({getter:s,typeName:ZodFirstPartyTypeKind.ZodLazy,...processCreateParams(e)});class ZodLiteral extends ZodType{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{received:t.data,code:ZodIssueCode.invalid_literal,expected:this._def.value}),INVALID}return{status:"valid",value:e.data}}get value(){return this._def.value}}ZodLiteral.create=(s,e)=>new ZodLiteral({value:s,typeName:ZodFirstPartyTypeKind.ZodLiteral,...processCreateParams(e)});function createZodEnum(s,e){return new ZodEnum({values:s,typeName:ZodFirstPartyTypeKind.ZodEnum,...processCreateParams(e)})}class ZodEnum extends ZodType{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return addIssueToContext(t,{expected:util.joinValues(n),received:t.parsedType,code:ZodIssueCode.invalid_type}),INVALID}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return addIssueToContext(t,{received:t.data,code:ZodIssueCode.invalid_enum_value,options:n}),INVALID}return OK(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return ZodEnum.create(e)}exclude(e){return ZodEnum.create(this.options.filter(t=>!e.includes(t)))}}ZodEnum.create=createZodEnum;class ZodNativeEnum extends ZodType{_parse(e){const t=util.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ZodParsedType.string&&n.parsedType!==ZodParsedType.number){const r=util.objectValues(t);return addIssueToContext(n,{expected:util.joinValues(r),received:n.parsedType,code:ZodIssueCode.invalid_type}),INVALID}if(t.indexOf(e.data)===-1){const r=util.objectValues(t);return addIssueToContext(n,{received:n.data,code:ZodIssueCode.invalid_enum_value,options:r}),INVALID}return OK(e.data)}get enum(){return this._def.values}}ZodNativeEnum.create=(s,e)=>new ZodNativeEnum({values:s,typeName:ZodFirstPartyTypeKind.ZodNativeEnum,...processCreateParams(e)});class ZodPromise extends ZodType{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ZodParsedType.promise&&t.common.async===!1)return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.promise,received:t.parsedType}),INVALID;const n=t.parsedType===ZodParsedType.promise?t.data:Promise.resolve(t.data);return OK(n.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ZodPromise.create=(s,e)=>new ZodPromise({type:s,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:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,o={addIssue:a=>{addIssueToContext(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),r.type==="preprocess"){const a=r.transform(n.data,o);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(a).then(u=>this._def.schema._parseAsync({data:u,path:n.path,parent:n})):this._def.schema._parseSync({data:a,path:n.path,parent:n})}if(r.type==="refinement"){const a=u=>{const d=r.refinement(u,o);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return u};if(n.common.async===!1){const u=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return u.status==="aborted"?INVALID:(u.status==="dirty"&&t.dirty(),a(u.value),{status:t.value,value:u.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(u=>u.status==="aborted"?INVALID:(u.status==="dirty"&&t.dirty(),a(u.value).then(()=>({status:t.value,value:u.value}))))}if(r.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!isValid(a))return a;const u=r.transform(a.value,o);if(u instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:u}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>isValid(a)?Promise.resolve(r.transform(a.value,o)).then(u=>({status:t.value,value:u})):a);util.assertNever(r)}}ZodEffects.create=(s,e,t)=>new ZodEffects({schema:s,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:e,...processCreateParams(t)});ZodEffects.createWithPreprocess=(s,e,t)=>new ZodEffects({schema:e,effect:{type:"preprocess",transform:s},typeName:ZodFirstPartyTypeKind.ZodEffects,...processCreateParams(t)});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=(s,e)=>new ZodOptional({innerType:s,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=(s,e)=>new ZodNullable({innerType:s,typeName:ZodFirstPartyTypeKind.ZodNullable,...processCreateParams(e)});class ZodDefault extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===ZodParsedType.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ZodDefault.create=(s,e)=>new ZodDefault({innerType:s,typeName:ZodFirstPartyTypeKind.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...processCreateParams(e)});class ZodCatch extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return isAsync(r)?r.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new ZodError(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new ZodError(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ZodCatch.create=(s,e)=>new ZodCatch({innerType:s,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 n=this._getOrReturnCtx(e);return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.nan,received:n.parsedType}),INVALID}return{status:"valid",value:e.data}}}ZodNaN.create=s=>new ZodNaN({typeName:ZodFirstPartyTypeKind.ZodNaN,...processCreateParams(s)});const BRAND=Symbol("zod_brand");class ZodBranded extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class ZodPipeline extends ZodType{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?INVALID:o.status==="dirty"?(t.dirty(),DIRTY(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{const r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?INVALID:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,t){return new ZodPipeline({in:e,out:t,typeName:ZodFirstPartyTypeKind.ZodPipeline})}}class ZodReadonly extends ZodType{_parse(e){const t=this._def.innerType._parse(e);return isValid(t)&&(t.value=Object.freeze(t.value)),t}}ZodReadonly.create=(s,e)=>new ZodReadonly({innerType:s,typeName:ZodFirstPartyTypeKind.ZodReadonly,...processCreateParams(e)});const custom=(s,e={},t)=>s?ZodAny.create().superRefine((n,r)=>{var o,a;if(!s(n)){const u=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,d=(a=(o=u.fatal)!==null&&o!==void 0?o:t)!==null&&a!==void 0?a:!0,h=typeof u=="string"?{message:u}:u;r.addIssue({code:"custom",...h,fatal:d})}}):ZodAny.create(),late={object:ZodObject.lazycreate};var ZodFirstPartyTypeKind;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(ZodFirstPartyTypeKind||(ZodFirstPartyTypeKind={}));const instanceOfType=(s,e={message:`Input not instance of ${s.name}`})=>custom(t=>t instanceof s,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:s=>ZodString.create({...s,coerce:!0}),number:s=>ZodNumber.create({...s,coerce:!0}),boolean:s=>ZodBoolean.create({...s,coerce:!0}),bigint:s=>ZodBigInt.create({...s,coerce:!0}),date:s=>ZodDate.create({...s,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=s=>s.reduce((e,t)=>{var n;return t.dtype==="str"||t.dtype==="list"?e[t.name]=z.string():t.dtype==="int"||t.dtype==="float"?e[t.name]=z.number():e[t.name]=z.boolean(),t.required||(e[t.name]=(n=e[t.name])==null?void 0:n.optional()),e},{}),createSchemaFromFeatures=s=>z.object(mapInputsToValueType(s)),createFeature=s=>createObjectInputsSchema.parse(Object.values(s).map(t=>({...t,type:t.dtype,required:!1,label:t.name}))).map(t=>{var r;const n=(r=s[t.name])==null?void 0:r.value;return t.type==="list"?{...t,options:t.options,value:n}:{...t,value:n}}),mapShapeInputsToFeatures=(s,e)=>Object.entries(s).reduce((t,[n,r])=>{var o;return t[n]={name:n,dtype:(o=e.find(a=>a.name===n))==null?void 0:o.type,value:r},t},{}),addNewInput=(s,e,t,n)=>{s&&(e==="objects"||e==="main")&&(s[e][t]?s[e][t].values.includes(n)||s[e][t].values.push(n):s[e][t]={restricted:!1,values:[n]})},mapFeatureList=(s={restricted:!1,values:[]})=>(s.values??(s.values=[]),s.restricted??(s.restricted=!1),s.values.sort((e,t)=>e.localeCompare(t)).map(e=>({value:e,label:e})));function create_if_block_3$6(s){let e,t=s[0].value+"",n;return{c(){e=element("p"),n=text(t),this.h()},l(r){e=claim_element(r,"P",{class:!0});var o=children(e);n=claim_text(o,t),o.forEach(detach),this.h()},h(){attr(e,"class","first-letter:uppercase")},m(r,o){insert_hydration(r,e,o),append_hydration(e,n)},p(r,o){o&1&&t!==(t=r[0].value+"")&&set_data(n,t)},i:noop,o:noop,d(r){r&&detach(e)}}}function create_if_block$l(s){let e,t,n,r,o;const a=[create_if_block_2$8,create_else_block$5],u=[];function d(p,l){return p[0].type==="str"?0:1}e=d(s),t=u[e]=a[e](s);let h=s[3]&&create_if_block_1$c();return{c(){t.c(),n=space(),h&&h.c(),r=empty()},l(p){t.l(p),n=claim_space(p),h&&h.l(p),r=empty()},m(p,l){u[e].m(p,l),insert_hydration(p,n,l),h&&h.m(p,l),insert_hydration(p,r,l),o=!0},p(p,l){let i=e;e=d(p),e===i?u[e].p(p,l):(group_outros(),transition_out(u[i],1,1,()=>{u[i]=null}),check_outros(),t=u[e],t?t.p(p,l):(t=u[e]=a[e](p),t.c()),transition_in(t,1),t.m(n.parentNode,n)),p[3]?h?l&8&&transition_in(h,1):(h=create_if_block_1$c(),h.c(),transition_in(h,1),h.m(r.parentNode,r)):h&&(group_outros(),transition_out(h,1,1,()=>{h=null}),check_outros())},i(p){o||(transition_in(t),transition_in(h),o=!0)},o(p){transition_out(t),transition_out(h),o=!1},d(p){p&&(detach(n),detach(r)),u[e].d(p),h&&h.d(p)}}}function create_else_block$5(s){let e,t;return e=new Input({props:{value:s[0].value,type:"number",step:s[0].type==="int"?"1":"any"}}),e.$on("change",s[8]),e.$on("input",s[9]),e.$on("keyup",keyup_handler$1),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p(n,r){const o={};r&1&&(o.value=n[0].value),r&1&&(o.step=n[0].type==="int"?"1":"any"),e.$set(o)},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_if_block_2$8(s){var n,r,o;let e,t;return e=new AutoCompleteFeatureInput({props:{value:s[0].value,onTextInputChange:s[7],featureList:mapFeatureList((n=s[4].featuresList)==null?void 0:n[s[2]][s[0].name]),isInputEnabled:!((o=(r=s[4].featuresList)==null?void 0:r[s[2]][s[0].name])!=null&&o.restricted)}}),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,u){mount_component(e,a,u),t=!0},p(a,u){var h,p,l;const d={};u&1&&(d.value=a[0].value),u&1&&(d.onTextInputChange=a[7]),u&21&&(d.featureList=mapFeatureList((h=a[4].featuresList)==null?void 0:h[a[2]][a[0].name])),u&21&&(d.isInputEnabled=!((l=(p=a[4].featuresList)==null?void 0:p[a[2]][a[0].name])!=null&&l.restricted)),e.$set(d)},i(a){t||(transition_in(e.$$.fragment,a),t=!0)},o(a){transition_out(e.$$.fragment,a),t=!1},d(a){destroy_component(e,a)}}}function create_if_block_1$c(s){let e,t,n;return t=new Check_check({}),{c(){e=element("span"),create_component(t.$$.fragment),this.h()},l(r){e=claim_element(r,"SPAN",{class:!0});var o=children(e);claim_component(t.$$.fragment,o),o.forEach(detach),this.h()},h(){attr(e,"class","text-green-700")},m(r,o){insert_hydration(r,e,o),mount_component(t,e,null),n=!0},i(r){n||(transition_in(t.$$.fragment,r),n=!0)},o(r){transition_out(t.$$.fragment,r),n=!1},d(r){r&&detach(e),destroy_component(t)}}}function create_fragment$t(s){let e,t,n,r;const o=[create_if_block$l,create_if_block_3$6],a=[];function u(d,h){return d[1]?0:d[0].value||d[0].value===0?1:-1}return~(t=u(s))&&(n=a[t]=o[t](s)),{c(){e=element("div"),n&&n.c(),this.h()},l(d){e=claim_element(d,"DIV",{class:!0});var h=children(e);n&&n.l(h),h.forEach(detach),this.h()},h(){attr(e,"class","flex justify-start items-center gap-4")},m(d,h){insert_hydration(d,e,h),~t&&a[t].m(e,null),r=!0},p(d,[h]){let p=t;t=u(d),t===p?~t&&a[t].p(d,h):(n&&(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros()),~t?(n=a[t],n?n.p(d,h):(n=a[t]=o[t](d),n.c()),transition_in(n,1),n.m(e,null)):n=null)},i(d){r||(transition_in(n),r=!0)},o(d){transition_out(n),r=!1},d(d){d&&detach(e),~t&&a[t].d()}}}const keyup_handler$1=s=>s.stopPropagation();function instance$x(s,e,t){let n;component_subscribe(s,itemMetas,c=>t(4,n=c));let{feature:r}=e,{isEditing:o}=e,{saveInputChange:a}=e,{featureClass:u}=e,d=!1;const h=(c,f)=>{let g=c;r.type==="int"?g=Math.round(Number(c)):r.type==="float"&&(g=Number(c)),typeof g=="string"&&addNewInput(n.featuresList,u,f,g),a(g,f),t(3,d=!0)},p=c=>h(c,r.name),l=c=>h(c.currentTarget.value,r.name),i=()=>t(3,d=!1);return s.$$set=c=>{"feature"in c&&t(0,r=c.feature),"isEditing"in c&&t(1,o=c.isEditing),"saveInputChange"in c&&t(6,a=c.saveInputChange),"featureClass"in c&&t(2,u=c.featureClass)},[r,o,u,d,n,h,a,p,l,i]}class TextFeatureInput extends SvelteComponent{constructor(e){super(),init(this,e,instance$x,create_fragment$t,safe_not_equal,{feature:0,isEditing:1,saveInputChange:6,featureClass:2})}}function create_if_block_1$b(s){let e,t=s[0].value+"",n;return{c(){e=element("p"),n=text(t),this.h()},l(r){e=claim_element(r,"P",{class:!0});var o=children(e);n=claim_text(o,t),o.forEach(detach),this.h()},h(){attr(e,"class","first-letter:uppercase")},m(r,o){insert_hydration(r,e,o),append_hydration(e,n)},p(r,o){o&1&&t!==(t=r[0].value+"")&&set_data(n,t)},i:noop,o:noop,d(r){r&&detach(e)}}}function create_if_block$k(s){let e,t;return e=new Combobox({props:{placeholder:`Select a ${s[0].name}`,listItems:s[0].options,saveValue:s[3],value:s[0].value}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p(n,r){const o={};r&1&&(o.placeholder=`Select a ${n[0].name}`),r&1&&(o.listItems=n[0].options),r&5&&(o.saveValue=n[3]),r&1&&(o.value=n[0].value),e.$set(o)},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_fragment$s(s){let e,t,n,r;const o=[create_if_block$k,create_if_block_1$b],a=[];function u(d,h){return d[1]?0:d[0].value?1:-1}return~(e=u(s))&&(t=a[e]=o[e](s)),{c(){t&&t.c(),n=empty()},l(d){t&&t.l(d),n=empty()},m(d,h){~e&&a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,[h]){let p=e;e=u(d),e===p?~e&&a[e].p(d,h):(t&&(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros()),~e?(t=a[e],t?t.p(d,h):(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n)):t=null)},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),~e&&a[e].d(d)}}}function instance$w(s,e,t){let{listFeature:n}=e,{isEditing:r}=e,{handleInputChange:o}=e;const a=u=>o(u,n.name);return s.$$set=u=>{"listFeature"in u&&t(0,n=u.listFeature),"isEditing"in u&&t(1,r=u.isEditing),"handleInputChange"in u&&t(2,o=u.handleInputChange)},[n,r,o,a]}class SelectFeatureInput extends SvelteComponent{constructor(e){super(),init(this,e,instance$w,create_fragment$s,safe_not_equal,{listFeature:0,isEditing:1,handleInputChange:2})}}function get_each_context$5(s,e,t){const n=s.slice();return n[6]=e[t],n}function create_if_block_3$5(s){let e,t=s[6].label.replace("_"," ")+"",n;return{c(){e=element("p"),n=text(t),this.h()},l(r){e=claim_element(r,"P",{class:!0});var o=children(e);n=claim_text(o,t),o.forEach(detach),this.h()},h(){attr(e,"class","font-medium first-letter:uppercase flex items-center")},m(r,o){insert_hydration(r,e,o),append_hydration(e,n)},p(r,o){o&1&&t!==(t=r[6].label.replace("_"," ")+"")&&set_data(n,t)},d(r){r&&detach(e)}}}function create_if_block_2$7(s){let e,t;function n(...r){return s[4](s[6],...r)}return e=new Checkbox({props:{checked:!!s[6].value,disabled:!s[2],handleClick:n}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,o){mount_component(e,r,o),t=!0},p(r,o){s=r;const a={};o&1&&(a.checked=!!s[6].value),o&4&&(a.disabled=!s[2]),o&9&&(a.handleClick=n),e.$set(a)},i(r){t||(transition_in(e.$$.fragment,r),t=!0)},o(r){transition_out(e.$$.fragment,r),t=!1},d(r){destroy_component(e,r)}}}function create_if_block_1$a(s){let e,t;return e=new SelectFeatureInput({props:{isEditing:s[2],handleInputChange:s[5],listFeature:{value:s[6].value,name:s[6].name,options:s[6].options}}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p(n,r){const o={};r&4&&(o.isEditing=n[2]),r&8&&(o.handleInputChange=n[5]),r&1&&(o.listFeature={value:n[6].value,name:n[6].name,options:n[6].options}),e.$set(o)},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_if_block$j(s){let e,t;return e=new TextFeatureInput({props:{featureClass:s[1],feature:s[6],saveInputChange:s[3],isEditing:s[2]}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p(n,r){const o={};r&2&&(o.featureClass=n[1]),r&1&&(o.feature=n[6]),r&8&&(o.saveInputChange=n[3]),r&4&&(o.isEditing=n[2]),e.$set(o)},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_each_block$5(s){let e,t,n,r,o,a,u=(s[2]||s[6].value!==void 0)&&create_if_block_3$5(s),d=s[6].type==="bool"&&(s[6].value!==void 0||s[2])&&create_if_block_2$7(s),h=s[6].type==="list"&&create_if_block_1$a(s),p=(s[6].type==="str"||s[6].type==="int"||s[6].type==="float")&&create_if_block$j(s);return{c(){e=element("div"),u&&u.c(),t=space(),d&&d.c(),n=space(),h&&h.c(),r=space(),p&&p.c(),o=space(),this.h()},l(l){e=claim_element(l,"DIV",{class:!0});var i=children(e);u&&u.l(i),t=claim_space(i),d&&d.l(i),n=claim_space(i),h&&h.l(i),r=claim_space(i),p&&p.l(i),o=claim_space(i),i.forEach(detach),this.h()},h(){attr(e,"class","grid gap-4 grid-cols-[150px_auto] mt-2 pr-4")},m(l,i){insert_hydration(l,e,i),u&&u.m(e,null),append_hydration(e,t),d&&d.m(e,null),append_hydration(e,n),h&&h.m(e,null),append_hydration(e,r),p&&p.m(e,null),append_hydration(e,o),a=!0},p(l,i){l[2]||l[6].value!==void 0?u?u.p(l,i):(u=create_if_block_3$5(l),u.c(),u.m(e,t)):u&&(u.d(1),u=null),l[6].type==="bool"&&(l[6].value!==void 0||l[2])?d?(d.p(l,i),i&5&&transition_in(d,1)):(d=create_if_block_2$7(l),d.c(),transition_in(d,1),d.m(e,n)):d&&(group_outros(),transition_out(d,1,1,()=>{d=null}),check_outros()),l[6].type==="list"?h?(h.p(l,i),i&1&&transition_in(h,1)):(h=create_if_block_1$a(l),h.c(),transition_in(h,1),h.m(e,r)):h&&(group_outros(),transition_out(h,1,1,()=>{h=null}),check_outros()),l[6].type==="str"||l[6].type==="int"||l[6].type==="float"?p?(p.p(l,i),i&1&&transition_in(p,1)):(p=create_if_block$j(l),p.c(),transition_in(p,1),p.m(e,o)):p&&(group_outros(),transition_out(p,1,1,()=>{p=null}),check_outros())},i(l){a||(transition_in(d),transition_in(h),transition_in(p),a=!0)},o(l){transition_out(d),transition_out(h),transition_out(p),a=!1},d(l){l&&detach(e),u&&u.d(),d&&d.d(),h&&h.d(),p&&p.d()}}}function create_fragment$r(s){let e,t,n=ensure_array_like(s[0]),r=[];for(let a=0;a<n.length;a+=1)r[a]=create_each_block$5(get_each_context$5(s,n,a));const o=a=>transition_out(r[a],1,1,()=>{r[a]=null});return{c(){for(let a=0;a<r.length;a+=1)r[a].c();e=empty()},l(a){for(let u=0;u<r.length;u+=1)r[u].l(a);e=empty()},m(a,u){for(let d=0;d<r.length;d+=1)r[d]&&r[d].m(a,u);insert_hydration(a,e,u),t=!0},p(a,[u]){if(u&15){n=ensure_array_like(a[0]);let d;for(d=0;d<n.length;d+=1){const h=get_each_context$5(a,n,d);r[d]?(r[d].p(h,u),transition_in(r[d],1)):(r[d]=create_each_block$5(h),r[d].c(),transition_in(r[d],1),r[d].m(e.parentNode,e))}for(group_outros(),d=n.length;d<r.length;d+=1)o(d);check_outros()}},i(a){if(!t){for(let u=0;u<n.length;u+=1)transition_in(r[u]);t=!0}},o(a){r=r.filter(Boolean);for(let u=0;u<r.length;u+=1)transition_out(r[u]);t=!1},d(a){a&&detach(e),destroy_each(r,a)}}}function instance$v(s,e,t){let{features:n}=e,{featureClass:r}=e,{isEditing:o}=e,{saveInputChange:a}=e;const u=(h,p)=>a(p,h.name),d=(h,p)=>a(h,p);return s.$$set=h=>{"features"in h&&t(0,n=h.features),"featureClass"in h&&t(1,r=h.featureClass),"isEditing"in h&&t(2,o=h.isEditing),"saveInputChange"in h&&t(3,a=h.saveInputChange)},[n,r,o,a,u,d]}class UpdateFeatureInputs extends SvelteComponent{constructor(e){super(),init(this,e,instance$v,create_fragment$r,safe_not_equal,{features:0,featureClass:1,isEditing:2,saveInputChange:3})}}function get_each_context$4(s,e,t){const n=s.slice();return n[5]=e[t],n}function create_default_slot$d(s){let e,t;return e=new Pencil({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p:noop,i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_each_block$4(s){let e,t=s[5].id+"",n,r,o,a,u,d="File name",h,p,l=s[5].fileName+"",i,c,f,g,m,_="Width",b,v,T=s[5].width+"",y,S,w,k,P="Height",I,F,C=s[5].height+"",E,$,x,A,L="Format",B,H,J=s[5].format+"",X,ee;return{c(){e=element("h3"),n=text(t),r=space(),o=element("div"),a=element("div"),u=element("p"),u.textContent=d,h=space(),p=element("p"),i=text(l),f=space(),g=element("div"),m=element("p"),m.textContent=_,b=space(),v=element("p"),y=text(T),S=space(),w=element("div"),k=element("p"),k.textContent=P,I=space(),F=element("p"),E=text(C),$=space(),x=element("div"),A=element("p"),A.textContent=L,B=space(),H=element("p"),X=text(J),ee=space(),this.h()},l(Q){e=claim_element(Q,"H3",{class:!0});var re=children(e);n=claim_text(re,t),re.forEach(detach),r=claim_space(Q),o=claim_element(Q,"DIV",{class:!0});var oe=children(o);a=claim_element(oe,"DIV",{class:!0});var ce=children(a);u=claim_element(ce,"P",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(u)!=="svelte-26li1s"&&(u.textContent=d),h=claim_space(ce),p=claim_element(ce,"P",{class:!0,title:!0});var fe=children(p);i=claim_text(fe,l),fe.forEach(detach),ce.forEach(detach),f=claim_space(oe),g=claim_element(oe,"DIV",{class:!0});var ge=children(g);m=claim_element(ge,"P",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(m)!=="svelte-uc7myb"&&(m.textContent=_),b=claim_space(ge),v=claim_element(ge,"P",{});var we=children(v);y=claim_text(we,T),we.forEach(detach),ge.forEach(detach),S=claim_space(oe),w=claim_element(oe,"DIV",{class:!0});var xe=children(w);k=claim_element(xe,"P",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(k)!=="svelte-zdyg3w"&&(k.textContent=P),I=claim_space(xe),F=claim_element(xe,"P",{});var _e=children(F);E=claim_text(_e,C),_e.forEach(detach),xe.forEach(detach),$=claim_space(oe),x=claim_element(oe,"DIV",{class:!0});var ye=children(x);A=claim_element(ye,"P",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(A)!=="svelte-1dszlb8"&&(A.textContent=L),B=claim_space(ye),H=claim_element(ye,"P",{});var pe=children(H);X=claim_text(pe,J),pe.forEach(detach),ye.forEach(detach),ee=claim_space(oe),oe.forEach(detach),this.h()},h(){attr(e,"class","uppercase font-medium h-10 flex items-center"),attr(u,"class","font-medium first-letter:uppercase"),attr(p,"class","truncate"),attr(p,"title",c=s[5].fileName),attr(a,"class","grid gap-4 grid-cols-[150px_auto] mt-2"),attr(m,"class","font-medium first-letter:uppercase"),attr(g,"class","grid gap-4 grid-cols-[150px_auto] mt-2"),attr(k,"class","font-medium first-letter:uppercase"),attr(w,"class","grid gap-4 grid-cols-[150px_auto] mt-2"),attr(A,"class","font-medium first-letter:uppercase"),attr(x,"class","grid gap-4 grid-cols-[150px_auto] mt-2"),attr(o,"class","mx-4 mb-4")},m(Q,re){insert_hydration(Q,e,re),append_hydration(e,n),insert_hydration(Q,r,re),insert_hydration(Q,o,re),append_hydration(o,a),append_hydration(a,u),append_hydration(a,h),append_hydration(a,p),append_hydration(p,i),append_hydration(o,f),append_hydration(o,g),append_hydration(g,m),append_hydration(g,b),append_hydration(g,v),append_hydration(v,y),append_hydration(o,S),append_hydration(o,w),append_hydration(w,k),append_hydration(w,I),append_hydration(w,F),append_hydration(F,E),append_hydration(o,$),append_hydration(o,x),append_hydration(x,A),append_hydration(x,B),append_hydration(x,H),append_hydration(H,X),append_hydration(o,ee)},p(Q,re){re&2&&t!==(t=Q[5].id+"")&&set_data(n,t),re&2&&l!==(l=Q[5].fileName+"")&&set_data(i,l),re&2&&c!==(c=Q[5].fileName)&&attr(p,"title",c),re&2&&T!==(T=Q[5].width+"")&&set_data(y,T),re&2&&C!==(C=Q[5].height+"")&&set_data(E,C),re&2&&J!==(J=Q[5].format+"")&&set_data(X,J)},d(Q){Q&&(detach(e),detach(r),detach(o))}}}function create_fragment$q(s){let e,t,n,r="Features",o,a,u,d,h,p,l,i;a=new TooltipIconButton({props:{selected:s[2],tooltipContent:"Edit scene features",$$slots:{default:[create_default_slot$d]},$$scope:{ctx:s}}}),a.$on("click",s[3]),h=new UpdateFeatureInputs({props:{featureClass:"main",features:s[0],isEditing:s[2],saveInputChange:s[4]}});let c=ensure_array_like(s[1]),f=[];for(let g=0;g<c.length;g+=1)f[g]=create_each_block$4(get_each_context$4(s,c,g));return{c(){e=element("div"),t=element("h3"),n=element("span"),n.textContent=r,o=space(),create_component(a.$$.fragment),u=space(),d=element("div"),create_component(h.$$.fragment),p=space(),l=element("div");for(let g=0;g<f.length;g+=1)f[g].c();this.h()},l(g){e=claim_element(g,"DIV",{class:!0});var m=children(e);t=claim_element(m,"H3",{class:!0});var _=children(t);n=claim_element(_,"SPAN",{"data-svelte-h":!0}),get_svelte_dataset(n)!=="svelte-sapa9p"&&(n.textContent=r),o=claim_space(_),claim_component(a.$$.fragment,_),_.forEach(detach),u=claim_space(m),d=claim_element(m,"DIV",{class:!0});var b=children(d);claim_component(h.$$.fragment,b),b.forEach(detach),m.forEach(detach),p=claim_space(g),l=claim_element(g,"DIV",{class:!0});var v=children(l);for(let T=0;T<f.length;T+=1)f[T].l(v);v.forEach(detach),this.h()},h(){attr(t,"class","uppercase font-medium h-10"),attr(d,"class","mx-4"),attr(e,"class","border-b-2 border-b-slate-500 p-4 pb-8 text-slate-800"),attr(l,"class","p-4 text-slate-800")},m(g,m){insert_hydration(g,e,m),append_hydration(e,t),append_hydration(t,n),append_hydration(t,o),mount_component(a,t,null),append_hydration(e,u),append_hydration(e,d),mount_component(h,d,null),insert_hydration(g,p,m),insert_hydration(g,l,m);for(let _=0;_<f.length;_+=1)f[_]&&f[_].m(l,null);i=!0},p(g,[m]){const _={};m&4&&(_.selected=g[2]),m&256&&(_.$$scope={dirty:m,ctx:g}),a.$set(_);const b={};if(m&1&&(b.features=g[0]),m&4&&(b.isEditing=g[2]),h.$set(b),m&2){c=ensure_array_like(g[1]);let v;for(v=0;v<c.length;v+=1){const T=get_each_context$4(g,c,v);f[v]?f[v].p(T,m):(f[v]=create_each_block$4(T),f[v].c(),f[v].m(l,null))}for(;v<f.length;v+=1)f[v].d(1);f.length=c.length}},i(g){i||(transition_in(a.$$.fragment,g),transition_in(h.$$.fragment,g),i=!0)},o(g){transition_out(a.$$.fragment,g),transition_out(h.$$.fragment,g),i=!1},d(g){g&&(detach(e),detach(p),detach(l)),destroy_component(a),destroy_component(h),destroy_each(f,g)}}}function instance$u(s,e,t){let n,r=[],o=!1;return itemMetas.subscribe(d=>{t(1,r=Object.values(d.views||{}).map(p=>{var l;return{fileName:p.uri.split("/").at(-1),width:p.features.width.value,height:p.features.height.value,format:(l=p.uri.split(".").at(-1))==null?void 0:l.toUpperCase(),id:p.id}}));const h=Object.values(d.mainFeatures).length?d.mainFeatures:defaultSceneFeatures;t(0,n=createFeature(h))}),[n,r,o,()=>{t(2,o=!o)},(d,h)=>{itemMetas.update(p=>{var i;const l={...p};return l.mainFeatures={...l.mainFeatures,[h]:{...((i=l.mainFeatures)==null?void 0:i[h])||defaultSceneFeatures[h],value:d}},l}),canSave.set(!0)}]}class SceneInspector extends SvelteComponent{constructor(e){super(),init(this,e,instance$u,create_fragment$q,safe_not_equal,{})}}function create_else_block$4(s){let e,t;return e=new Eye_off({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_if_block_4$3(s){let e,t;return e=new Eye({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_default_slot_3$2(s){let e,t,n,r;const o=[create_if_block_4$3,create_else_block$4],a=[];function u(d,h){return d[7]?0:1}return e=u(s),t=a[e]=o[e](s),{c(){t.c(),n=empty()},l(d){t.l(d),n=empty()},m(d,h){a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,h){let p=e;e=u(d),e!==p&&(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),t=a[e],t||(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n))},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),a[e].d(d)}}}function create_if_block_3$4(s){let e,t,n,r;return e=new TooltipIconButton({props:{tooltipContent:"Edit object",selected:s[4],$$slots:{default:[create_default_slot_2$2]},$$scope:{ctx:s}}}),e.$on("click",s[13]),n=new TooltipIconButton({props:{tooltipContent:"Delete object",$$slots:{default:[create_default_slot_1$5]},$$scope:{ctx:s}}}),n.$on("click",s[10]),{c(){create_component(e.$$.fragment),t=space(),create_component(n.$$.fragment)},l(o){claim_component(e.$$.fragment,o),t=claim_space(o),claim_component(n.$$.fragment,o)},m(o,a){mount_component(e,o,a),insert_hydration(o,t,a),mount_component(n,o,a),r=!0},p(o,a){const u={};a&16&&(u.selected=o[4]),a&8388608&&(u.$$scope={dirty:a,ctx:o}),e.$set(u);const d={};a&8388608&&(d.$$scope={dirty:a,ctx:o}),n.$set(d)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(n.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(n.$$.fragment,o),r=!1},d(o){o&&detach(t),destroy_component(e,o),destroy_component(n,o)}}}function create_default_slot_2$2(s){let e,t;return e=new Pencil({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p:noop,i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_default_slot_1$5(s){let e,t;return e=new Trash_2({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p:noop,i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_default_slot$c(s){let e,t;return e=new ChevronRight({props:{class:cn("transition",{"rotate-90":s[2]}),strokeWidth:1}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p(n,r){const o={};r&4&&(o.class=cn("transition",{"rotate-90":n[2]})),e.$set(o)},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_if_block$i(s){let e,t,n,r,o,a="display",u,d,h,p,l,i,c=s[0].bbox&&create_if_block_2$6(s),f=s[0].mask&&create_if_block_1$9(s);return l=new UpdateFeatureInputs({props:{featureClass:"objects",features:s[8],isEditing:s[4],saveInputChange:s[11]}}),{c(){e=element("div"),t=element("div"),n=element("div"),r=element("div"),o=element("p"),o.textContent=a,u=space(),d=element("div"),c&&c.c(),h=space(),f&&f.c(),p=space(),create_component(l.$$.fragment),this.h()},l(g){e=claim_element(g,"DIV",{class:!0});var m=children(e);t=claim_element(m,"DIV",{class:!0,style:!0});var _=children(t);n=claim_element(_,"DIV",{class:!0});var b=children(n);r=claim_element(b,"DIV",{});var v=children(r);o=claim_element(v,"P",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(o)!=="svelte-1t2n1td"&&(o.textContent=a),u=claim_space(v),d=claim_element(v,"DIV",{class:!0});var T=children(d);c&&c.l(T),h=claim_space(T),f&&f.l(T),T.forEach(detach),v.forEach(detach),p=claim_space(b),claim_component(l.$$.fragment,b),b.forEach(detach),_.forEach(detach),m.forEach(detach),this.h()},h(){attr(o,"class","font-medium first-letter:uppercase"),attr(d,"class","flex gap-4"),attr(n,"class","flex flex-col gap-2"),attr(t,"class","border-l-4 border-dashed border-red-400 pl-4 pb-4 pt-4 flex flex-col gap-4"),set_style(t,"border-color",s[1]),attr(e,"class","pl-5 border-b border-b-slate-600 text-slate-800 bg-white")},m(g,m){insert_hydration(g,e,m),append_hydration(e,t),append_hydration(t,n),append_hydration(n,r),append_hydration(r,o),append_hydration(r,u),append_hydration(r,d),c&&c.m(d,null),append_hydration(d,h),f&&f.m(d,null),append_hydration(n,p),mount_component(l,n,null),i=!0},p(g,m){g[0].bbox?c?(c.p(g,m),m&1&&transition_in(c,1)):(c=create_if_block_2$6(g),c.c(),transition_in(c,1),c.m(d,h)):c&&(group_outros(),transition_out(c,1,1,()=>{c=null}),check_outros()),g[0].mask?f?(f.p(g,m),m&1&&transition_in(f,1)):(f=create_if_block_1$9(g),f.c(),transition_in(f,1),f.m(d,null)):f&&(group_outros(),transition_out(f,1,1,()=>{f=null}),check_outros());const _={};m&256&&(_.features=g[8]),m&16&&(_.isEditing=g[4]),l.$set(_),(!i||m&2)&&set_style(t,"border-color",g[1])},i(g){i||(transition_in(c),transition_in(f),transition_in(l.$$.fragment,g),i=!0)},o(g){transition_out(c),transition_out(f),transition_out(l.$$.fragment,g),i=!1},d(g){g&&detach(e),c&&c.d(),f&&f.d(),destroy_component(l)}}}function create_if_block_2$6(s){let e,t,n="Box",r,o,a,u;function d(p){s[18](p)}let h={handleClick:s[17],title:s[6]?"Hide":"Show",class:"mx-1"};return s[6]!==void 0&&(h.checked=s[6]),o=new Checkbox({props:h}),binding_callbacks.push(()=>bind(o,"checked",d)),{c(){e=element("div"),t=element("p"),t.textContent=n,r=space(),create_component(o.$$.fragment),this.h()},l(p){e=claim_element(p,"DIV",{class:!0});var l=children(e);t=claim_element(l,"P",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(t)!=="svelte-lhqu05"&&(t.textContent=n),r=claim_space(l),claim_component(o.$$.fragment,l),l.forEach(detach),this.h()},h(){attr(t,"class","font-light first-letter:uppercase"),attr(e,"class","flex gap-2 mt-2 items-center")},m(p,l){insert_hydration(p,e,l),append_hydration(e,t),append_hydration(e,r),mount_component(o,e,null),u=!0},p(p,l){const i={};l&64&&(i.handleClick=p[17]),l&64&&(i.title=p[6]?"Hide":"Show"),!a&&l&64&&(a=!0,i.checked=p[6],add_flush_callback(()=>a=!1)),o.$set(i)},i(p){u||(transition_in(o.$$.fragment,p),u=!0)},o(p){transition_out(o.$$.fragment,p),u=!1},d(p){p&&detach(e),destroy_component(o)}}}function create_if_block_1$9(s){let e,t,n="Mask",r,o,a,u;function d(p){s[20](p)}let h={handleClick:s[19],title:s[5]?"Hide":"Show",class:"mx-1"};return s[5]!==void 0&&(h.checked=s[5]),o=new Checkbox({props:h}),binding_callbacks.push(()=>bind(o,"checked",d)),{c(){e=element("div"),t=element("p"),t.textContent=n,r=space(),create_component(o.$$.fragment),this.h()},l(p){e=claim_element(p,"DIV",{class:!0});var l=children(e);t=claim_element(l,"P",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(t)!=="svelte-21ke58"&&(t.textContent=n),r=claim_space(l),claim_component(o.$$.fragment,l),l.forEach(detach),this.h()},h(){attr(t,"class","font-light first-letter:uppercase"),attr(e,"class","flex gap-2 mt-2 items-center")},m(p,l){insert_hydration(p,e,l),append_hydration(e,t),append_hydration(e,r),mount_component(o,e,null),u=!0},p(p,l){const i={};l&32&&(i.handleClick=p[19]),l&32&&(i.title=p[5]?"Hide":"Show"),!a&&l&32&&(a=!0,i.checked=p[5],add_flush_callback(()=>a=!1)),o.$set(i)},i(p){u||(transition_in(o.$$.fragment,p),u=!0)},o(p){transition_out(o.$$.fragment,p),u=!1},d(p){p&&detach(e),destroy_component(o)}}}function create_fragment$p(s){let e,t,n,r,o,a,u,d,h=s[0].id+"",p,l,i,c,f,g,m,_,b,v;r=new TooltipIconButton({props:{tooltipContent:s[7]?"Hide object":"Show object",$$slots:{default:[create_default_slot_3$2]},$$scope:{ctx:s}}}),r.$on("click",s[15]);let T=(s[3]||s[4])&&create_if_block_3$4(s);f=new TooltipIconButton({props:{tooltipContent:s[2]?"Hide features":"Show features",$$slots:{default:[create_default_slot$c]},$$scope:{ctx:s}}}),f.$on("click",s[16]);let y=s[2]&&create_if_block$i(s);return{c(){e=element("article"),t=element("div"),n=element("div"),create_component(r.$$.fragment),o=space(),a=element("button"),u=space(),d=element("span"),p=text(h),l=space(),i=element("div"),T&&T.c(),c=space(),create_component(f.$$.fragment),g=space(),y&&y.c(),this.h()},l(S){e=claim_element(S,"ARTICLE",{id:!0});var w=children(e);t=claim_element(w,"DIV",{class:!0,style:!0});var k=children(t);n=claim_element(k,"DIV",{class:!0});var P=children(n);claim_component(r.$$.fragment,P),o=claim_space(P),a=claim_element(P,"BUTTON",{class:!0,style:!0,title:!0}),children(a).forEach(detach),u=claim_space(P),d=claim_element(P,"SPAN",{class:!0});var I=children(d);p=claim_text(I,h),I.forEach(detach),P.forEach(detach),l=claim_space(k),i=claim_element(k,"DIV",{class:!0});var F=children(i);T&&T.l(F),c=claim_space(F),claim_component(f.$$.fragment,F),F.forEach(detach),k.forEach(detach),g=claim_space(w),y&&y.l(w),w.forEach(detach),this.h()},h(){attr(a,"class","rounded-full border w-3 h-3 mr-2 flex-[0_0_0.75rem]"),set_style(a,"background",s[1]),attr(a,"title","Highlight object"),attr(d,"class","truncate w-max flex-auto"),attr(n,"class","flex items-center flex-auto max-w-[50%]"),attr(i,"class","flex items-center"),attr(t,"class",cn("flex items-center mt-1  rounded justify-between text-slate-800 bg-white border-2 ")),set_style(t,"border-color",s[0].highlighted==="self"?s[1]:"transparent"),attr(e,"id",m=createObjectCardId(s[0]))},m(S,w){insert_hydration(S,e,w),append_hydration(e,t),append_hydration(t,n),mount_component(r,n,null),append_hydration(n,o),append_hydration(n,a),append_hydration(n,u),append_hydration(n,d),append_hydration(d,p),append_hydration(t,l),append_hydration(t,i),T&&T.m(i,null),append_hydration(i,c),mount_component(f,i,null),append_hydration(e,g),y&&y.m(e,null),_=!0,b||(v=[listen(a,"click",s[12]),listen(e,"mouseenter",s[21]),listen(e,"mouseleave",s[22])],b=!0)},p(S,[w]){const k={};w&128&&(k.tooltipContent=S[7]?"Hide object":"Show object"),w&8388736&&(k.$$scope={dirty:w,ctx:S}),r.$set(k),(!_||w&2)&&set_style(a,"background",S[1]),(!_||w&1)&&h!==(h=S[0].id+"")&&set_data(p,h),S[3]||S[4]?T?(T.p(S,w),w&24&&transition_in(T,1)):(T=create_if_block_3$4(S),T.c(),transition_in(T,1),T.m(i,c)):T&&(group_outros(),transition_out(T,1,1,()=>{T=null}),check_outros());const P={};w&4&&(P.tooltipContent=S[2]?"Hide features":"Show features"),w&8388612&&(P.$$scope={dirty:w,ctx:S}),f.$set(P),(!_||w&3)&&set_style(t,"border-color",S[0].highlighted==="self"?S[1]:"transparent"),S[2]?y?(y.p(S,w),w&4&&transition_in(y,1)):(y=create_if_block$i(S),y.c(),transition_in(y,1),y.m(e,null)):y&&(group_outros(),transition_out(y,1,1,()=>{y=null}),check_outros()),(!_||w&1&&m!==(m=createObjectCardId(S[0])))&&attr(e,"id",m)},i(S){_||(transition_in(r.$$.fragment,S),transition_in(T),transition_in(f.$$.fragment,S),transition_in(y),_=!0)},o(S){transition_out(r.$$.fragment,S),transition_out(T),transition_out(f.$$.fragment,S),transition_out(y),_=!1},d(S){S&&detach(e),destroy_component(r),T&&T.d(),destroy_component(f),y&&y.d(),b=!1,run_all(v)}}}function instance$t(s,e,t){let n,r,o,a,u,{itemObject:d}=e,{colorScale:h}=e,p,l=!1,i=!1;const c=(I,F,C=["bbox","mask"])=>{itemObjects.update(E=>E.map($=>(I==="editing"&&($.displayControl={...$.displayControl,editing:!1}),$.id===d.id&&($=toggleObjectDisplayControl($,I,C,F)),F&&d.highlighted==="self"&&($.highlighted="all"),$)))},f=()=>{itemObjects.update(I=>I.filter(F=>F.id!==d.id)),canSave.set(!0)},g=(I,F)=>{itemObjects.update(C=>C.map(E=>(E.id===d.id&&(E.features={...E.features,[F]:{...E.features[F],value:I}}),E))),canSave.set(!0)},m=()=>{const I=d.highlighted==="self";itemObjects.update(F=>F.map(C=>(I?C.highlighted="all":C.id===d.id?C.highlighted="self":C.highlighted="none",C)))},_=()=>{c("editing",!r),t(2,l=!0),!r&&selectedTool.set(panTool)},b=()=>c("hidden",o),v=()=>t(2,l=!l),T=()=>c("hidden",a,["bbox"]);function y(I){a=I,t(6,a),t(0,d)}const S=()=>c("hidden",u,["mask"]);function w(I){u=I,t(5,u),t(0,d)}const k=()=>t(3,i=!0),P=()=>t(3,i=l);return s.$$set=I=>{"itemObject"in I&&t(0,d=I.itemObject),"colorScale"in I&&t(14,h=I.colorScale)},s.$$.update=()=>{var I,F,C,E,$,x;s.$$.dirty&1&&t(8,n=createFeature(d.features)),s.$$.dirty&16385&&t(1,p=h(d.id)),s.$$.dirty&1&&t(4,r=((I=d.displayControl)==null?void 0:I.editing)||!1),s.$$.dirty&1&&t(7,o=!((F=d.displayControl)!=null&&F.hidden)),s.$$.dirty&1&&t(6,a=!((E=(C=d.bbox)==null?void 0:C.displayControl)!=null&&E.hidden)),s.$$.dirty&1&&t(5,u=!((x=($=d.mask)==null?void 0:$.displayControl)!=null&&x.hidden))},[d,p,l,i,r,u,a,o,n,c,f,g,m,_,h,b,v,T,y,S,w,k,P]}class ObjectCard extends SvelteComponent{constructor(e){super(),init(this,e,instance$t,create_fragment$p,safe_not_equal,{itemObject:0,colorScale:14})}}const get_modelSelection_slot_changes=s=>({}),get_modelSelection_slot_context=s=>({});function create_else_block$3(s){let e,t;return e=new Eye({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_if_block$h(s){let e,t;return e=new Eye_off({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_default_slot$b(s){let e,t,n,r;const o=[create_if_block$h,create_else_block$3],a=[];function u(d,h){return d[2]==="hidden"?0:1}return e=u(s),t=a[e]=o[e](s),{c(){t.c(),n=empty()},l(d){t.l(d),n=empty()},m(d,h){a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,h){let p=e;e=u(d),e!==p&&(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),t=a[e],t||(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n))},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),a[e].d(d)}}}function create_fragment$o(s){let e,t,n,r,o,a,u,d,h,p,l,i,c,f;r=new TooltipIconButton({props:{tooltipContent:s[3],$$slots:{default:[create_default_slot$b]},$$scope:{ctx:s}}}),r.$on("click",s[4]);const g=s[6].modelSelection,m=create_slot(g,s,s[7],get_modelSelection_slot_context),_=s[6].default,b=create_slot(_,s,s[7],null);return{c(){e=element("section"),t=element("div"),n=element("div"),create_component(r.$$.fragment),o=space(),a=element("h3"),u=text(s[0]),d=space(),m&&m.c(),h=space(),p=element("p"),l=text(s[1]),i=space(),c=element("div"),b&&b.c(),this.h()},l(v){e=claim_element(v,"SECTION",{class:!0});var T=children(e);t=claim_element(T,"DIV",{class:!0});var y=children(t);n=claim_element(y,"DIV",{class:!0});var S=children(n);claim_component(r.$$.fragment,S),o=claim_space(S),a=claim_element(S,"H3",{class:!0});var w=children(a);u=claim_text(w,s[0]),w.forEach(detach),d=claim_space(S),m&&m.l(S),h=claim_space(S),p=claim_element(S,"P",{});var k=children(p);l=claim_text(k,s[1]),k.forEach(detach),S.forEach(detach),y.forEach(detach),i=claim_space(T),c=claim_element(T,"DIV",{class:!0});var P=children(c);b&&b.l(P),P.forEach(detach),T.forEach(detach),this.h()},h(){attr(a,"class","uppercase font-medium grow"),attr(n,"class","flex items-center gap-3 w-full"),attr(t,"class","flex items-center justify-between text-slate-800"),attr(c,"class","p-2 pt-0 max-h-full overflow-y-auto"),attr(e,"class","h-full pb-10")},m(v,T){insert_hydration(v,e,T),append_hydration(e,t),append_hydration(t,n),mount_component(r,n,null),append_hydration(n,o),append_hydration(n,a),append_hydration(a,u),append_hydration(n,d),m&&m.m(n,null),append_hydration(n,h),append_hydration(n,p),append_hydration(p,l),append_hydration(e,i),append_hydration(e,c),b&&b.m(c,null),f=!0},p(v,[T]){const y={};T&8&&(y.tooltipContent=v[3]),T&132&&(y.$$scope={dirty:T,ctx:v}),r.$set(y),(!f||T&1)&&set_data(u,v[0]),m&&m.p&&(!f||T&128)&&update_slot_base(m,g,v,v[7],f?get_slot_changes(g,v[7],T,get_modelSelection_slot_changes):get_all_dirty_from_scope(v[7]),get_modelSelection_slot_context),(!f||T&2)&&set_data(l,v[1]),b&&b.p&&(!f||T&128)&&update_slot_base(b,_,v,v[7],f?get_slot_changes(_,v[7],T,null):get_all_dirty_from_scope(v[7]),null)},i(v){f||(transition_in(r.$$.fragment,v),transition_in(m,v),transition_in(b,v),f=!0)},o(v){transition_out(r.$$.fragment,v),transition_out(m,v),transition_out(b,v),f=!1},d(v){v&&detach(e),destroy_component(r),m&&m.d(v),b&&b.d(v)}}}function instance$s(s,e,t){let n,{$$slots:r={},$$scope:o}=e,{sectionTitle:a}=e,{modelName:u}=e,{numberOfItem:d}=e,h="shown";itemObjects.subscribe(l=>{if(!l.length)return;const i=l.filter(g=>g.source_id===u);i.every(g=>{var m;return(m=g.displayControl)==null?void 0:m.hidden})&&t(2,h="hidden"),i.every(g=>{var m;return!((m=g.displayControl)!=null&&m.hidden)})&&t(2,h="shown")});const p=()=>{h==="hidden"?t(2,h="shown"):t(2,h="hidden")};return s.$$set=l=>{"sectionTitle"in l&&t(0,a=l.sectionTitle),"modelName"in l&&t(5,u=l.modelName),"numberOfItem"in l&&t(1,d=l.numberOfItem),"$$scope"in l&&t(7,o=l.$$scope)},s.$$.update=()=>{s.$$.dirty&36&&t(3,n=h==="hidden"?`Show ${u} objects`:`Hide ${u} objects`),s.$$.dirty&36&&itemObjects.update(l=>l.map(i=>{const c=h==="hidden";return u===GROUND_TRUTH?i.source_id===u?toggleObjectDisplayControl(i,"hidden",["bbox","mask"],c):i:EXISTING_SOURCE_IDS.includes(i.source_id)?i:i.source_id===u?toggleObjectDisplayControl(i,"hidden",["bbox","mask"],c):toggleObjectDisplayControl(i,"hidden",["bbox","mask"],!0)}))},[a,d,h,n,p,u,r,o]}class ObjectsModelSection extends SvelteComponent{constructor(e){super(),init(this,e,instance$s,create_fragment$o,safe_not_equal,{sectionTitle:0,modelName:5,numberOfItem:1})}}const urlAlphabet="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let nanoid=(s=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(s));for(;s--;)e+=urlAlphabet[t[s]&63];return e};function get_each_context$3(s,e,t){const n=s.slice();return n[13]=e[t],n[15]=t,n}function create_if_block_4$2(s){var l;let e,t,n,r,o=s[13].label+"",a,u,d;function h(...i){return s[9](s[13],...i)}t=new Checkbox({props:{handleClick:h,checked:((l=s[1][s[13].name])==null?void 0:l.value)===1}});let p=s[13].required&&create_if_block_5();return{c(){e=element("div"),create_component(t.$$.fragment),n=space(),r=element("span"),a=text(o),u=space(),p&&p.c(),this.h()},l(i){e=claim_element(i,"DIV",{class:!0});var c=children(e);claim_component(t.$$.fragment,c),n=claim_space(c),r=claim_element(c,"SPAN",{});var f=children(r);a=claim_text(f,o),u=claim_space(f),p&&p.l(f),f.forEach(detach),c.forEach(detach),this.h()},h(){attr(e,"class","flex gap-4 items-center")},m(i,c){insert_hydration(i,e,c),mount_component(t,e,null),append_hydration(e,n),append_hydration(e,r),append_hydration(r,a),append_hydration(r,u),p&&p.m(r,null),d=!0},p(i,c){var g;s=i;const f={};c&1&&(f.handleClick=h),c&3&&(f.checked=((g=s[1][s[13].name])==null?void 0:g.value)===1),t.$set(f),(!d||c&1)&&o!==(o=s[13].label+"")&&set_data(a,o),s[13].required?p||(p=create_if_block_5(),p.c(),p.m(r,null)):p&&(p.d(1),p=null)},i(i){d||(transition_in(t.$$.fragment,i),d=!0)},o(i){transition_out(t.$$.fragment,i),d=!1},d(i){i&&detach(e),destroy_component(t),p&&p.d()}}}function create_if_block_5(s){let e,t="*";return{c(){e=element("span"),e.textContent=t},l(n){e=claim_element(n,"SPAN",{"data-svelte-h":!0}),get_svelte_dataset(e)!=="svelte-140b0co"&&(e.textContent=t)},m(n,r){insert_hydration(n,e,r)},d(n){n&&detach(e)}}}function create_if_block_3$3(s){let e,t;function n(...r){return s[10](s[13],...r)}return e=new Combobox({props:{placeholder:`Select a ${s[13].label}`,listItems:s[13].options,saveValue:n}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,o){mount_component(e,r,o),t=!0},p(r,o){s=r;const a={};o&1&&(a.placeholder=`Select a ${s[13].label}`),o&1&&(a.listItems=s[13].options),o&1&&(a.saveValue=n),e.$set(a)},i(r){t||(transition_in(e.$$.fragment,r),t=!0)},o(r){transition_out(e.$$.fragment,r),t=!1},d(r){destroy_component(e,r)}}}function create_if_block$g(s){let e,t,n=s[13].label+"",r,o,a,u,d,h,p,l=s[13].required&&create_if_block_2$5();const i=[create_if_block_1$8,create_else_block$2],c=[];function f(g,m){return g[13].type==="str"?0:1}return u=f(s),d=c[u]=i[u](s),{c(){e=element("div"),t=element("span"),r=text(n),o=space(),l&&l.c(),a=space(),d.c(),h=space()},l(g){e=claim_element(g,"DIV",{});var m=children(e);t=claim_element(m,"SPAN",{});var _=children(t);r=claim_text(_,n),o=claim_space(_),l&&l.l(_),_.forEach(detach),a=claim_space(m),d.l(m),h=claim_space(m),m.forEach(detach)},m(g,m){insert_hydration(g,e,m),append_hydration(e,t),append_hydration(t,r),append_hydration(t,o),l&&l.m(t,null),append_hydration(e,a),c[u].m(e,null),append_hydration(e,h),p=!0},p(g,m){(!p||m&1)&&n!==(n=g[13].label+"")&&set_data(r,n),g[13].required?l||(l=create_if_block_2$5(),l.c(),l.m(t,null)):l&&(l.d(1),l=null);let _=u;u=f(g),u===_?c[u].p(g,m):(group_outros(),transition_out(c[_],1,1,()=>{c[_]=null}),check_outros(),d=c[u],d?d.p(g,m):(d=c[u]=i[u](g),d.c()),transition_in(d,1),d.m(e,h))},i(g){p||(transition_in(d),p=!0)},o(g){transition_out(d),p=!1},d(g){g&&detach(e),l&&l.d(),c[u].d()}}}function create_if_block_2$5(s){let e,t="*";return{c(){e=element("span"),e.textContent=t},l(n){e=claim_element(n,"SPAN",{"data-svelte-h":!0}),get_svelte_dataset(e)!=="svelte-140b0co"&&(e.textContent=t)},m(n,r){insert_hydration(n,e,r)},d(n){n&&detach(e)}}}function create_else_block$2(s){var r;let e,t;function n(...o){return s[12](s[13],...o)}return e=new Input({props:{type:"number",step:s[13].type==="int"?"1":"any",value:((r=s[1][s[13].name])==null?void 0:r.value)||"",autofocus:s[15]===0}}),e.$on("keyup",keyup_handler),e.$on("input",n),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,a){mount_component(e,o,a),t=!0},p(o,a){var d;s=o;const u={};a&1&&(u.step=s[13].type==="int"?"1":"any"),a&3&&(u.value=((d=s[1][s[13].name])==null?void 0:d.value)||""),e.$set(u)},i(o){t||(transition_in(e.$$.fragment,o),t=!0)},o(o){transition_out(e.$$.fragment,o),t=!1},d(o){destroy_component(e,o)}}}function create_if_block_1$8(s){var r,o,a;let e,t;function n(...u){return s[11](s[13],...u)}return e=new AutoCompleteFeatureInput({props:{value:s[5](s[13].name),onTextInputChange:n,featureList:mapFeatureList((r=s[3].featuresList)==null?void 0:r.objects[s[13].name]),autofocus:s[15]===0&&s[2],isInputEnabled:!((a=(o=s[3].featuresList)==null?void 0:o.objects[s[13].name])!=null&&a.restricted)}}),{c(){create_component(e.$$.fragment)},l(u){claim_component(e.$$.fragment,u)},m(u,d){mount_component(e,u,d),t=!0},p(u,d){var p,l,i;s=u;const h={};d&1&&(h.value=s[5](s[13].name)),d&1&&(h.onTextInputChange=n),d&9&&(h.featureList=mapFeatureList((p=s[3].featuresList)==null?void 0:p.objects[s[13].name])),d&4&&(h.autofocus=s[15]===0&&s[2]),d&9&&(h.isInputEnabled=!((i=(l=s[3].featuresList)==null?void 0:l.objects[s[13].name])!=null&&i.restricted)),e.$set(h)},i(u){t||(transition_in(e.$$.fragment,u),t=!0)},o(u){transition_out(e.$$.fragment,u),t=!1},d(u){destroy_component(e,u)}}}function create_each_block$3(s){let e,t,n=["int","float","str"].includes(s[13].type),r,o,a=s[13].type==="bool"&&create_if_block_4$2(s),u=s[13].type==="list"&&create_if_block_3$3(s),d=n&&create_if_block$g(s);return{c(){a&&a.c(),e=space(),u&&u.c(),t=space(),d&&d.c(),r=empty()},l(h){a&&a.l(h),e=claim_space(h),u&&u.l(h),t=claim_space(h),d&&d.l(h),r=empty()},m(h,p){a&&a.m(h,p),insert_hydration(h,e,p),u&&u.m(h,p),insert_hydration(h,t,p),d&&d.m(h,p),insert_hydration(h,r,p),o=!0},p(h,p){h[13].type==="bool"?a?(a.p(h,p),p&1&&transition_in(a,1)):(a=create_if_block_4$2(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[13].type==="list"?u?(u.p(h,p),p&1&&transition_in(u,1)):(u=create_if_block_3$3(h),u.c(),transition_in(u,1),u.m(t.parentNode,t)):u&&(group_outros(),transition_out(u,1,1,()=>{u=null}),check_outros()),p&1&&(n=["int","float","str"].includes(h[13].type)),n?d?(d.p(h,p),p&1&&transition_in(d,1)):(d=create_if_block$g(h),d.c(),transition_in(d,1),d.m(r.parentNode,r)):d&&(group_outros(),transition_out(d,1,1,()=>{d=null}),check_outros())},i(h){o||(transition_in(a),transition_in(u),transition_in(d),o=!0)},o(h){transition_out(a),transition_out(u),transition_out(d),o=!1},d(h){h&&(detach(e),detach(t),detach(r)),a&&a.d(h),u&&u.d(h),d&&d.d(h)}}}function create_fragment$n(s){let e,t,n=ensure_array_like(s[0]),r=[];for(let a=0;a<n.length;a+=1)r[a]=create_each_block$3(get_each_context$3(s,n,a));const o=a=>transition_out(r[a],1,1,()=>{r[a]=null});return{c(){for(let a=0;a<r.length;a+=1)r[a].c();e=empty()},l(a){for(let u=0;u<r.length;u+=1)r[u].l(a);e=empty()},m(a,u){for(let d=0;d<r.length;d+=1)r[d]&&r[d].m(a,u);insert_hydration(a,e,u),t=!0},p(a,[u]){if(u&63){n=ensure_array_like(a[0]);let d;for(d=0;d<n.length;d+=1){const h=get_each_context$3(a,n,d);r[d]?(r[d].p(h,u),transition_in(r[d],1)):(r[d]=create_each_block$3(h),r[d].c(),transition_in(r[d],1),r[d].m(e.parentNode,e))}for(group_outros(),d=n.length;d<r.length;d+=1)o(d);check_outros()}},i(a){if(!t){for(let u=0;u<n.length;u+=1)transition_in(r[u]);t=!0}},o(a){r=r.filter(Boolean);for(let u=0;u<r.length;u+=1)transition_out(r[u]);t=!1},d(a){a&&detach(e),destroy_each(r,a)}}}const keyup_handler=s=>s.stopPropagation();function instance$r(s,e,t){let n;component_subscribe(s,itemMetas,m=>t(3,n=m));let{isFormValid:r=!1}=e,{formInputs:o=[]}=e,{objectProperties:a={}}=e,{initialValues:u={}}=e,{isAutofocusEnabled:d=!0}=e,h;itemMetas.subscribe(m=>{const _=Object.values(m.objectFeatures||defaultObjectFeatures).map(b=>({...b,label:b.name,required:!0,type:b.dtype}));t(8,h=createSchemaFromFeatures(_)),t(0,o=createObjectInputsSchema.parse(_))});const p=(m,_)=>{t(6,a[_]=m,a)},l=m=>{var b;const _=(b=u[m])==null?void 0:b.value;return typeof _=="string"?_:""},i=(m,_)=>p(_,m.name),c=(m,_)=>p(_,m.name),f=(m,_)=>p(_,m.name),g=(m,_)=>p(Number(_.currentTarget.value),m.name);return s.$$set=m=>{"isFormValid"in m&&t(7,r=m.isFormValid),"formInputs"in m&&t(0,o=m.formInputs),"objectProperties"in m&&t(6,a=m.objectProperties),"initialValues"in m&&t(1,u=m.initialValues),"isAutofocusEnabled"in m&&t(2,d=m.isAutofocusEnabled)},s.$$.update=()=>{if(s.$$.dirty&2&&Object.values(u).forEach(m=>{typeof m.value!="object"&&t(6,a[m.name]=m.value,a)}),s.$$.dirty&320){const m=h.safeParse(a);t(7,r=m.success)}},[o,u,d,n,p,l,a,r,h,i,c,f,g]}class CreateFeatureInputs extends SvelteComponent{constructor(e){super(),init(this,e,instance$r,create_fragment$n,safe_not_equal,{isFormValid:7,formInputs:0,objectProperties:6,initialValues:1,isAutofocusEnabled:2})}}function create_if_block$f(s){let e,t,n,r,o,a="PRE ANNOTATION",u,d,h,p;n=new Root$2({props:{$$slots:{default:[create_default_slot_3$1]},$$scope:{ctx:s}}});let l=s[3]&&create_if_block_3$2(s),i=s[3]&&create_if_block_1$7(s);return{c(){e=element("div"),t=element("div"),create_component(n.$$.fragment),r=space(),o=element("h3"),o.textContent=a,u=space(),l&&l.c(),d=space(),i&&i.c(),h=empty(),this.h()},l(c){e=claim_element(c,"DIV",{class:!0});var f=children(e);t=claim_element(f,"DIV",{class:!0});var g=children(t);claim_component(n.$$.fragment,g),r=claim_space(g),o=claim_element(g,"H3",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(o)!=="svelte-k5yb9e"&&(o.textContent=a),g.forEach(detach),u=claim_space(f),l&&l.l(f),f.forEach(detach),d=claim_space(c),i&&i.l(c),h=empty(),this.h()},h(){attr(o,"class","uppercase font-medium"),attr(t,"class","flex gap-4"),attr(e,"class","flex justify-between my-4")},m(c,f){insert_hydration(c,e,f),append_hydration(e,t),mount_component(n,t,null),append_hydration(t,r),append_hydration(t,o),append_hydration(e,u),l&&l.m(e,null),insert_hydration(c,d,f),i&&i.m(c,f),insert_hydration(c,h,f),p=!0},p(c,f){const g={};f&32769&&(g.$$scope={dirty:f,ctx:c}),n.$set(g),c[3]?l?l.p(c,f):(l=create_if_block_3$2(c),l.c(),l.m(e,null)):l&&(l.d(1),l=null),c[3]?i?(i.p(c,f),f&8&&transition_in(i,1)):(i=create_if_block_1$7(c),i.c(),transition_in(i,1),i.m(h.parentNode,h)):i&&(group_outros(),transition_out(i,1,1,()=>{i=null}),check_outros())},i(c){p||(transition_in(n.$$.fragment,c),transition_in(i),p=!0)},o(c){transition_out(n.$$.fragment,c),transition_out(i),p=!1},d(c){c&&(detach(e),detach(d),detach(h)),destroy_component(n),l&&l.d(),i&&i.d(c)}}}function create_default_slot_5$1(s){let e,t;return e=new SwitchRoot({props:{class:cn({"pointer-events-none":!s[0].length}),onChange:s[9]}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p(n,r){const o={};r&1&&(o.class=cn({"pointer-events-none":!n[0].length})),e.$set(o)},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_if_block_4$1(s){let e,t;return e=new Tooltip_content({props:{$$slots:{default:[create_default_slot_4$1]},$$scope:{ctx:s}}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_default_slot_4$1(s){let e,t="No objects to annotate";return{c(){e=element("p"),e.textContent=t},l(n){e=claim_element(n,"P",{"data-svelte-h":!0}),get_svelte_dataset(e)!=="svelte-1mgoitw"&&(e.textContent=t)},m(n,r){insert_hydration(n,e,r)},p:noop,d(n){n&&detach(e)}}}function create_default_slot_3$1(s){let e,t,n,r;e=new Trigger$1({props:{$$slots:{default:[create_default_slot_5$1]},$$scope:{ctx:s}}});let o=s[0].length===0&&create_if_block_4$1(s);return{c(){create_component(e.$$.fragment),t=space(),o&&o.c(),n=empty()},l(a){claim_component(e.$$.fragment,a),t=claim_space(a),o&&o.l(a),n=empty()},m(a,u){mount_component(e,a,u),insert_hydration(a,t,u),o&&o.m(a,u),insert_hydration(a,n,u),r=!0},p(a,u){const d={};u&32769&&(d.$$scope={dirty:u,ctx:a}),e.$set(d),a[0].length===0?o?u&1&&transition_in(o,1):(o=create_if_block_4$1(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(e.$$.fragment,a),transition_in(o),r=!0)},o(a){transition_out(e.$$.fragment,a),transition_out(o),r=!1},d(a){a&&(detach(t),detach(n)),destroy_component(e,a),o&&o.d(a)}}}function create_if_block_3$2(s){let e,t=s[1].length+"",n;return{c(){e=element("span"),n=text(t)},l(r){e=claim_element(r,"SPAN",{});var o=children(e);n=claim_text(o,t),o.forEach(detach)},m(r,o){insert_hydration(r,e,o),append_hydration(e,n)},p(r,o){o&2&&t!==(t=r[1].length+"")&&set_data(n,t)},d(r){r&&detach(e)}}}function create_if_block_1$7(s){let e,t,n,r,o,a,u,d;t=new TooltipIconButton({props:{tooltipContent:"confidence slider",$$slots:{default:[create_default_slot_2$1]},$$scope:{ctx:s}}}),o=new SliderRoot({props:{onChange:s[10],max:1,step:.01}});let h=s[2]&&create_if_block_2$4(s);return{c(){e=element("div"),create_component(t.$$.fragment),n=space(),r=element("div"),create_component(o.$$.fragment),a=space(),h&&h.c(),u=empty(),this.h()},l(p){e=claim_element(p,"DIV",{class:!0});var l=children(e);claim_component(t.$$.fragment,l),n=claim_space(l),r=claim_element(l,"DIV",{class:!0});var i=children(r);claim_component(o.$$.fragment,i),i.forEach(detach),l.forEach(detach),a=claim_space(p),h&&h.l(p),u=empty(),this.h()},h(){attr(r,"class","px-8 w-full"),attr(e,"class","my-2 flex items-center")},m(p,l){insert_hydration(p,e,l),mount_component(t,e,null),append_hydration(e,n),append_hydration(e,r),mount_component(o,r,null),insert_hydration(p,a,l),h&&h.m(p,l),insert_hydration(p,u,l),d=!0},p(p,l){const i={};l&32768&&(i.$$scope={dirty:l,ctx:p}),t.$set(i),p[2]?h?(h.p(p,l),l&4&&transition_in(h,1)):(h=create_if_block_2$4(p),h.c(),transition_in(h,1),h.m(u.parentNode,u)):h&&(group_outros(),transition_out(h,1,1,()=>{h=null}),check_outros())},i(p){d||(transition_in(t.$$.fragment,p),transition_in(o.$$.fragment,p),transition_in(h),d=!0)},o(p){transition_out(t.$$.fragment,p),transition_out(o.$$.fragment,p),transition_out(h),d=!1},d(p){p&&(detach(e),detach(a),detach(u)),destroy_component(t),destroy_component(o),h&&h.d(p)}}}function create_default_slot_2$1(s){let e,t;return e=new Filter({}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_if_block_2$4(s){let e,t,n,r,o,a=s[2].id+"",u,d,h,p=s[2].id,l,i,c,f,g,m;n=new BoxSelectIcon({props:{color:s[5]}});let _=create_key_block$2(s);return c=new PrimaryButton({props:{isSelected:!0,disabled:!s[4],$$slots:{default:[create_default_slot_1$4]},$$scope:{ctx:s}}}),c.$on("click",s[7]),g=new PrimaryButton({props:{$$slots:{default:[create_default_slot$a]},$$scope:{ctx:s}}}),g.$on("click",s[8]),{c(){e=element("div"),t=element("p"),create_component(n.$$.fragment),r=space(),o=element("span"),u=text(a),d=space(),h=element("div"),_.c(),l=space(),i=element("div"),create_component(c.$$.fragment),f=space(),create_component(g.$$.fragment),this.h()},l(b){e=claim_element(b,"DIV",{class:!0});var v=children(e);t=claim_element(v,"P",{class:!0});var T=children(t);claim_component(n.$$.fragment,T),r=claim_space(T),o=claim_element(T,"SPAN",{});var y=children(o);u=claim_text(y,a),y.forEach(detach),T.forEach(detach),d=claim_space(v),h=claim_element(v,"DIV",{class:!0});var S=children(h);_.l(S),S.forEach(detach),l=claim_space(v),i=claim_element(v,"DIV",{class:!0});var w=children(i);claim_component(c.$$.fragment,w),f=claim_space(w),claim_component(g.$$.fragment,w),w.forEach(detach),v.forEach(detach),this.h()},h(){attr(t,"class","flex gap-2"),attr(h,"class","flex flex-col gap-4 py-4"),attr(i,"class","flex gap-4 mt-4 justify-center sticky bottom-0 pb-2 left-[50%] bg-white"),attr(e,"class","bg-white rounded-sm p-4 pb-0 mt-4 relative max-h-[60vh] overflow-y-auto")},m(b,v){insert_hydration(b,e,v),append_hydration(e,t),mount_component(n,t,null),append_hydration(t,r),append_hydration(t,o),append_hydration(o,u),append_hydration(e,d),append_hydration(e,h),_.m(h,null),append_hydration(e,l),append_hydration(e,i),mount_component(c,i,null),append_hydration(i,f),mount_component(g,i,null),m=!0},p(b,v){const T={};v&32&&(T.color=b[5]),n.$set(T),(!m||v&4)&&a!==(a=b[2].id+"")&&set_data(u,a),v&4&&safe_not_equal(p,p=b[2].id)?(group_outros(),transition_out(_,1,1,noop),check_outros(),_=create_key_block$2(b),_.c(),transition_in(_,1),_.m(h,null)):_.p(b,v);const y={};v&16&&(y.disabled=!b[4]),v&32768&&(y.$$scope={dirty:v,ctx:b}),c.$set(y);const S={};v&32768&&(S.$$scope={dirty:v,ctx:b}),g.$set(S)},i(b){m||(transition_in(n.$$.fragment,b),transition_in(_),transition_in(c.$$.fragment,b),transition_in(g.$$.fragment,b),m=!0)},o(b){transition_out(n.$$.fragment,b),transition_out(_),transition_out(c.$$.fragment,b),transition_out(g.$$.fragment,b),m=!1},d(b){b&&detach(e),destroy_component(n),_.d(b),destroy_component(c),destroy_component(g)}}}function create_key_block$2(s){let e,t,n,r;function o(d){s[12](d)}function a(d){s[13](d)}let u={initialValues:s[2].features,isAutofocusEnabled:!1};return s[4]!==void 0&&(u.isFormValid=s[4]),s[6]!==void 0&&(u.objectProperties=s[6]),e=new CreateFeatureInputs({props:u}),binding_callbacks.push(()=>bind(e,"isFormValid",o)),binding_callbacks.push(()=>bind(e,"objectProperties",a)),{c(){create_component(e.$$.fragment)},l(d){claim_component(e.$$.fragment,d)},m(d,h){mount_component(e,d,h),r=!0},p(d,h){const p={};h&4&&(p.initialValues=d[2].features),!t&&h&16&&(t=!0,p.isFormValid=d[4],add_flush_callback(()=>t=!1)),!n&&h&64&&(n=!0,p.objectProperties=d[6],add_flush_callback(()=>n=!1)),e.$set(p)},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 create_default_slot_1$4(s){let e,t,n;return e=new Check({}),{c(){create_component(e.$$.fragment),t=text("Accept")},l(r){claim_component(e.$$.fragment,r),t=claim_text(r,"Accept")},m(r,o){mount_component(e,r,o),insert_hydration(r,t,o),n=!0},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){r&&detach(t),destroy_component(e,r)}}}function create_default_slot$a(s){let e;return{c(){e=text("Reject")},l(t){e=claim_text(t,"Reject")},m(t,n){insert_hydration(t,e,n)},d(t){t&&detach(e)}}}function create_fragment$m(s){let e,t,n=s[0].length>0&&create_if_block$f(s);return{c(){n&&n.c(),e=empty()},l(r){n&&n.l(r),e=empty()},m(r,o){n&&n.m(r,o),insert_hydration(r,e,o),t=!0},p(r,[o]){r[0].length>0?n?(n.p(r,o),o&1&&transition_in(n,1)):(n=create_if_block$f(r),n.c(),transition_in(n,1),n.m(e.parentNode,e)):n&&(group_outros(),transition_out(n,1,1,()=>{n=null}),check_outros())},i(r){t||(transition_in(n),t=!0)},o(r){transition_out(n),t=!1},d(r){r&&detach(e),n&&n.d(r)}}}function instance$q(s,e,t){let n,r;component_subscribe(s,preAnnotationIsActive,b=>t(3,r=b));let{colorScale:o}=e,a=[],u=[],d=!1,h=[0],p,l={};itemObjects.subscribe(b=>{t(0,a=getObjectsToPreAnnotate(b)),t(1,u=sortAndFilterObjectsToAnnotate(a,h))});const i=()=>{itemObjects.update(b=>[...mapObjectWithNewStatus(b,u,"accepted",l),{...n,review_state:"accepted",source_id:GROUND_TRUTH,id:nanoid(10),highlighted:"none"}]),canSave.set(!0)},c=()=>{itemObjects.update(b=>mapObjectWithNewStatus(b,u,"rejected")),canSave.set(!0)},f=b=>{set_store_value(preAnnotationIsActive,r=b||!1,r),itemObjects.update(v=>{const T=getObjectsToPreAnnotate(v),y=sortAndFilterObjectsToAnnotate(T,h);return v.map(S=>{var w;return S.highlighted=r?"none":"all",S.id===((w=y[0])==null?void 0:w.id)&&r&&(S.highlighted="self"),S})})},g=b=>{h=b||[0],t(1,u=sortAndFilterObjectsToAnnotate(a,h)),a.length===0&&preAnnotationIsActive.set(!1)};function m(b){d=b,t(4,d)}function _(b){l=b,t(6,l)}return s.$$set=b=>{"colorScale"in b&&t(11,o=b.colorScale)},s.$$.update=()=>{s.$$.dirty&2&&t(2,n=u[0]),s.$$.dirty&2052&&t(5,p=o((n==null?void 0:n.id)||"")),s.$$.dirty&9&&r&&a.length===0&&(preAnnotationIsActive.set(!1),itemObjects.update(b=>b.map(v=>(v.highlighted="all",v))))},[a,u,n,r,d,p,l,i,c,f,g,o,m,_]}class PreAnnotation extends SvelteComponent{constructor(e){super(),init(this,e,instance$q,create_fragment$m,safe_not_equal,{colorScale:11})}}function get_each_context$2(s,e,t){const n=s.slice();return n[9]=e[t],n[10]=e,n[11]=t,n}function get_each_context_1$2(s,e,t){const n=s.slice();return n[9]=e[t],n[12]=e,n[13]=t,n}function create_if_block$e(s){let e,t,n,r,o;t=new ObjectsModelSection({props:{sectionTitle:"Ground truth",modelName:GROUND_TRUTH,numberOfItem:s[0][GROUND_TRUTH].length,$$slots:{default:[create_default_slot_1$3]},$$scope:{ctx:s}}});let a=s[1]&&create_if_block_1$6(s);return{c(){e=element("div"),create_component(t.$$.fragment),n=space(),a&&a.c(),this.h()},l(u){e=claim_element(u,"DIV",{class:!0});var d=children(e);claim_component(t.$$.fragment,d),n=claim_space(d),a&&a.l(d),d.forEach(detach),this.h()},h(){attr(e,"class",r=cn("gap-4 grow grid grid-cols-1 grid-rows-2 h-full",{block:!s[1]}))},m(u,d){insert_hydration(u,e,d),mount_component(t,e,null),append_hydration(e,n),a&&a.m(e,null),o=!0},p(u,d){const h={};d&1&&(h.numberOfItem=u[0][GROUND_TRUTH].length),d&16385&&(h.$$scope={dirty:d,ctx:u}),t.$set(h),u[1]?a?(a.p(u,d),d&2&&transition_in(a,1)):(a=create_if_block_1$6(u),a.c(),transition_in(a,1),a.m(e,null)):a&&(group_outros(),transition_out(a,1,1,()=>{a=null}),check_outros()),(!o||d&2&&r!==(r=cn("gap-4 grow grid grid-cols-1 grid-rows-2 h-full",{block:!u[1]})))&&attr(e,"class",r)},i(u){o||(transition_in(t.$$.fragment,u),transition_in(a),o=!0)},o(u){transition_out(t.$$.fragment,u),transition_out(a),o=!1},d(u){u&&detach(e),destroy_component(t),a&&a.d()}}}function create_each_block_1$2(s){let e,t,n;function r(a){s[5](a,s[9],s[12],s[13])}let o={colorScale:s[3]};return s[9]!==void 0&&(o.itemObject=s[9]),e=new ObjectCard({props:o}),binding_callbacks.push(()=>bind(e,"itemObject",r)),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,u){mount_component(e,a,u),n=!0},p(a,u){s=a;const d={};!t&&u&1&&(t=!0,d.itemObject=s[9],add_flush_callback(()=>t=!1)),e.$set(d)},i(a){n||(transition_in(e.$$.fragment,a),n=!0)},o(a){transition_out(e.$$.fragment,a),n=!1},d(a){destroy_component(e,a)}}}function create_default_slot_1$3(s){let e,t,n=ensure_array_like(s[0][GROUND_TRUTH]),r=[];for(let a=0;a<n.length;a+=1)r[a]=create_each_block_1$2(get_each_context_1$2(s,n,a));const o=a=>transition_out(r[a],1,1,()=>{r[a]=null});return{c(){for(let a=0;a<r.length;a+=1)r[a].c();e=empty()},l(a){for(let u=0;u<r.length;u+=1)r[u].l(a);e=empty()},m(a,u){for(let d=0;d<r.length;d+=1)r[d]&&r[d].m(a,u);insert_hydration(a,e,u),t=!0},p(a,u){if(u&9){n=ensure_array_like(a[0][GROUND_TRUTH]);let d;for(d=0;d<n.length;d+=1){const h=get_each_context_1$2(a,n,d);r[d]?(r[d].p(h,u),transition_in(r[d],1)):(r[d]=create_each_block_1$2(h),r[d].c(),transition_in(r[d],1),r[d].m(e.parentNode,e))}for(group_outros(),d=n.length;d<r.length;d+=1)o(d);check_outros()}},i(a){if(!t){for(let u=0;u<n.length;u+=1)transition_in(r[u]);t=!0}},o(a){r=r.filter(Boolean);for(let u=0;u<r.length;u+=1)transition_out(r[u]);t=!1},d(a){a&&detach(e),destroy_each(r,a)}}}function create_if_block_1$6(s){var n;let e,t;return e=new ObjectsModelSection({props:{sectionTitle:"Model run",modelName:s[1],numberOfItem:((n=s[0][s[1]])==null?void 0:n.length)||0,$$slots:{modelSelection:[create_modelSelection_slot],default:[create_default_slot$9]},$$scope:{ctx:s}}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,o){mount_component(e,r,o),t=!0},p(r,o){var u;const a={};o&2&&(a.modelName=r[1]),o&3&&(a.numberOfItem=((u=r[0][r[1]])==null?void 0:u.length)||0),o&16387&&(a.$$scope={dirty:o,ctx:r}),e.$set(a)},i(r){t||(transition_in(e.$$.fragment,r),t=!0)},o(r){transition_out(e.$$.fragment,r),t=!1},d(r){destroy_component(e,r)}}}function create_each_block$2(s){let e,t,n;function r(a){s[7](a,s[9],s[10],s[11])}let o={colorScale:s[3]};return s[9]!==void 0&&(o.itemObject=s[9]),e=new ObjectCard({props:o}),binding_callbacks.push(()=>bind(e,"itemObject",r)),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,u){mount_component(e,a,u),n=!0},p(a,u){s=a;const d={};!t&&u&3&&(t=!0,d.itemObject=s[9],add_flush_callback(()=>t=!1)),e.$set(d)},i(a){n||(transition_in(e.$$.fragment,a),n=!0)},o(a){transition_out(e.$$.fragment,a),n=!1},d(a){destroy_component(e,a)}}}function create_default_slot$9(s){let e,t,n=ensure_array_like(s[0][s[1]]||[]),r=[];for(let a=0;a<n.length;a+=1)r[a]=create_each_block$2(get_each_context$2(s,n,a));const o=a=>transition_out(r[a],1,1,()=>{r[a]=null});return{c(){for(let a=0;a<r.length;a+=1)r[a].c();e=empty()},l(a){for(let u=0;u<r.length;u+=1)r[u].l(a);e=empty()},m(a,u){for(let d=0;d<r.length;d+=1)r[d]&&r[d].m(a,u);insert_hydration(a,e,u),t=!0},p(a,u){if(u&11){n=ensure_array_like(a[0][a[1]]||[]);let d;for(d=0;d<n.length;d+=1){const h=get_each_context$2(a,n,d);r[d]?(r[d].p(h,u),transition_in(r[d],1)):(r[d]=create_each_block$2(h),r[d].c(),transition_in(r[d],1),r[d].m(e.parentNode,e))}for(group_outros(),d=n.length;d<r.length;d+=1)o(d);check_outros()}},i(a){if(!t){for(let u=0;u<n.length;u+=1)transition_in(r[u]);t=!0}},o(a){r=r.filter(Boolean);for(let u=0;u<r.length;u+=1)transition_out(r[u]);t=!1},d(a){a&&detach(e),destroy_each(r,a)}}}function create_modelSelection_slot(s){let e,t,n;function r(a){s[6](a)}let o={slot:"modelSelection",width:"w-[150px]",listItems:s[4].map(func)};return s[1]!==void 0&&(o.value=s[1]),e=new Combobox({props:o}),binding_callbacks.push(()=>bind(e,"value",r)),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,u){mount_component(e,a,u),n=!0},p(a,u){const d={};!t&&u&2&&(t=!0,d.value=a[1],add_flush_callback(()=>t=!1)),e.$set(d)},i(a){n||(transition_in(e.$$.fragment,a),n=!0)},o(a){transition_out(e.$$.fragment,a),n=!1},d(a){destroy_component(e,a)}}}function create_fragment$l(s){let e,t,n,r;t=new PreAnnotation({props:{colorScale:s[3]}});let o=!s[2]&&create_if_block$e(s);return{c(){e=element("div"),create_component(t.$$.fragment),n=space(),o&&o.c(),this.h()},l(a){e=claim_element(a,"DIV",{class:!0});var u=children(e);claim_component(t.$$.fragment,u),n=claim_space(u),o&&o.l(u),u.forEach(detach),this.h()},h(){attr(e,"class","p-2 flex flex-col h-[calc(100vh-200px)]")},m(a,u){insert_hydration(a,e,u),mount_component(t,e,null),append_hydration(e,n),o&&o.m(e,null),r=!0},p(a,[u]){a[2]?o&&(group_outros(),transition_out(o,1,1,()=>{o=null}),check_outros()):o?(o.p(a,u),u&4&&transition_in(o,1)):(o=create_if_block$e(a),o.c(),transition_in(o,1),o.m(e,null))},i(a){r||(transition_in(t.$$.fragment,a),transition_in(o),r=!0)},o(a){transition_out(t.$$.fragment,a),transition_out(o),r=!1},d(a){a&&detach(e),destroy_component(t),o&&o.d()}}}const func=s=>({value:s,label:s});function instance$p(s,e,t){let n;component_subscribe(s,preAnnotationIsActive,i=>t(2,n=i));let r={[GROUND_TRUTH]:[],[PRE_ANNOTATION]:[]},o=[];itemObjects.subscribe(i=>{o=i.map(g=>g.id),t(0,r=sortObjectsByModel(i));const c=i.find(g=>g.highlighted==="self");if(!c)return;const f=document.querySelector(`#${createObjectCardId(c)}`);f&&f.scrollIntoView({behavior:"smooth",block:"start"})});let a=ordinalColorScale(o),u=Object.keys(r).filter(i=>i!==GROUND_TRUTH&&i!==PRE_ANNOTATION),d=Object.keys(r).filter(i=>i!==GROUND_TRUTH&&i!==PRE_ANNOTATION)[0];function h(i,c,f,g){f[g]=i,t(0,r)}function p(i){d=i,t(1,d)}function l(i,c,f,g){f[g]=i,t(0,r)}return[r,d,n,a,u,h,p,l]}class ObjectsInspector extends SvelteComponent{constructor(e){super(),init(this,e,instance$p,create_fragment$l,safe_not_equal,{})}}function create_if_block$d(s){let e,t,n,r=s[0].type+"",o,a,u,d,h,p,l,i,c,f,g,m,_,b,v;function T(k){s[7](k)}function y(k){s[8](k)}function S(k){s[9](k)}let w={};return s[1]!==void 0&&(w.isFormValid=s[1]),s[2]!==void 0&&(w.formInputs=s[2]),s[3]!==void 0&&(w.objectProperties=s[3]),d=new CreateFeatureInputs({props:w}),binding_callbacks.push(()=>bind(d,"isFormValid",T)),binding_callbacks.push(()=>bind(d,"formInputs",y)),binding_callbacks.push(()=>bind(d,"objectProperties",S)),f=new Button({props:{class:"text-white",$$slots:{default:[create_default_slot_1$2]},$$scope:{ctx:s}}}),f.$on("click",s[10]),m=new Button({props:{class:"text-white",type:"submit",disabled:!s[1],$$slots:{default:[create_default_slot$8]},$$scope:{ctx:s}}}),{c(){e=element("form"),t=element("p"),n=text("Save "),o=text(r),a=space(),u=element("div"),create_component(d.$$.fragment),i=space(),c=element("div"),create_component(f.$$.fragment),g=space(),create_component(m.$$.fragment),this.h()},l(k){e=claim_element(k,"FORM",{class:!0});var P=children(e);t=claim_element(P,"P",{});var I=children(t);n=claim_text(I,"Save "),o=claim_text(I,r),I.forEach(detach),a=claim_space(P),u=claim_element(P,"DIV",{class:!0});var F=children(u);claim_component(d.$$.fragment,F),F.forEach(detach),i=claim_space(P),c=claim_element(P,"DIV",{class:!0});var C=children(c);claim_component(f.$$.fragment,C),g=claim_space(C),claim_component(m.$$.fragment,C),C.forEach(detach),P.forEach(detach),this.h()},h(){attr(u,"class","max-h-[calc(100vh-250px)] overflow-y-auto flex flex-col gap-4"),attr(c,"class","flex gap-4"),attr(e,"class","flex flex-col gap-4 p-4")},m(k,P){insert_hydration(k,e,P),append_hydration(e,t),append_hydration(t,n),append_hydration(t,o),append_hydration(e,a),append_hydration(e,u),mount_component(d,u,null),append_hydration(e,i),append_hydration(e,c),mount_component(f,c,null),append_hydration(c,g),mount_component(m,c,null),_=!0,b||(v=listen(e,"submit",prevent_default(s[4])),b=!0)},p(k,P){(!_||P&1)&&r!==(r=k[0].type+"")&&set_data(o,r);const I={};!h&&P&2&&(h=!0,I.isFormValid=k[1],add_flush_callback(()=>h=!1)),!p&&P&4&&(p=!0,I.formInputs=k[2],add_flush_callback(()=>p=!1)),!l&&P&8&&(l=!0,I.objectProperties=k[3],add_flush_callback(()=>l=!1)),d.$set(I);const F={};P&4096&&(F.$$scope={dirty:P,ctx:k}),f.$set(F);const C={};P&2&&(C.disabled=!k[1]),P&4096&&(C.$$scope={dirty:P,ctx:k}),m.$set(C)},i(k){_||(transition_in(d.$$.fragment,k),transition_in(f.$$.fragment,k),transition_in(m.$$.fragment,k),_=!0)},o(k){transition_out(d.$$.fragment,k),transition_out(f.$$.fragment,k),transition_out(m.$$.fragment,k),_=!1},d(k){k&&detach(e),destroy_component(d),destroy_component(f),destroy_component(m),b=!1,v()}}}function create_default_slot_1$2(s){let e;return{c(){e=text("Cancel")},l(t){e=claim_text(t,"Cancel")},m(t,n){insert_hydration(t,e,n)},d(t){t&&detach(e)}}}function create_default_slot$8(s){let e;return{c(){e=text("Confirm")},l(t){e=claim_text(t,"Confirm")},m(t,n){insert_hydration(t,e,n)},d(t){t&&detach(e)}}}function create_fragment$k(s){let e,t,n,r,o=s[0].status==="saving"&&create_if_block$d(s);return{c(){o&&o.c(),e=empty()},l(a){o&&o.l(a),e=empty()},m(a,u){o&&o.m(a,u),insert_hydration(a,e,u),t=!0,n||(r=listen(window,"keydown",s[5]),n=!0)},p(a,[u]){a[0].status==="saving"?o?(o.p(a,u),u&1&&transition_in(o,1)):(o=create_if_block$d(a),o.c(),transition_in(o,1),o.m(e.parentNode,e)):o&&(group_outros(),transition_out(o,1,1,()=>{o=null}),check_outros())},i(a){t||(transition_in(o),t=!0)},o(a){transition_out(o),t=!1},d(a){a&&detach(e),o&&o.d(a),n=!1,r()}}}function instance$o(s,e,t){let n;component_subscribe(s,itemMetas,g=>t(11,n=g));let{currentTab:r}=e,o,a=!1,u=[],d={};newShape.subscribe(g=>{g&&t(0,o=g)});const h=()=>{const g=mapShapeInputsToFeatures(d,u);itemObjects.update(m=>{if(o.status!=="saving")return m;let _=null;const b={id:nanoid(10),item_id:o.itemId,source_id:GROUND_TRUTH,view_id:o.viewId,features:g};return o.type==="rectangle"&&(_={...b,bbox:{coords:[o.attrs.x/o.imageWidth,o.attrs.y/o.imageHeight,o.attrs.width/o.imageWidth,o.attrs.height/o.imageHeight],format:"xywh",is_normalized:!0,confidence:1}}),o.type==="mask"&&(_={...b,mask:{counts:o.rle.counts,size:o.rle.size}}),[...m,..._?[_]:[]]});for(let m in d)typeof d[m]=="string"&&addNewInput(n.featuresList,"objects",m,d[m]);newShape.set({status:"none",shouldReset:!0}),canSave.set(!0),t(6,r="objects")};function p(g){g.key==="Escape"&&newShape.set({status:"none",shouldReset:!0})}function l(g){a=g,t(1,a)}function i(g){u=g,t(2,u)}function c(g){d=g,t(3,d)}const f=()=>newShape.set({status:"none",shouldReset:!0});return s.$$set=g=>{"currentTab"in g&&t(6,r=g.currentTab)},[o,a,u,d,h,p,r,l,i,c,f]}class SaveShapeForm extends SvelteComponent{constructor(e){super(),init(this,e,instance$o,create_fragment$k,safe_not_equal,{currentTab:6})}}function create_else_block$1(s){let e,t,n;function r(a){s[6](a)}let o={class:"h-full",$$slots:{default:[create_default_slot$7]},$$scope:{ctx:s}};return s[2]!==void 0&&(o.value=s[2]),e=new Root$1({props:o}),binding_callbacks.push(()=>bind(e,"value",r)),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,u){mount_component(e,a,u),n=!0},p(a,u){const d={};u&137&&(d.$$scope={dirty:u,ctx:a}),!t&&u&4&&(t=!0,d.value=a[2],add_flush_callback(()=>t=!1)),e.$set(d)},i(a){n||(transition_in(e.$$.fragment,a),n=!0)},o(a){transition_out(e.$$.fragment,a),n=!1},d(a){destroy_component(e,a)}}}function create_if_block$c(s){let e,t,n;function r(a){s[5](a)}let o={};return s[2]!==void 0&&(o.currentTab=s[2]),e=new SaveShapeForm({props:o}),binding_callbacks.push(()=>bind(e,"currentTab",r)),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,u){mount_component(e,a,u),n=!0},p(a,u){const d={};!t&&u&4&&(t=!0,d.currentTab=a[2],add_flush_callback(()=>t=!1)),e.$set(d)},i(a){n||(transition_in(e.$$.fragment,a),n=!0)},o(a){transition_out(e.$$.fragment,a),n=!1},d(a){destroy_component(e,a)}}}function create_default_slot_5(s){let e;return{c(){e=text("Objects")},l(t){e=claim_text(t,"Objects")},m(t,n){insert_hydration(t,e,n)},d(t){t&&detach(e)}}}function create_default_slot_4(s){let e;return{c(){e=text("Scene")},l(t){e=claim_text(t,"Scene")},m(t,n){insert_hydration(t,e,n)},d(t){t&&detach(e)}}}function create_default_slot_3(s){let e,t,n,r;return e=new Tabs_trigger({props:{value:"objects",class:"w-1/2",$$slots:{default:[create_default_slot_5]},$$scope:{ctx:s}}}),n=new Tabs_trigger({props:{value:"scene",class:"w-1/2 ",$$slots:{default:[create_default_slot_4]},$$scope:{ctx:s}}}),{c(){create_component(e.$$.fragment),t=space(),create_component(n.$$.fragment)},l(o){claim_component(e.$$.fragment,o),t=claim_space(o),claim_component(n.$$.fragment,o)},m(o,a){mount_component(e,o,a),insert_hydration(o,t,a),mount_component(n,o,a),r=!0},p(o,a){const u={};a&128&&(u.$$scope={dirty:a,ctx:o}),e.$set(u);const d={};a&128&&(d.$$scope={dirty:a,ctx:o}),n.$set(d)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(n.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(n.$$.fragment,o),r=!1},d(o){o&&detach(t),destroy_component(e,o),destroy_component(n,o)}}}function create_else_block_2(s){let e,t;return e=new ObjectsInspector({}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_if_block_2$3(s){let e,t,n,r,o,a,u;return t=new Skeleton({props:{class:"h-8 w-full"}}),r=new Skeleton({props:{class:"h-8 w-full"}}),a=new Skeleton({props:{class:"h-8 w-full"}}),{c(){e=element("div"),create_component(t.$$.fragment),n=space(),create_component(r.$$.fragment),o=space(),create_component(a.$$.fragment),this.h()},l(d){e=claim_element(d,"DIV",{class:!0});var h=children(e);claim_component(t.$$.fragment,h),n=claim_space(h),claim_component(r.$$.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(d,h){insert_hydration(d,e,h),mount_component(t,e,null),append_hydration(e,n),mount_component(r,e,null),append_hydration(e,o),mount_component(a,e,null),u=!0},i(d){u||(transition_in(t.$$.fragment,d),transition_in(r.$$.fragment,d),transition_in(a.$$.fragment,d),u=!0)},o(d){transition_out(t.$$.fragment,d),transition_out(r.$$.fragment,d),transition_out(a.$$.fragment,d),u=!1},d(d){d&&detach(e),destroy_component(t),destroy_component(r),destroy_component(a)}}}function create_default_slot_2(s){let e,t,n,r;const o=[create_if_block_2$3,create_else_block_2],a=[];function u(d,h){return d[0]?0:1}return e=u(s),t=a[e]=o[e](s),{c(){t.c(),n=empty()},l(d){t.l(d),n=empty()},m(d,h){a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,h){let p=e;e=u(d),e!==p&&(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),t=a[e],t||(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n))},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),a[e].d(d)}}}function create_else_block_1(s){let e,t;return e=new SceneInspector({}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_if_block_1$5(s){let e,t,n,r,o,a,u;return t=new Skeleton({props:{class:"h-8 w-full"}}),r=new Skeleton({props:{class:"h-8 w-full"}}),a=new Skeleton({props:{class:"h-8 w-full"}}),{c(){e=element("div"),create_component(t.$$.fragment),n=space(),create_component(r.$$.fragment),o=space(),create_component(a.$$.fragment),this.h()},l(d){e=claim_element(d,"DIV",{class:!0});var h=children(e);claim_component(t.$$.fragment,h),n=claim_space(h),claim_component(r.$$.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(d,h){insert_hydration(d,e,h),mount_component(t,e,null),append_hydration(e,n),mount_component(r,e,null),append_hydration(e,o),mount_component(a,e,null),u=!0},i(d){u||(transition_in(t.$$.fragment,d),transition_in(r.$$.fragment,d),transition_in(a.$$.fragment,d),u=!0)},o(d){transition_out(t.$$.fragment,d),transition_out(r.$$.fragment,d),transition_out(a.$$.fragment,d),u=!1},d(d){d&&detach(e),destroy_component(t),destroy_component(r),destroy_component(a)}}}function create_default_slot_1$1(s){let e,t,n,r;const o=[create_if_block_1$5,create_else_block_1],a=[];function u(d,h){return d[0]?0:1}return e=u(s),t=a[e]=o[e](s),{c(){t.c(),n=empty()},l(d){t.l(d),n=empty()},m(d,h){a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,h){let p=e;e=u(d),e!==p&&(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),t=a[e],t||(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n))},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),a[e].d(d)}}}function create_default_slot$7(s){let e,t,n,r,o,a,u,d,h,p,l,i,c,f;return e=new Tabs_list({props:{class:"h-[48px]",$$slots:{default:[create_default_slot_3]},$$scope:{ctx:s}}}),r=new Tabs_content({props:{value:"objects",class:"h-full",$$slots:{default:[create_default_slot_2]},$$scope:{ctx:s}}}),a=new Tabs_content({props:{value:"scene",class:"max-h-[calc(100vh-200px)] overflow-y-auto",$$slots:{default:[create_default_slot_1$1]},$$scope:{ctx:s}}}),{c(){create_component(e.$$.fragment),t=space(),n=element("div"),create_component(r.$$.fragment),o=space(),create_component(a.$$.fragment),u=space(),d=element("button"),h=text("SAVE CHANGES"),this.h()},l(g){claim_component(e.$$.fragment,g),t=claim_space(g),n=claim_element(g,"DIV",{class:!0});var m=children(n);claim_component(r.$$.fragment,m),o=claim_space(m),claim_component(a.$$.fragment,m),u=claim_space(m),d=claim_element(m,"BUTTON",{class:!0});var _=children(d);h=claim_text(_,"SAVE CHANGES"),_.forEach(detach),m.forEach(detach),this.h()},h(){d.disabled=p=!s[3],attr(d,"class",l=cn("h-[48px] w-full border-t border-t-primary-light hover:bg-primary-light hover:cursor-pointer bg-slate-50 z-50",{"bg-slate-100 hover:bg-slate-100 pointer-events-none cursor-not-allowed text-slate-500":!s[3]})),attr(n,"class","h-[calc(100%-48px)] flex flex-col justify-between")},m(g,m){mount_component(e,g,m),insert_hydration(g,t,m),insert_hydration(g,n,m),mount_component(r,n,null),append_hydration(n,o),mount_component(a,n,null),append_hydration(n,u),append_hydration(n,d),append_hydration(d,h),i=!0,c||(f=listen(d,"click",s[4]),c=!0)},p(g,m){const _={};m&128&&(_.$$scope={dirty:m,ctx:g}),e.$set(_);const b={};m&129&&(b.$$scope={dirty:m,ctx:g}),r.$set(b);const v={};m&129&&(v.$$scope={dirty:m,ctx:g}),a.$set(v),(!i||m&8&&p!==(p=!g[3]))&&(d.disabled=p),(!i||m&8&&l!==(l=cn("h-[48px] w-full border-t border-t-primary-light hover:bg-primary-light hover:cursor-pointer bg-slate-50 z-50",{"bg-slate-100 hover:bg-slate-100 pointer-events-none cursor-not-allowed text-slate-500":!g[3]})))&&attr(d,"class",l)},i(g){i||(transition_in(e.$$.fragment,g),transition_in(r.$$.fragment,g),transition_in(a.$$.fragment,g),i=!0)},o(g){transition_out(e.$$.fragment,g),transition_out(r.$$.fragment,g),transition_out(a.$$.fragment,g),i=!1},d(g){g&&(detach(t),detach(n)),destroy_component(e,g),destroy_component(r),destroy_component(a),c=!1,f()}}}function create_fragment$j(s){let e,t,n,r;const o=[create_if_block$c,create_else_block$1],a=[];function u(d,h){var p;return((p=d[1])==null?void 0:p.status)==="saving"?0:1}return t=u(s),n=a[t]=o[t](s),{c(){e=element("div"),n.c(),this.h()},l(d){e=claim_element(d,"DIV",{class:!0});var h=children(e);n.l(h),h.forEach(detach),this.h()},h(){attr(e,"class","h-full max-h-screen shadow-sm border-l border-slate-200 bg-slate-100 font-Montserrat")},m(d,h){insert_hydration(d,e,h),a[t].m(e,null),r=!0},p(d,[h]){let p=t;t=u(d),t===p?a[t].p(d,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),n=a[t],n?n.p(d,h):(n=a[t]=o[t](d),n.c()),transition_in(n,1),n.m(e,null))},i(d){r||(transition_in(n),r=!0)},o(d){transition_out(n),r=!1},d(d){d&&detach(e),a[t].d()}}}function instance$n(s,e,t){let{isLoading:n}=e,r,o="objects",a=!1;canSave.subscribe(p=>{t(3,a=p)}),newShape.subscribe(p=>{t(1,r=p)});function u(p){bubble.call(this,s,p)}function d(p){o=p,t(2,o)}function h(p){o=p,t(2,o)}return s.$$set=p=>{"isLoading"in p&&t(0,n=p.isLoading)},[n,r,o,a,u,d,h]}class InspectorInspector extends SvelteComponent{constructor(e){super(),init(this,e,instance$n,create_fragment$j,safe_not_equal,{isLoading:0})}}async function loadEmbeddings(s,e,t){const n={};if(e){const r=await getItemEmbeddings(t,s,e);if(r.embeddings)for(const[o,a]of Object.entries(r.embeddings))try{const u=parse(b64ToBuffer(a.data));n[o]=new ort_minExports.Tensor("float32",u.data,u.shape)}catch(u){console.warn("AnnotationWorkspace.loadModel - Error loading embeddings",u)}}if(Object.keys(n).length===0)throw new Error("No embeddings found");return n}function create_if_block_2$2(s){let e,t,n;function r(a){s[8](a)}let o={message:"Please select your model for interactive segmentation.",choices:s[0],ifNoChoices:""};return s[1]!==void 0&&(o.selected=s[1]),e=new SelectModal({props:o}),binding_callbacks.push(()=>bind(e,"selected",r)),e.$on("confirm",s[3]),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,u){mount_component(e,a,u),n=!0},p(a,u){const d={};u&1&&(d.choices=a[0]),!t&&u&2&&(t=!0,d.selected=a[1],add_flush_callback(()=>t=!1)),e.$set(d)},i(a){n||(transition_in(e.$$.fragment,a),n=!0)},o(a){transition_out(e.$$.fragment,a),n=!1},d(a){destroy_component(e,a)}}}function create_if_block_1$4(s){let e,t;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",s[9]),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_if_block$b(s){let e,t;return e=new ConfirmModal({props:{message:"No embeddings found for model "+s[1]+".",details:"Please refer to our interactive annotation notebook for information on how to compute embeddings on your dataset."}}),e.$on("confirm",s[10]),e.$on("cancel",s[11]),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p(n,r){const o={};r&2&&(o.message="No embeddings found for model "+n[1]+"."),e.$set(o)},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_fragment$i(s){let e,t,n,r,o=s[2]==="selectModel"&&create_if_block_2$2(s),a=s[2]==="noModel"&&create_if_block_1$4(s),u=s[2]==="noEmbeddings"&&create_if_block$b(s);return{c(){o&&o.c(),e=space(),a&&a.c(),t=space(),u&&u.c(),n=empty()},l(d){o&&o.l(d),e=claim_space(d),a&&a.l(d),t=claim_space(d),u&&u.l(d),n=empty()},m(d,h){o&&o.m(d,h),insert_hydration(d,e,h),a&&a.m(d,h),insert_hydration(d,t,h),u&&u.m(d,h),insert_hydration(d,n,h),r=!0},p(d,[h]){d[2]==="selectModel"?o?(o.p(d,h),h&4&&transition_in(o,1)):(o=create_if_block_2$2(d),o.c(),transition_in(o,1),o.m(e.parentNode,e)):o&&(group_outros(),transition_out(o,1,1,()=>{o=null}),check_outros()),d[2]==="noModel"?a?h&4&&transition_in(a,1):(a=create_if_block_1$4(d),a.c(),transition_in(a,1),a.m(t.parentNode,t)):a&&(group_outros(),transition_out(a,1,1,()=>{a=null}),check_outros()),d[2]==="noEmbeddings"?u?(u.p(d,h),h&4&&transition_in(u,1)):(u=create_if_block$b(d),u.c(),transition_in(u,1),u.m(n.parentNode,n)):u&&(group_outros(),transition_out(u,1,1,()=>{u=null}),check_outros())},i(d){r||(transition_in(o),transition_in(a),transition_in(u),r=!0)},o(d){transition_out(o),transition_out(a),transition_out(u),r=!1},d(d){d&&(detach(e),detach(t),detach(n)),o&&o.d(d),a&&a.d(d),u&&u.d(d)}}}function instance$m(s,e,t){let n;component_subscribe(s,selectedTool,_=>t(7,n=_));let{models:r}=e,{currentDatasetId:o}=e,{selectedItemId:a}=e,{embeddings:u}=e,d="none",h;modelsStore.subscribe(_=>{t(2,d=_.currentModalOpen),t(1,h=_.selectedModelName)});const p=()=>{!a||!h||!o||h==="none"||loadEmbeddings(a,h,o).then(_=>{t(4,u=_)}).catch(_=>{modelsStore.update(b=>({...b,currentModalOpen:"noEmbeddings"})),console.error("cannot load Embeddings",_)})},l=new SAM;async function i(){modelsStore.update(_=>({..._,currentModalOpen:"none"})),await l.init("/data/models/"+h),interactiveSegmenterModel.set(l),p()}onMount(async()=>{if(r.length>0){let _=r.filter(b=>b.includes("sam"));_.length==1&&(modelsStore.update(b=>({...b,selectedModelName:_[0]})),await i())}});function c(_){h=_,t(1,h)}const f=()=>modelsStore.update(_=>({..._,currentModalOpen:"none"})),g=()=>modelsStore.update(_=>({..._,currentModalOpen:"selectModel"})),m=()=>modelsStore.update(_=>({..._,currentModalOpen:"none",selectedModelName:"none"}));return s.$$set=_=>{"models"in _&&t(0,r=_.models),"currentDatasetId"in _&&t(5,o=_.currentDatasetId),"selectedItemId"in _&&t(6,a=_.selectedItemId),"embeddings"in _&&t(4,u=_.embeddings)},s.$$.update=()=>{s.$$.dirty&64&&a&&p(),s.$$.dirty&131&&(n!=null&&n.isSmart&&r.length>1&&!h&&modelsStore.update(_=>({..._,currentModalOpen:"selectModel"})),n!=null&&n.isSmart&&r.length==0&&modelsStore.update(_=>({..._,currentModalOpen:"noModel"}))),s.$$.dirty&2&&h&&modelsStore.update(_=>({..._,selectedModelName:h}))},[r,h,d,i,u,o,a,n,c,f,g,m]}class LoadModelModal extends SvelteComponent{constructor(e){super(),init(this,e,instance$m,create_fragment$i,safe_not_equal,{models:0,currentDatasetId:5,selectedItemId:6,embeddings:4})}}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(s){}).toString()),dblClickWindow:400,getAngle(s){return Konva$2.angleDeg?s*PI_OVER_180:s},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(s){glob.Konva=s}},_registerNode=s=>{Konva$2[s.prototype.getClassName()]=s};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 t=this.m;return{x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}translate(e,t){return this.m[4]+=this.m[0]*e+this.m[2]*t,this.m[5]+=this.m[1]*e+this.m[3]*t,this}scale(e,t){return this.m[0]*=e,this.m[1]*=e,this.m[2]*=t,this.m[3]*=t,this}rotate(e){var t=Math.cos(e),n=Math.sin(e),r=this.m[0]*t+this.m[2]*n,o=this.m[1]*t+this.m[3]*n,a=this.m[0]*-n+this.m[2]*t,u=this.m[1]*-n+this.m[3]*t;return this.m[0]=r,this.m[1]=o,this.m[2]=a,this.m[3]=u,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(e,t){var n=this.m[0]+this.m[2]*t,r=this.m[1]+this.m[3]*t,o=this.m[2]+this.m[0]*e,a=this.m[3]+this.m[1]*e;return this.m[0]=n,this.m[1]=r,this.m[2]=o,this.m[3]=a,this}multiply(e){var t=this.m[0]*e.m[0]+this.m[2]*e.m[1],n=this.m[1]*e.m[0]+this.m[3]*e.m[1],r=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],u=this.m[1]*e.m[4]+this.m[3]*e.m[5]+this.m[5];return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=o,this.m[4]=a,this.m[5]=u,this}invert(){var e=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),t=this.m[3]*e,n=-this.m[1]*e,r=-this.m[2]*e,o=this.m[0]*e,a=e*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),u=e*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=o,this.m[4]=a,this.m[5]=u,this}getMatrix(){return this.m}decompose(){var e=this.m[0],t=this.m[1],n=this.m[2],r=this.m[3],o=this.m[4],a=this.m[5],u=e*r-t*n;let d={x:o,y:a,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(e!=0||t!=0){var h=Math.sqrt(e*e+t*t);d.rotation=t>0?Math.acos(e/h):-Math.acos(e/h),d.scaleX=h,d.scaleY=u/h,d.skewX=(e*n+t*r)/u,d.skewY=0}else if(n!=0||r!=0){var p=Math.sqrt(n*n+r*r);d.rotation=Math.PI/2-(r>0?Math.acos(-n/p):-Math.acos(n/p)),d.scaleX=u/p,d.scaleY=p,d.skewX=0,d.skewY=(e*n+t*r)/u}return d.rotation=Util._getRotation(d.rotation),d}}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(s){setTimeout(s,60)},Util={_isElement(s){return!!(s&&s.nodeType==1)},_isFunction(s){return!!(s&&s.constructor&&s.call&&s.apply)},_isPlainObject(s){return!!s&&s.constructor===Object},_isArray(s){return Object.prototype.toString.call(s)===OBJECT_ARRAY},_isNumber(s){return Object.prototype.toString.call(s)===OBJECT_NUMBER&&!isNaN(s)&&isFinite(s)},_isString(s){return Object.prototype.toString.call(s)===OBJECT_STRING},_isBoolean(s){return Object.prototype.toString.call(s)===OBJECT_BOOLEAN},isObject(s){return s instanceof Object},isValidSelector(s){if(typeof s!="string")return!1;var e=s[0];return e==="#"||e==="."||e===e.toUpperCase()},_sign(s){return s===0||s>0?1:-1},requestAnimFrame(s){animQueue.push(s),animQueue.length===1&&req(function(){const e=animQueue;animQueue=[],e.forEach(function(t){t()})})},createCanvasElement(){var s=document.createElement("canvas");try{s.style=s.style||{}}catch{}return s},createImageElement(){return document.createElement("img")},_isInDocument(s){for(;s=s.parentNode;)if(s==document)return!0;return!1},_urlToImage(s,e){var t=Util.createImageElement();t.onload=function(){e(t)},t.src=s},_rgbToHex(s,e,t){return((1<<24)+(s<<16)+(e<<8)+t).toString(16).slice(1)},_hexToRgb(s){s=s.replace(HASH$1,EMPTY_STRING$1);var e=parseInt(s,16);return{r:e>>16&255,g:e>>8&255,b:e&255}},getRandomColor(){for(var s=(Math.random()*16777215<<0).toString(16);s.length<6;)s=ZERO+s;return HASH$1+s},getRGB(s){var e;return s in COLORS?(e=COLORS[s],{r:e[0],g:e[1],b:e[2]}):s[0]===HASH$1?this._hexToRgb(s.substring(1)):s.substr(0,4)===RGB_PAREN?(e=RGB_REGEX.exec(s.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA(s){return s=s||"black",Util._namedColorToRBA(s)||Util._hex3ColorToRGBA(s)||Util._hex4ColorToRGBA(s)||Util._hex6ColorToRGBA(s)||Util._hex8ColorToRGBA(s)||Util._rgbColorToRGBA(s)||Util._rgbaColorToRGBA(s)||Util._hslColorToRGBA(s)},_namedColorToRBA(s){var e=COLORS[s.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(s){if(s.indexOf("rgb(")===0){s=s.match(/rgb\(([^)]+)\)/)[1];var e=s.split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(s){if(s.indexOf("rgba(")===0){s=s.match(/rgba\(([^)]+)\)/)[1];var e=s.split(/ *, */).map((t,n)=>t.slice(-1)==="%"?n===3?parseInt(t)/100:parseInt(t)/100*255:Number(t));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(s){if(s[0]==="#"&&s.length===9)return{r:parseInt(s.slice(1,3),16),g:parseInt(s.slice(3,5),16),b:parseInt(s.slice(5,7),16),a:parseInt(s.slice(7,9),16)/255}},_hex6ColorToRGBA(s){if(s[0]==="#"&&s.length===7)return{r:parseInt(s.slice(1,3),16),g:parseInt(s.slice(3,5),16),b:parseInt(s.slice(5,7),16),a:1}},_hex4ColorToRGBA(s){if(s[0]==="#"&&s.length===5)return{r:parseInt(s[1]+s[1],16),g:parseInt(s[2]+s[2],16),b:parseInt(s[3]+s[3],16),a:parseInt(s[4]+s[4],16)/255}},_hex3ColorToRGBA(s){if(s[0]==="#"&&s.length===4)return{r:parseInt(s[1]+s[1],16),g:parseInt(s[2]+s[2],16),b:parseInt(s[3]+s[3],16),a:1}},_hslColorToRGBA(s){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(s)){const[e,...t]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(s),n=Number(t[0])/360,r=Number(t[1])/100,o=Number(t[2])/100;let a,u,d;if(r===0)return d=o*255,{r:Math.round(d),g:Math.round(d),b:Math.round(d),a:1};o<.5?a=o*(1+r):a=o+r-o*r;const h=2*o-a,p=[0,0,0];for(let l=0;l<3;l++)u=n+1/3*-(l-1),u<0&&u++,u>1&&u--,6*u<1?d=h+(a-h)*6*u:2*u<1?d=a:3*u<2?d=h+(a-h)*(2/3-u)*6:d=h,p[l]=d*255;return{r:Math.round(p[0]),g:Math.round(p[1]),b:Math.round(p[2]),a:1}}},haveIntersection(s,e){return!(e.x>s.x+s.width||e.x+e.width<s.x||e.y>s.y+s.height||e.y+e.height<s.y)},cloneObject(s){var e={};for(var t in s)this._isPlainObject(s[t])?e[t]=this.cloneObject(s[t]):this._isArray(s[t])?e[t]=this.cloneArray(s[t]):e[t]=s[t];return e},cloneArray(s){return s.slice(0)},degToRad(s){return s*PI_OVER_DEG180},radToDeg(s){return s*DEG180_OVER_PI},_degToRad(s){return Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),Util.degToRad(s)},_radToDeg(s){return Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),Util.radToDeg(s)},_getRotation(s){return Konva$2.angleDeg?Util.radToDeg(s):s},_capitalize(s){return s.charAt(0).toUpperCase()+s.slice(1)},throw(s){throw new Error(KONVA_ERROR+s)},error(s){console.error(KONVA_ERROR+s)},warn(s){Konva$2.showWarnings&&console.warn(KONVA_WARNING+s)},each(s,e){for(var t in s)e(t,s[t])},_inRange(s,e,t){return e<=s&&s<t},_getProjectionToSegment(s,e,t,n,r,o){var a,u,d,h=(s-t)*(s-t)+(e-n)*(e-n);if(h==0)a=s,u=e,d=(r-t)*(r-t)+(o-n)*(o-n);else{var p=((r-s)*(t-s)+(o-e)*(n-e))/h;p<0?(a=s,u=e,d=(s-r)*(s-r)+(e-o)*(e-o)):p>1?(a=t,u=n,d=(t-r)*(t-r)+(n-o)*(n-o)):(a=s+p*(t-s),u=e+p*(n-e),d=(a-r)*(a-r)+(u-o)*(u-o))}return[a,u,d]},_getProjectionToLine(s,e,t){var n=Util.cloneObject(s),r=Number.MAX_VALUE;return e.forEach(function(o,a){if(!(!t&&a===e.length-1)){var u=e[(a+1)%e.length],d=Util._getProjectionToSegment(o.x,o.y,u.x,u.y,s.x,s.y),h=d[0],p=d[1],l=d[2];l<r&&(n.x=h,n.y=p,r=l)}}),n},_prepareArrayForTween(s,e,t){var n,r=[],o=[];if(s.length>e.length){var a=e;e=s,s=a}for(n=0;n<s.length;n+=2)r.push({x:s[n],y:s[n+1]});for(n=0;n<e.length;n+=2)o.push({x:e[n],y:e[n+1]});var u=[];return o.forEach(function(d){var h=Util._getProjectionToLine(d,r,t);u.push(h.x),u.push(h.y)}),u},_prepareToStringify(s){var e;s.visitedByCircularReferenceRemoval=!0;for(var t in s)if(s.hasOwnProperty(t)&&s[t]&&typeof s[t]=="object"){if(e=Object.getOwnPropertyDescriptor(s,t),s[t].visitedByCircularReferenceRemoval||Util._isElement(s[t]))if(e.configurable)delete s[t];else return null;else if(Util._prepareToStringify(s[t])===null)if(e.configurable)delete s[t];else return null}return delete s.visitedByCircularReferenceRemoval,s},_assign(s,e){for(var t in e)s[t]=e[t];return s},_getFirstPointerId(s){return s.touches?s.changedTouches[0].identifier:s.pointerId||999},releaseCanvas(...s){Konva$2.releaseCanvasOnDestroy&&s.forEach(e=>{e.width=0,e.height=0})},drawRoundedRectPath(s,e,t,n){let r=0,o=0,a=0,u=0;typeof n=="number"?r=o=a=u=Math.min(n,e/2,t/2):(r=Math.min(n[0]||0,e/2,t/2),o=Math.min(n[1]||0,e/2,t/2),u=Math.min(n[2]||0,e/2,t/2),a=Math.min(n[3]||0,e/2,t/2)),s.moveTo(r,0),s.lineTo(e-o,0),s.arc(e-o,o,o,Math.PI*3/2,0,!1),s.lineTo(e,t-u),s.arc(e-u,t-u,u,0,Math.PI/2,!1),s.lineTo(a,t),s.arc(a,t-a,a,Math.PI/2,Math.PI,!1),s.lineTo(0,r),s.arc(r,r,r,Math.PI,Math.PI*3/2,!1)}};function _formatValue(s){return Util._isString(s)?'"'+s+'"':Object.prototype.toString.call(s)==="[object Number]"||Util._isBoolean(s)?s:Object.prototype.toString.call(s)}function RGBComponent(s){return s>255?255:s<0?0:Math.round(s)}function getNumberValidator(){if(Konva$2.isUnminified)return function(s,e){return Util._isNumber(s)||Util.warn(_formatValue(s)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),s}}function getNumberOrArrayOfNumbersValidator(s){if(Konva$2.isUnminified)return function(e,t){let n=Util._isNumber(e),r=Util._isArray(e)&&e.length==s;return!n&&!r&&Util.warn(_formatValue(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or Array<number>('+s+")"),e}}function getNumberOrAutoValidator(){if(Konva$2.isUnminified)return function(s,e){var t=Util._isNumber(s),n=s==="auto";return t||n||Util.warn(_formatValue(s)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),s}}function getStringValidator(){if(Konva$2.isUnminified)return function(s,e){return Util._isString(s)||Util.warn(_formatValue(s)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),s}}function getStringOrGradientValidator(){if(Konva$2.isUnminified)return function(s,e){const t=Util._isString(s),n=Object.prototype.toString.call(s)==="[object CanvasGradient]"||s&&s.addColorStop;return t||n||Util.warn(_formatValue(s)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),s}}function getNumberArrayValidator(){if(Konva$2.isUnminified)return function(s,e){const t=Int8Array?Object.getPrototypeOf(Int8Array):null;return t&&s instanceof t||(Util._isArray(s)?s.forEach(function(n){Util._isNumber(n)||Util.warn('"'+e+'" attribute has non numeric element '+n+". Make sure that all elements are numbers.")}):Util.warn(_formatValue(s)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),s}}function getBooleanValidator(){if(Konva$2.isUnminified)return function(s,e){var t=s===!0||s===!1;return t||Util.warn(_formatValue(s)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),s}}function getComponentValidator(s){if(Konva$2.isUnminified)return function(e,t){return e==null||Util.isObject(e)||Util.warn(_formatValue(e)+' is a not valid value for "'+t+'" attribute. The value should be an object with properties '+s),e}}var GET="get",SET$1="set";const Factory={addGetterSetter(s,e,t,n,r){Factory.addGetter(s,e,t),Factory.addSetter(s,e,n,r),Factory.addOverloadedGetterSetter(s,e)},addGetter(s,e,t){var n=GET+Util._capitalize(e);s.prototype[n]=s.prototype[n]||function(){var r=this.attrs[e];return r===void 0?t:r}},addSetter(s,e,t,n){var r=SET$1+Util._capitalize(e);s.prototype[r]||Factory.overWriteSetter(s,e,t,n)},overWriteSetter(s,e,t,n){var r=SET$1+Util._capitalize(e);s.prototype[r]=function(o){return t&&o!==void 0&&o!==null&&(o=t.call(this,o,e)),this._setAttr(e,o),n&&n.call(this),this}},addComponentsGetterSetter(s,e,t,n,r){var o=t.length,a=Util._capitalize,u=GET+a(e),d=SET$1+a(e),h,p;s.prototype[u]=function(){var i={};for(h=0;h<o;h++)p=t[h],i[p]=this.getAttr(e+a(p));return i};var l=getComponentValidator(t);s.prototype[d]=function(i){var c=this.attrs[e],f;n&&(i=n.call(this,i)),l&&l.call(this,i,e);for(f in i)i.hasOwnProperty(f)&&this._setAttr(e+a(f),i[f]);return i||t.forEach(g=>{this._setAttr(e+a(g),void 0)}),this._fireChangeEvent(e,c,i),r&&r.call(this),this},Factory.addOverloadedGetterSetter(s,e)},addOverloadedGetterSetter(s,e){var t=Util._capitalize(e),n=SET$1+t,r=GET+t;s.prototype[e]=function(){return arguments.length?(this[n](arguments[0]),this):this[r]()}},addDeprecatedGetterSetter(s,e,t,n){Util.error("Adding deprecated "+e);var r=GET+Util._capitalize(e),o=e+" property is deprecated and will be removed soon. Look at Konva change log for more information.";s.prototype[r]=function(){Util.error(o);var a=this.attrs[e];return a===void 0?t:a},Factory.addSetter(s,e,n,function(){Util.error(o)}),Factory.addOverloadedGetterSetter(s,e)},backCompat(s,e){Util.each(e,function(t,n){var r=s.prototype[n],o=GET+Util._capitalize(t),a=SET$1+Util._capitalize(t);function u(){r.apply(this,arguments),Util.error('"'+t+'" method is deprecated and will be removed soon. Use ""'+n+'" instead.')}s.prototype[t]=u,s.prototype[o]=u,s.prototype[a]=u})},afterSetFilter(){this._filterUpToDate=!1}};function simplifyArray(s){var e=[],t=s.length,n=Util,r,o;for(r=0;r<t;r++)o=s[r],n._isNumber(o)?o=Math.round(o*1e3)/1e3:n._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,t){var n=this.traceArr,r=n.length,o="",a,u,d,h;for(a=0;a<r;a++)u=n[a],d=u.method,d?(h=u.args,o+=d,e?o+=DOUBLE_PAREN:Util._isArray(h[0])?o+=OPEN_PAREN_BRACKET+h.join(COMMA)+CLOSE_BRACKET_PAREN:(t&&(h=h.map(p=>typeof p=="number"?Math.floor(p):p)),o+=OPEN_PAREN+h.join(COMMA)+CLOSE_PAREN)):(o+=u.property,e||(o+=EQUALS+u.val)),o+=SEMICOLON;return o}clearTrace(){this.traceArr=[]}_trace(e){var t=this.traceArr,n;t.push(e),n=t.length,n>=traceArrMax&&t.shift()}reset(){var e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){var t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_applyLineCap(e){const t=e.attrs.lineCap;t&&this.setAttr("lineCap",t)}_applyOpacity(e){var t=e.getAbsoluteOpacity();t!==1&&this.setAttr("globalAlpha",t)}_applyLineJoin(e){const t=e.attrs.lineJoin;t&&this.setAttr("lineJoin",t)}setAttr(e,t){this._context[e]=t}arc(e,t,n,r,o,a){this._context.arc(e,t,n,r,o,a)}arcTo(e,t,n,r,o){this._context.arcTo(e,t,n,r,o)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,r,o,a){this._context.bezierCurveTo(e,t,n,r,o,a)}clearRect(e,t,n,r){this._context.clearRect(e,t,n,r)}clip(){this._context.clip()}closePath(){this._context.closePath()}createImageData(e,t){var n=arguments;if(n.length===2)return this._context.createImageData(e,t);if(n.length===1)return this._context.createImageData(e)}createLinearGradient(e,t,n,r){return this._context.createLinearGradient(e,t,n,r)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,n,r,o,a){return this._context.createRadialGradient(e,t,n,r,o,a)}drawImage(e,t,n,r,o,a,u,d,h){var p=arguments,l=this._context;p.length===3?l.drawImage(e,t,n):p.length===5?l.drawImage(e,t,n,r,o):p.length===9&&l.drawImage(e,t,n,r,o,a,u,d,h)}ellipse(e,t,n,r,o,a,u,d){this._context.ellipse(e,t,n,r,o,a,u,d)}isPointInPath(e,t,n,r){return n?this._context.isPointInPath(n,e,t,r):this._context.isPointInPath(e,t,r)}fill(e){e?this._context.fill(e):this._context.fill()}fillRect(e,t,n,r){this._context.fillRect(e,t,n,r)}strokeRect(e,t,n,r){this._context.strokeRect(e,t,n,r)}fillText(e,t,n,r){r?this._context.fillText(e,t,n,r):this._context.fillText(e,t,n)}measureText(e){return this._context.measureText(e)}getImageData(e,t,n,r){return this._context.getImageData(e,t,n,r)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,n,r){this._context.rect(e,t,n,r)}putImageData(e,t,n){this._context.putImageData(e,t,n)}quadraticCurveTo(e,t,n,r){this._context.quadraticCurveTo(e,t,n,r)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}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,t,n,r,o,a){this._context.setTransform(e,t,n,r,o,a)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,n,r){this._context.strokeText(e,t,n,r)}transform(e,t,n,r,o,a){this._context.transform(e,t,n,r,o,a)}translate(e,t){this._context.translate(e,t)}_enableTrace(){var e=this,t=CONTEXT_METHODS.length,n=this.setAttr,r,o,a=function(u){var d=e[u],h;e[u]=function(){return o=simplifyArray(Array.prototype.slice.call(arguments,0)),h=d.apply(e,arguments),e._trace({method:u,args:o}),h}};for(r=0;r<t;r++)a(CONTEXT_METHODS[r]);e.setAttr=function(){n.apply(e,arguments);var u=arguments[0],d=arguments[1];(u==="shadowOffsetX"||u==="shadowOffsetY"||u==="shadowBlur")&&(d=d/this.canvas.getPixelRatio()),e._trace({property:u,val:d})}}_applyGlobalCompositeOperation(e){const t=e.attrs.globalCompositeOperation;var n=!t||t==="source-over";n||this.setAttr("globalCompositeOperation",t)}}CONTEXT_PROPERTIES.forEach(function(s){Object.defineProperty(Context.prototype,s,{get(){return this._context[s]},set(e){this._context[s]=e}})});class SceneContext extends Context{constructor(e){super(e),this._context=e._canvas.getContext("2d")}_fillColor(e){var t=e.fill();this.setAttr("fillStyle",t),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){var t=e._getLinearGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fillRadialGradient(e){const t=e._getRadialGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fill(e){const t=e.fill(),n=e.getFillPriority();if(t&&n==="color"){this._fillColor(e);return}const r=e.getFillPatternImage();if(r&&n==="pattern"){this._fillPattern(e);return}const o=e.getFillLinearGradientColorStops();if(o&&n==="linear-gradient"){this._fillLinearGradient(e);return}const a=e.getFillRadialGradientColorStops();if(a&&n==="radial-gradient"){this._fillRadialGradient(e);return}t?this._fillColor(e):r?this._fillPattern(e):o?this._fillLinearGradient(e):a&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const t=e.getStrokeLinearGradientStartPoint(),n=e.getStrokeLinearGradientEndPoint(),r=e.getStrokeLinearGradientColorStops(),o=this.createLinearGradient(t.x,t.y,n.x,n.y);if(r){for(var a=0;a<r.length;a+=2)o.addColorStop(r[a],r[a+1]);this.setAttr("strokeStyle",o)}}_stroke(e){var t=e.dash(),n=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!n){this.save();var r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(e),t&&e.dashEnabled()&&(this.setLineDash(t),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),n||this.restore()}}_applyShadow(e){var t,n,r,o=(t=e.getShadowRGBA())!==null&&t!==void 0?t:"black",a=(n=e.getShadowBlur())!==null&&n!==void 0?n:5,u=(r=e.getShadowOffset())!==null&&r!==void 0?r:{x:0,y:0},d=e.getAbsoluteScale(),h=this.canvas.getPixelRatio(),p=d.x*h,l=d.y*h;this.setAttr("shadowColor",o),this.setAttr("shadowBlur",a*Math.min(Math.abs(p),Math.abs(l))),this.setAttr("shadowOffsetX",u.x*p),this.setAttr("shadowOffsetY",u.y*l)}}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 t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(e);var n=e.hitStrokeWidth(),r=n==="auto"?e.strokeWidth():n;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),o||this.restore()}}}var _pixelRatio;function getDevicePixelRatio(){if(_pixelRatio)return _pixelRatio;var s=Util.createCanvasElement(),e=s.getContext("2d");return _pixelRatio=function(){var t=Konva$2._global.devicePixelRatio||1,n=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return t/n}(),Util.releaseCanvas(s),_pixelRatio}class Canvas{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var t=e||{},n=t.pixelRatio||Konva$2.pixelRatio||getDevicePixelRatio();this.pixelRatio=n,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 t=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/t,this.getHeight()/t)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";var t=this.pixelRatio,n=this.getContext()._context;n.scale(t,t)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";var t=this.pixelRatio,n=this.getContext()._context;n.scale(t,t)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,t){this.setWidth(e||0),this.setHeight(t||0)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch{try{return this._canvas.toDataURL()}catch(r){return Util.error("Unable to get data URL. "+r.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 s=!1;return DD._dragElements.forEach(e=>{e.dragStatus==="dragging"&&(s=!0)}),s},justDragged:!1,get node(){var s;return DD._dragElements.forEach(e=>{s=e.node}),s},_dragElements:new Map,_drag(s){const e=[];DD._dragElements.forEach((t,n)=>{const{node:r}=t,o=r.getStage();o.setPointersPositions(s),t.pointerId===void 0&&(t.pointerId=Util._getFirstPointerId(s));const a=o._changedPointerPositions.find(h=>h.id===t.pointerId);if(a){if(t.dragStatus!=="dragging"){var u=r.dragDistance(),d=Math.max(Math.abs(a.x-t.startPointerPos.x),Math.abs(a.y-t.startPointerPos.y));if(d<u||(r.startDrag({evt:s}),!r.isDragging()))return}r._setDragPosition(s,t),e.push(r)}}),e.forEach(t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:s},!0)})},_endDragBefore(s){const e=[];DD._dragElements.forEach(t=>{const{node:n}=t,r=n.getStage();if(s&&r.setPointersPositions(s),!r._changedPointerPositions.find(u=>u.id===t.pointerId))return;(t.dragStatus==="dragging"||t.dragStatus==="stopped")&&(DD.justDragged=!0,Konva$2._mouseListenClick=!1,Konva$2._touchListenClick=!1,Konva$2._pointerListenClick=!1,t.dragStatus="stopped");const a=t.node.getLayer()||t.node instanceof Konva$2.Stage&&t.node;a&&e.indexOf(a)===-1&&e.push(a)}),e.forEach(t=>{t.draw()})},_endDragAfter(s){DD._dragElements.forEach((e,t)=>{e.dragStatus==="stopped"&&e.node.fire("dragend",{type:"dragend",target:e.node,evt:s},!0),e.dragStatus!=="dragging"&&DD._dragElements.delete(t)})}};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,t){var n=this._cache.get(e),r=e===TRANSFORM||e===ABSOLUTE_TRANSFORM,o=n===void 0||r&&n.dirty===!0;return o&&(n=t.call(this),this._cache.set(e,n)),n}_calculate(e,t,n){if(!this._attachedDepsListeners.get(e)){const r=t.map(o=>o+"Change.konva").join(SPACE$1);this.on(r,()=>{this._clearCache(e)}),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,n)}_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:t,hit:n}=this._cache.get(CANVAS);Util.releaseCanvas(e,t,n),this._cache.delete(CANVAS)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){var t=e||{},n={};(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0)&&(n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()}));var r=Math.ceil(t.width||n.width),o=Math.ceil(t.height||n.height),a=t.pixelRatio,u=t.x===void 0?Math.floor(n.x):t.x,d=t.y===void 0?Math.floor(n.y):t.y,h=t.offset||0,p=t.drawBorder||!1,l=t.hitCanvasPixelRatio||1;if(!r||!o){Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}r+=h*2+1,o+=h*2+1,u-=h,d-=h;var i=new SceneCanvas({pixelRatio:a,width:r,height:o}),c=new SceneCanvas({pixelRatio:a,width:0,height:0}),f=new HitCanvas({pixelRatio:l,width:r,height:o}),g=i.getContext(),m=f.getContext();return f.isCache=!0,i.isCache=!0,this._cache.delete(CANVAS),this._filterUpToDate=!1,t.imageSmoothingEnabled===!1&&(i.getContext()._context.imageSmoothingEnabled=!1,c.getContext()._context.imageSmoothingEnabled=!1),g.save(),m.save(),g.translate(-u,-d),m.translate(-u,-d),this._isUnderCache=!0,this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY),this._clearSelfAndDescendantCache(ABSOLUTE_SCALE),this.drawScene(i,this),this.drawHit(f,this),this._isUnderCache=!1,g.restore(),m.restore(),p&&(g.save(),g.beginPath(),g.rect(0,0,r,o),g.closePath(),g.setAttr("strokeStyle","red"),g.setAttr("lineWidth",5),g.stroke(),g.restore()),this._cache.set(CANVAS,{scene:i,filter:c,hit:f,x:u,y:d}),this._requestDraw(),this}isCached(){return this._cache.has(CANVAS)}getClientRect(e){throw new Error('abstract "getClientRect" method call')}_transformedRect(e,t){var n=[{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}],r,o,a,u,d=this.getAbsoluteTransform(t);return n.forEach(function(h){var p=d.point(h);r===void 0&&(r=a=p.x,o=u=p.y),r=Math.min(r,p.x),o=Math.min(o,p.y),a=Math.max(a,p.x),u=Math.max(u,p.y)}),{x:r,y:o,width:a-r,height:u-o}}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);const t=this._getCanvasCache();e.translate(t.x,t.y);var n=this._getCachedSceneCanvas(),r=n.pixelRatio;e.drawImage(n._canvas,0,0,n.width/r,n.height/r),e.restore()}_drawCachedHitCanvas(e){var t=this._getCanvasCache(),n=t.hit;e.save(),e.translate(t.x,t.y),e.drawImage(n._canvas,0,0,n.width/n.pixelRatio,n.height/n.pixelRatio),e.restore()}_getCachedSceneCanvas(){var e=this.filters(),t=this._getCanvasCache(),n=t.scene,r=t.filter,o=r.getContext(),a,u,d,h;if(e){if(!this._filterUpToDate){var p=n.pixelRatio;r.setSize(n.width/n.pixelRatio,n.height/n.pixelRatio);try{for(a=e.length,o.clear(),o.drawImage(n._canvas,0,0,n.getWidth()/p,n.getHeight()/p),u=o.getImageData(0,0,r.getWidth(),r.getHeight()),d=0;d<a;d++){if(h=e[d],typeof h!="function"){Util.error("Filter should be type of function, but got "+typeof h+" instead. Please check correct filters");continue}h.call(this,u),o.putImageData(u,0,0)}}catch(l){Util.error("Unable to apply filter. "+l.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return r}return n}on(e,t){if(this._cache&&this._cache.delete(ALL_LISTENERS),arguments.length===3)return this._delegate.apply(this,arguments);var n=e.split(SPACE$1),r=n.length,o,a,u,d,h;for(o=0;o<r;o++)a=n[o],u=a.split("."),d=u[0],h=u[1]||"",this.eventListeners[d]||(this.eventListeners[d]=[]),this.eventListeners[d].push({name:h,handler:t});return this}off(e,t){var n=(e||"").split(SPACE$1),r=n.length,o,a,u,d,h,p;if(this._cache&&this._cache.delete(ALL_LISTENERS),!e)for(a in this.eventListeners)this._off(a);for(o=0;o<r;o++)if(u=n[o],d=u.split("."),h=d[0],p=d[1],h)this.eventListeners[h]&&this._off(h,p,t);else for(a in this.eventListeners)this._off(a,p,t);return this}dispatchEvent(e){var t={target:this,type:e.type,evt:e};return this.fire(e.type,t),this}addEventListener(e,t){return this.on(e,function(n){t.call(this,n.evt)}),this}removeEventListener(e){return this.off(e),this}_delegate(e,t,n){var r=this;this.on(e,function(o){for(var a=o.target.findAncestors(t,!0,r),u=0;u<a.length;u++)o=Util.cloneObject(o),o.currentTarget=a[u],n.call(a[u],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 t="get"+Util._capitalize(e);return Util._isFunction(this[t])?this[t]():this.attrs[e]}getAncestors(){for(var e=this.getParent(),t=[];e;)t.push(e),e=e.getParent();return t}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges(()=>{var t,n;if(!e)return this;for(t in e)t!==CHILDREN&&(n=SET+Util._capitalize(t),Util._isFunction(this[n])?this[n](e[t]):this._setAttr(t,e[t]))}),this}isListening(){return this._getCache(LISTENING,this._isListening)}_isListening(e){if(!this.listening())return!1;const n=this.getParent();return n&&n!==e&&this!==e?n._isListening(e):!0}isVisible(){return this._getCache(VISIBLE,this._isVisible)}_isVisible(e){if(!this.visible())return!1;const n=this.getParent();return n&&n!==e&&this!==e?n._isVisible(e):!0}shouldDrawHit(e,t=!1){if(e)return this._isVisible(e)&&this._isListening(e);var n=this.getLayer(),r=!1;DD._dragElements.forEach(a=>{a.dragStatus==="dragging"&&(a.node.nodeType==="Stage"||a.node.getLayer()===n)&&(r=!0)});var o=!t&&!Konva$2.hitOnDragEnabled&&r;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(),t=this,n=0,r,o,a,u;function d(h){for(r=[],o=h.length,a=0;a<o;a++)u=h[a],n++,u.nodeType!==SHAPE&&(r=r.concat(u.getChildren().slice())),u._id===t._id&&(a=o);r.length>0&&r[0].getDepth()<=e&&d(r)}return t.nodeType!==UPPER_STAGE&&d(t.getStage().getChildren()),n}getDepth(){for(var e=0,t=this.parent;t;)e++,t=t.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 t=this.getAbsoluteTransform().copy();return t.invert(),t.point(e)}getAbsolutePosition(e){let t=!1,n=this.parent;for(;n;){if(n.isCached()){t=!0;break}n=n.parent}t&&!e&&(e=!0);var r=this.getAbsoluteTransform(e).getMatrix(),o=new Transform,a=this.offset();return o.m=r.slice(),o.translate(a.x,a.y),o.getTranslation()}setAbsolutePosition(e){var t=this._clearTransform();this.attrs.x=t.x,this.attrs.y=t.y,delete t.x,delete t.y,this._clearCache(TRANSFORM);var n=this._getAbsoluteTransform().copy();return n.invert(),n.translate(e.x,e.y),e={x:this.attrs.x+n.getTranslation().x,y:this.attrs.y+n.getTranslation().y},this._setTransform(t),this.setPosition({x:e.x,y:e.y}),this._clearCache(TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM),this}_setTransform(e){var t;for(t in e)this.attrs[t]=e[t]}_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 t=e.x,n=e.y,r=this.x(),o=this.y();return t!==void 0&&(r+=t),n!==void 0&&(o+=n),this.setPosition({x:r,y:o}),this}_eachAncestorReverse(e,t){var n=[],r=this.getParent(),o,a;if(!(t&&t._id===this._id)){for(n.unshift(this);r&&(!t||r._id!==t._id);)n.unshift(r),r=r.parent;for(o=n.length,a=0;a<o;a++)e(n[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,t=this.parent.getChildren().length;return e<t-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,t=this.parent.getChildren().length;return e<t-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 t=this.index;return this.parent.children.splice(t,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(),t=this.getParent();return t&&!t._isUnderCache&&(e*=t.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){var e={},t=this.getAttrs(),n,r,o,a,u;e.attrs={};for(n in t)r=t[n],u=Util.isObject(r)&&!Util._isPlainObject(r)&&!Util._isArray(r),!u&&(o=typeof this[n]=="function"&&this[n],delete t[n],a=o?o.call(this):null,t[n]=r,a!==r&&(e.attrs[n]=r));return e.className=this.getClassName(),Util._prepareToStringify(e)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,t,n){var r=[];t&&this._isMatch(e)&&r.push(this);for(var o=this.parent;o;){if(o===n)return r;o._isMatch(e)&&r.push(o),o=o.parent}return r}isAncestorOf(e){return!1}findAncestor(e,t,n){return this.findAncestors(e,t,n)[0]}_isMatch(e){if(!e)return!1;if(typeof e=="function")return e(this);var t=e.replace(/ /g,"").split(","),n=t.length,r,o;for(r=0;r<n;r++)if(o=t[r],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,t={},n){return t.target=t.target||this,n?this._fireAndBubble(e,t):this._fire(e,t),this}getAbsoluteTransform(e){return e?this._getAbsoluteTransform(e):this._getCache(ABSOLUTE_TRANSFORM,this._getAbsoluteTransform)}_getAbsoluteTransform(e){var t;if(e)return t=new Transform,this._eachAncestorReverse(function(r){var o=r.transformsEnabled();o==="all"?t.multiply(r.getTransform()):o==="position"&&t.translate(r.x()-r.offsetX(),r.y()-r.offsetY())},e),t;t=this._cache.get(ABSOLUTE_TRANSFORM)||new Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(t):t.reset();var n=this.transformsEnabled();if(n==="all")t.multiply(this.getTransform());else if(n==="position"){const r=this.attrs.x||0,o=this.attrs.y||0,a=this.attrs.offsetX||0,u=this.attrs.offsetY||0;t.translate(r-a,o-u)}return t.dirty=!1,t}getAbsoluteScale(e){for(var t=this;t;)t._isUnderCache&&(e=t),t=t.getParent();const r=this.getAbsoluteTransform(e).decompose();return{x:r.scaleX,y:r.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(TRANSFORM,this._getTransform)}_getTransform(){var e,t,n=this._cache.get(TRANSFORM)||new Transform;n.reset();var r=this.x(),o=this.y(),a=Konva$2.getAngle(this.rotation()),u=(e=this.attrs.scaleX)!==null&&e!==void 0?e:1,d=(t=this.attrs.scaleY)!==null&&t!==void 0?t:1,h=this.attrs.skewX||0,p=this.attrs.skewY||0,l=this.attrs.offsetX||0,i=this.attrs.offsetY||0;return(r!==0||o!==0)&&n.translate(r,o),a!==0&&n.rotate(a),(h!==0||p!==0)&&n.skew(h,p),(u!==1||d!==1)&&n.scale(u,d),(l!==0||i!==0)&&n.translate(-1*l,-1*i),n.dirty=!1,n}clone(e){var t=Util.cloneObject(this.attrs),n,r,o,a,u;for(n in e)t[n]=e[n];var d=new this.constructor(t);for(n in this.eventListeners)for(r=this.eventListeners[n],o=r.length,a=0;a<o;a++)u=r[a],u.name.indexOf(KONVA)<0&&(d.eventListeners[n]||(d.eventListeners[n]=[]),d.eventListeners[n].push(u));return d}_toKonvaCanvas(e){e=e||{};var t=this.getClientRect(),n=this.getStage(),r=e.x!==void 0?e.x:Math.floor(t.x),o=e.y!==void 0?e.y:Math.floor(t.y),a=e.pixelRatio||1,u=new SceneCanvas({width:e.width||Math.ceil(t.width)||(n?n.width():0),height:e.height||Math.ceil(t.height)||(n?n.height():0),pixelRatio:a}),d=u.getContext();return e.imageSmoothingEnabled===!1&&(d._context.imageSmoothingEnabled=!1),d.save(),(r||o)&&d.translate(-1*r,-1*o),this.drawScene(u),d.restore(),u}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){e=e||{};var t=e.mimeType||null,n=e.quality||null,r=this._toKonvaCanvas(e).toDataURL(t,n);return e.callback&&e.callback(r),r}toImage(e){return new Promise((t,n)=>{try{const r=e==null?void 0:e.callback;r&&delete e.callback,Util._urlToImage(this.toDataURL(e),function(o){t(o),r==null||r(o)})}catch(r){n(r)}})}toBlob(e){return new Promise((t,n)=>{try{const r=e==null?void 0:e.callback;r&&delete e.callback,this.toCanvas(e).toBlob(o=>{t(o),r==null||r(o)})}catch(r){n(r)}})}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,t,n){var r=this.eventListeners[e],o,a,u;for(o=0;o<r.length;o++)if(a=r[o].name,u=r[o].handler,(a!=="konva"||t==="konva")&&(!t||a===t)&&(!n||n===u)){if(r.splice(o,1),r.length===0){delete this.eventListeners[e];break}o--}}_fireChangeEvent(e,t,n){this._fire(e+CHANGE,{oldVal:t,newVal:n})}addName(e){if(!this.hasName(e)){var t=this.name(),n=t?t+" "+e:e;this.name(n)}return this}hasName(e){if(!e)return!1;const t=this.name();if(!t)return!1;var n=(t||"").split(/\s/g);return n.indexOf(e)!==-1}removeName(e){var t=(this.name()||"").split(/\s/g),n=t.indexOf(e);return n!==-1&&(t.splice(n,1),this.name(t.join(" "))),this}setAttr(e,t){var n=this[SET+Util._capitalize(e)];return Util._isFunction(n)?n.call(this,t):this._setAttr(e,t),this}_requestDraw(){if(Konva$2.autoDrawEnabled){const e=this.getLayer()||this.getStage();e==null||e.batchDraw()}}_setAttr(e,t){var n=this.attrs[e];n===t&&!Util.isObject(t)||(t==null?delete this.attrs[e]:this.attrs[e]=t,this._shouldFireChangeEvents&&this._fireChangeEvent(e,n,t),this._requestDraw())}_setComponentAttr(e,t,n){var r;n!==void 0&&(r=this.attrs[e],r||(this.attrs[e]=this.getAttr(e)),this.attrs[e][t]=n,this._fireChangeEvent(e,r,n))}_fireAndBubble(e,t,n){t&&this.nodeType===SHAPE&&(t.target=this);var r=(e===MOUSEENTER$1||e===MOUSELEAVE$1)&&(n&&(this===n||this.isAncestorOf&&this.isAncestorOf(n))||this.nodeType==="Stage"&&!n);if(!r){this._fire(e,t);var o=(e===MOUSEENTER$1||e===MOUSELEAVE$1)&&n&&n.isAncestorOf&&n.isAncestorOf(this)&&!n.isAncestorOf(this.parent);(t&&!t.cancelBubble||!t)&&this.parent&&this.parent.isListening()&&!o&&(n&&n.parent?this._fireAndBubble.call(this.parent,e,t,n):this._fireAndBubble.call(this.parent,e,t))}}_getProtoListeners(e){let t=this._cache.get(ALL_LISTENERS);if(!t){t={};let r=Object.getPrototypeOf(this);for(;r;){if(!r.eventListeners){r=Object.getPrototypeOf(r);continue}for(var n in r.eventListeners){const o=r.eventListeners[n],a=t[n]||[];t[n]=o.concat(a)}r=Object.getPrototypeOf(r)}this._cache.set(ALL_LISTENERS,t)}return t[e]}_fire(e,t){t=t||{},t.currentTarget=this,t.type=e;const n=this._getProtoListeners(e);if(n)for(var r=0;r<n.length;r++)n[r].handler.call(this,t);const o=this.eventListeners[e];if(o)for(var r=0;r<o.length;r++)o[r].handler.call(this,t)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(e){var t=e?e.pointerId:void 0,n=this.getStage(),r=this.getAbsolutePosition(),o=n._getPointerById(t)||n._changedPointerPositions[0]||r;DD._dragElements.set(this._id,{node:this,startPointerPos:o,offset:{x:o.x-r.x,y:o.y-r.y},dragStatus:"ready",pointerId:t})}startDrag(e,t=!0){DD._dragElements.has(this._id)||this._createDragElement(e);const n=DD._dragElements.get(this._id);n.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:e&&e.evt},t)}_setDragPosition(e,t){const n=this.getStage()._getPointerById(t.pointerId);if(n){var r={x:n.x-t.offset.x,y:n.y-t.offset.y},o=this.dragBoundFunc();if(o!==void 0){const a=o.call(this,r,e);a?r=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!==r.x||this._lastPos.y!==r.y)&&(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}}stopDrag(e){const t=DD._dragElements.get(this._id);t&&(t.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 t=e.evt.button!==void 0,n=!t||Konva$2.dragButtons.indexOf(e.evt.button)>=0;if(n&&!this.isDragging()){var r=!1;DD._dragElements.forEach(o=>{this.isAncestorOf(o.node)&&(r=!0)}),r||this._createDragElement(e)}})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();var e=this.getStage();if(!e)return;const t=DD._dragElements.get(this._id),n=t&&t.dragStatus==="dragging",r=t&&t.dragStatus==="ready";n?this.stopDrag():r&&DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const t=this.getStage();if(!t)return!1;const n={x:-e.x,y:-e.y,width:t.width()+2*e.x,height:t.height()+2*e.y};return Util.haveIntersection(n,this.getClientRect())}static create(e,t){return Util._isString(e)&&(e=JSON.parse(e)),this._createNode(e,t)}static _createNode(e,t){var n=Node.prototype.getClassName.call(e),r=e.children,o,a,u;t&&(e.attrs.container=t),Konva$2[n]||(Util.warn('Can not find a node with class name "'+n+'". Fallback to "Shape".'),n="Shape");const d=Konva$2[n];if(o=new d(e.attrs),r)for(a=r.length,u=0;u<a;u++)o.add(Node._createNode(r[u]));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(s){return this._filterUpToDate=!1,s});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 t=this.children||[];var n=[];return t.forEach(function(r){e(r)&&n.push(r)}),n}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 t=0;t<e.length;t++)this.add(e[t]);return this}const n=e[0];return n.getParent()?(n.moveTo(this),this):(this._validateAdd(n),n.index=this.getChildren().length,n.parent=this,n._clearCaches(),this.getChildren().push(n),this._fire("add",{child:n}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){var t=this._generalFind(e,!0);return t.length>0?t[0]:void 0}_generalFind(e,t){var n=[];return this._descendants(r=>{const o=r._isMatch(e);return o&&n.push(r),!!(o&&t)}),n}_descendants(e){let t=!1;const n=this.getChildren();for(const r of n){if(t=e(r),t)return!0;if(r.hasChildren()&&(t=r._descendants(e),t))return!0}return!1}toObject(){var e=Node.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(t=>{e.children.push(t.toObject())}),e}isAncestorOf(e){for(var t=e.getParent();t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){var t=Node.prototype.clone.call(this,e);return this.getChildren().forEach(function(n){t.add(n.clone())}),t}getAllIntersections(e){var t=[];return this.find("Shape").forEach(function(n){n.isVisible()&&n.intersects(e)&&t.push(n)}),t}_clearSelfAndDescendantCache(e){var t;super._clearSelfAndDescendantCache(e),!this.isCached()&&((t=this.children)===null||t===void 0||t.forEach(function(n){n._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)===null||e===void 0||e.forEach(function(t,n){t.index=n}),this._requestDraw()}drawScene(e,t){var n=this.getLayer(),r=e||n&&n.getCanvas(),o=r&&r.getContext(),a=this._getCanvasCache(),u=a&&a.scene,d=r&&r.isCache;if(!this.isVisible()&&!d)return this;if(u){o.save();var h=this.getAbsoluteTransform(t).getMatrix();o.transform(h[0],h[1],h[2],h[3],h[4],h[5]),this._drawCachedSceneCanvas(o),o.restore()}else this._drawChildren("drawScene",r,t);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;var n=this.getLayer(),r=e||n&&n.hitCanvas,o=r&&r.getContext(),a=this._getCanvasCache(),u=a&&a.hit;if(u){o.save();var d=this.getAbsoluteTransform(t).getMatrix();o.transform(d[0],d[1],d[2],d[3],d[4],d[5]),this._drawCachedHitCanvas(o),o.restore()}else this._drawChildren("drawHit",r,t);return this}_drawChildren(e,t,n){var r,o=t&&t.getContext(),a=this.clipWidth(),u=this.clipHeight(),d=this.clipFunc(),h=a&&u||d;const p=n===this;if(h){o.save();var l=this.getAbsoluteTransform(n),i=l.getMatrix();if(o.transform(i[0],i[1],i[2],i[3],i[4],i[5]),o.beginPath(),d)d.call(this,o,this);else{var c=this.clipX(),f=this.clipY();o.rect(c,f,a,u)}o.clip(),i=l.copy().invert().getMatrix(),o.transform(i[0],i[1],i[2],i[3],i[4],i[5])}var g=!p&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";g&&(o.save(),o._applyGlobalCompositeOperation(this)),(r=this.children)===null||r===void 0||r.forEach(function(m){m[e](t,n)}),g&&o.restore(),h&&o.restore()}getClientRect(e){var t;e=e||{};var n=e.skipTransform,r=e.relativeTo,o,a,u,d,h={x:1/0,y:1/0,width:0,height:0},p=this;(t=this.children)===null||t===void 0||t.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,u=m.x+m.width,d=m.y+m.height):(o=Math.min(o,m.x),a=Math.min(a,m.y),u=Math.max(u,m.x+m.width),d=Math.max(d,m.y+m.height)))}});for(var l=this.find("Shape"),i=!1,c=0;c<l.length;c++){var f=l[c];if(f._isVisible(this)){i=!0;break}}return i&&o!==void 0?h={x:o,y:a,width:u-o,height:d-a}:h={x:0,y:0,width:0,height:0},n?h:this._transformedRect(h,r)}};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(s){return Captures.get(s)}function createEvent(s){return{evt:s,pointerId:s.pointerId}}function hasPointerCapture(s,e){return Captures.get(s)===e}function setPointerCapture(s,e){releaseCapture(s),e.getStage()&&(Captures.set(s,e),SUPPORT_POINTER_EVENTS&&e._fire("gotpointercapture",createEvent(new PointerEvent("gotpointercapture"))))}function releaseCapture(s,e){const t=Captures.get(s);if(!t)return;const n=t.getStage();n&&n.content,Captures.delete(s),SUPPORT_POINTER_EVENTS&&t._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=s=>s.indexOf("pointer")>=0?"pointer":s.indexOf("touch")>=0?"touch":"mouse",getEventsMap=s=>{const e=getEventType(s);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(s={}){return(s.clipFunc||s.clipWidth||s.clipHeight)&&Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),s}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 t=e.getType()==="Layer",n=e.getType()==="FastLayer";t||n||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 t=e.slice(1);e=document.getElementsByClassName(t)[0]}else{var n;e.charAt(0)!=="#"?n=e:n=e.slice(1),e=document.getElementById(n)}if(!e)throw"Can not find container in document with id "+n}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,t=e.length,n;for(n=0;n<t;n++)e[n].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 t=stages.indexOf(this);return t>-1&&stages.splice(t,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(t=>t.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 t=new SceneCanvas({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),n=t.getContext()._context,r=this.children;return(e.x||e.y)&&n.translate(-1*e.x,-1*e.y),r.forEach(function(o){if(o.isVisible()){var a=o._toKonvaCanvas(e);n.drawImage(a._canvas,e.x,e.y,a.getWidth()/a.getPixelRatio(),a.getHeight()/a.getPixelRatio())}}),t}getIntersection(e){if(!e)return null;var t=this.children,n=t.length,r=n-1,o;for(o=r;o>=0;o--){const a=t[o].getIntersection(e);if(a)return a}return null}_resizeDOM(){var e=this.width(),t=this.height();this.content&&(this.content.style.width=e+PX,this.content.style.height=t+PX),this.bufferCanvas.setSize(e,t),this.bufferHitCanvas.setSize(e,t),this.children.forEach(n=>{n.setSize({width:e,height:t}),n.draw()})}add(e,...t){if(arguments.length>1){for(var n=0;n<arguments.length;n++)this.add(arguments[n]);return this}super.add(e);var r=this.children.length;return r>MAX_LAYERS_NUMBER&&Util.warn("The stage has "+r+" 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,t])=>{this.content.addEventListener(e,n=>{this[t](n)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);const t=getEventsMap(e.type);this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=getEventsMap(e.type);this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let t=this[e+"targetShape"];return t&&!t.getStage()&&(t=null),t}_pointerleave(e){const t=getEventsMap(e.type),n=getEventType(e.type);if(t){this.setPointersPositions(e);var r=this._getTargetShape(n),o=!DD.isDragging||Konva$2.hitOnDragEnabled;r&&o?(r._fireAndBubble(t.pointerout,{evt:e}),r._fireAndBubble(t.pointerleave,{evt:e}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this[n+"targetShape"]=null):o&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=void 0,this._pointerPositions=[]}}_pointerdown(e){const t=getEventsMap(e.type),n=getEventType(e.type);if(t){this.setPointersPositions(e);var r=!1;this._changedPointerPositions.forEach(o=>{var a=this.getIntersection(o);if(DD.justDragged=!1,Konva$2["_"+n+"ListenClick"]=!0,!(a&&a.isListening()))return;Konva$2.capturePointerEventsEnabled&&a.setPointerCapture(o.id),this[n+"ClickStartShape"]=a,a._fireAndBubble(t.pointerdown,{evt:e,pointerId:o.id}),r=!0;const d=e.type.indexOf("touch")>=0;a.preventDefault()&&e.cancelable&&d&&e.preventDefault()}),r||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(e){const t=getEventsMap(e.type),n=getEventType(e.type);if(!t)return;DD.isDragging&&DD.node.preventDefault()&&e.cancelable&&e.preventDefault(),this.setPointersPositions(e);var r=!DD.isDragging||Konva$2.hitOnDragEnabled;if(!r)return;var o={};let a=!1;var u=this._getTargetShape(n);this._changedPointerPositions.forEach(d=>{const h=getCapturedShape(d.id)||this.getIntersection(d),p=d.id,l={evt:e,pointerId:p};var i=u!==h;if(i&&u&&(u._fireAndBubble(t.pointerout,Object.assign({},l),h),u._fireAndBubble(t.pointerleave,Object.assign({},l),h)),h){if(o[h._id])return;o[h._id]=!0}h&&h.isListening()?(a=!0,i&&(h._fireAndBubble(t.pointerover,Object.assign({},l),u),h._fireAndBubble(t.pointerenter,Object.assign({},l),u),this[n+"targetShape"]=h),h._fireAndBubble(t.pointermove,Object.assign({},l))):u&&(this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:p}),this[n+"targetShape"]=null)}),a||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const t=getEventsMap(e.type),n=getEventType(e.type);if(!t)return;this.setPointersPositions(e);const r=this[n+"ClickStartShape"],o=this[n+"ClickEndShape"];var a={};let u=!1;this._changedPointerPositions.forEach(d=>{const h=getCapturedShape(d.id)||this.getIntersection(d);if(h){if(h.releaseCapture(d.id),a[h._id])return;a[h._id]=!0}const p=d.id,l={evt:e,pointerId:p};let i=!1;Konva$2["_"+n+"InDblClickWindow"]?(i=!0,clearTimeout(this[n+"DblTimeout"])):DD.justDragged||(Konva$2["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout(function(){Konva$2["_"+n+"InDblClickWindow"]=!1},Konva$2.dblClickWindow),h&&h.isListening()?(u=!0,this[n+"ClickEndShape"]=h,h._fireAndBubble(t.pointerup,Object.assign({},l)),Konva$2["_"+n+"ListenClick"]&&r&&r===h&&(h._fireAndBubble(t.pointerclick,Object.assign({},l)),i&&o&&o===h&&h._fireAndBubble(t.pointerdblclick,Object.assign({},l)))):(this[n+"ClickEndShape"]=null,Konva$2["_"+n+"ListenClick"]&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:p}),i&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:p}))}),u||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),Konva$2["_"+n+"ListenClick"]=!1,e.cancelable&&n!=="touch"&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);var t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(CONTEXTMENU,{evt:e}):this._fire(CONTEXTMENU,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);var t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(WHEEL,{evt:e}):this._fire(WHEEL,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=getCapturedShape(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(POINTERUP,createEvent(e)),releaseCapture(e.pointerId)}_lostpointercapture(e){releaseCapture(e.pointerId)}setPointersPositions(e){var t=this._getContentPosition(),n=null,r=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-t.left)/t.scaleX,y:(o.clientY-t.top)/t.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,o=>{this._changedPointerPositions.push({id:o.identifier,x:(o.clientX-t.left)/t.scaleX,y:(o.clientY-t.top)/t.scaleY})})):(n=(e.clientX-t.left)/t.scaleX,r=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:Util._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,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(s){s.fill()}function _strokeFunc$2(s){s.stroke()}function _fillFuncHit(s){s.fill()}function _strokeFuncHit(s){s.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 t;for(;t=Util.getRandomColor(),!(t&&!(t in shapes)););this.colorKey=t,shapes[t]=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 t=e.createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const n=new Transform;n.translate(this.fillPatternX(),this.fillPatternY()),n.rotate(Konva$2.getAngle(this.fillPatternRotation())),n.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),n.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const r=n.getMatrix(),o=typeof DOMMatrix>"u"?{a:r[0],b:r[1],c:r[2],d:r[3],e:r[4],f:r[5]}:new DOMMatrix(r);t.setTransform(o)}return t}}_getLinearGradient(){return this._getCache(linearGradient,this.__getLinearGradient)}__getLinearGradient(){var e=this.fillLinearGradientColorStops();if(e){for(var t=getDummyContext$1(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),o=t.createLinearGradient(n.x,n.y,r.x,r.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 t=getDummyContext$1(),n=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),o=t.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),r.x,r.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 t=this.getStage(),n=t.bufferHitCanvas,r;return n.getContext().clear(),this.drawHit(n,null,!0),r=n.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data,r[3]>0}destroy(){return Node.prototype.destroy.call(this),delete shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){var t;if(!this.getStage()||!((t=this.attrs.perfectDrawEnabled)!==null&&t!==void 0?t:!0))return!1;const r=e||this.hasFill(),o=this.hasStroke(),a=this.getAbsoluteOpacity()!==1;if(r&&o&&a)return!0;const u=this.hasShadow(),d=this.shadowForStrokeEnabled();return!!(r&&o&&u&&d)}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 t=e.skipTransform,n=e.relativeTo,r=this.getSelfRect(),a=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,u=r.width+a,d=r.height+a,h=!e.skipShadow&&this.hasShadow(),p=h?this.shadowOffsetX():0,l=h?this.shadowOffsetY():0,i=u+Math.abs(p),c=d+Math.abs(l),f=h&&this.shadowBlur()||0,g=i+f*2,m=c+f*2,_={width:g,height:m,x:-(a/2+f)+Math.min(p,0)+r.x,y:-(a/2+f)+Math.min(l,0)+r.y};return t?_:this._transformedRect(_,n)}drawScene(e,t){var n=this.getLayer(),r=e||n.getCanvas(),o=r.getContext(),a=this._getCanvasCache(),u=this.getSceneFunc(),d=this.hasShadow(),h,p,l,i=r.isCache,c=t===this;if(!this.isVisible()&&!c)return this;if(a){o.save();var f=this.getAbsoluteTransform(t).getMatrix();return o.transform(f[0],f[1],f[2],f[3],f[4],f[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!u)return this;if(o.save(),this._useBufferCanvas()&&!i){h=this.getStage(),p=h.bufferCanvas,l=p.getContext(),l.clear(),l.save(),l._applyLineJoin(this);var g=this.getAbsoluteTransform(t).getMatrix();l.transform(g[0],g[1],g[2],g[3],g[4],g[5]),u.call(this,l,this),l.restore();var m=p.pixelRatio;d&&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),!c){var g=this.getAbsoluteTransform(t).getMatrix();o.transform(g[0],g[1],g[2],g[3],g[4],g[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)}d&&o._applyShadow(this),u.call(this,o,this)}return o.restore(),this}drawHit(e,t,n=!1){if(!this.shouldDrawHit(t,n))return this;var r=this.getLayer(),o=e||r.hitCanvas,a=o&&o.getContext(),u=this.hitFunc()||this.sceneFunc(),d=this._getCanvasCache(),h=d&&d.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(t).getMatrix();return a.transform(p[0],p[1],p[2],p[3],p[4],p[5]),this._drawCachedHitCanvas(a),a.restore(),this}if(!u)return this;if(a.save(),a._applyLineJoin(this),!(this===t)){var i=this.getAbsoluteTransform(t).getMatrix();a.transform(i[0],i[1],i[2],i[3],i[4],i[5])}return u.call(this,a,this),a.restore(),this}drawHitFromCache(e=0){var t=this._getCanvasCache(),n=this._getCachedSceneCanvas(),r=t.hit,o=r.getContext(),a=r.getWidth(),u=r.getHeight(),d,h,p,l,i,c;o.clear(),o.drawImage(n._canvas,0,0,a,u);try{for(d=o.getImageData(0,0,a,u),h=d.data,p=h.length,l=Util._hexToRgb(this.colorKey),i=0;i<p;i+=4)c=h[i+3],c>e?(h[i]=l.r,h[i+1]=l.g,h[i+2]=l.b,h[i+3]=255):h[i+3]=0;o.putImageData(d,0,0)}catch(f){Util.error("Unable to draw hit graph from cached scene canvas. "+f.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 t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),e<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[e+1].getCanvas()._canvas):t.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 t=this.getStage();return!t||!t.content?!1:(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(Node.prototype.moveDown.call(this)){var e=this.getStage();if(e){var t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(Node.prototype.moveToBottom.call(this)){var e=this.getStage();if(e){var t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[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:t}){return this.canvas.setSize(e,t),this.hitCanvas.setSize(e,t),this._setSmoothEnabled(),this}_validateAdd(e){var t=e.getType();t!=="Group"&&t!=="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 t=1,n=!1;;){for(let r=0;r<INTERSECTION_OFFSETS_LEN;r++){const o=INTERSECTION_OFFSETS[r],a=this._getIntersection({x:e.x+o.x*t,y:e.y+o.y*t}),u=a.shape;if(u)return u;if(n=!!a.antialiased,!a.antialiased)break}if(n)t+=1;else return null}}_getIntersection(e){const t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.round(e.x*t),Math.round(e.y*t),1,1).data,r=n[3];if(r===255){const o=Util._rgbToHex(n[0],n[1],n[2]),a=shapes[HASH+o];return a?{shape:a}:{antialiased:!0}}else if(r>0)return{antialiased:!0};return{}}drawScene(e,t){var n=this.getLayer(),r=e||n&&n.getCanvas();return this._fire(BEFORE_DRAW,{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),Container$1.prototype.drawScene.call(this,r,t),this._fire(DRAW,{node:this}),this}drawHit(e,t){var n=this.getLayer(),r=e||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),Container$1.prototype.drawHit.call(this,r,t),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,t=!!this.hitCanvas._canvas.parentNode;t?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 t=e.getType();t!=="Group"&&t!=="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,t){this.id=Animation.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:now(),frameRate:0},this.func=e,this.setLayers(t)}setLayers(e){var t=[];return e?e.length>0?t=e:t=[e]:t=[],this.layers=t,this}getLayers(){return this.layers}addLayer(e){var t=this.layers,n=t.length,r;for(r=0;r<n;r++)if(t[r]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){var e=Animation,t=e.animations,n=t.length,r;for(r=0;r<n;r++)if(t[r].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 t=e.id,n=this.animations,r=n.length,o;for(o=0;o<r;o++)if(n[o].id===t){this.animations.splice(o,1);break}}static _runFrames(){var e={},t=this.animations,n,r,o,a,u,d,h,p,l;for(a=0;a<t.length;a++)if(n=t[a],r=n.layers,o=n.func,n._updateFrameObject(now()),d=r.length,o?l=o.call(n,n.frame)!==!1:l=!0,!!l)for(u=0;u<d;u++)h=r[u],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,t,n,r,o,a,u){this.prop=e,this.propFunc=t,this.begin=r,this._pos=r,this.duration=a,this._change=0,this.prevPos=0,this.yoyo=u,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=o-this.begin,this.pause()}fire(e){var t=this[e];t&&t()}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 t=this,n=e.node,r=n._id,o,a=e.easing||Easings.Linear,u=!!e.yoyo,d;typeof e.duration>"u"?o=.3:e.duration===0?o=.001:o=e.duration,this.node=n,this._id=idCounter++;var h=n.getLayer()||(n instanceof Konva$2.Stage?n.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(){t.tween.onEnterFrame()},h),this.tween=new TweenEngine(d,function(p){t._tweenFunc(p)},a,0,1,o*1e3,u),this._addListeners(),Tween.attrs[r]||(Tween.attrs[r]={}),Tween.attrs[r][this._id]||(Tween.attrs[r][this._id]={}),Tween.tweens[r]||(Tween.tweens[r]={});for(d in e)blacklist[d]===void 0&&this._addAttr(d,e[d]);this.reset(),this.onFinish=e.onFinish,this.onReset=e.onReset,this.onUpdate=e.onUpdate}_addAttr(e,t){var n=this.node,r=n._id,o,a,u,d,h,p,l,i;if(u=Tween.tweens[r][e],u&&delete Tween.attrs[r][u][e],o=n.getAttr(e),Util._isArray(t))if(a=[],h=Math.max(t.length,o.length),e==="points"&&t.length!==o.length&&(t.length>o.length?(l=o,o=Util._prepareArrayForTween(o,t,n.closed())):(p=t,t=Util._prepareArrayForTween(t,o,n.closed()))),e.indexOf("fill")===0)for(d=0;d<h;d++)if(d%2===0)a.push(t[d]-o[d]);else{var c=Util.colorToRGBA(o[d]);i=Util.colorToRGBA(t[d]),o[d]=c,a.push({r:i.r-c.r,g:i.g-c.g,b:i.b-c.b,a:i.a-c.a})}else for(d=0;d<h;d++)a.push(t[d]-o[d]);else colorAttrs.indexOf(e)!==-1?(o=Util.colorToRGBA(o),i=Util.colorToRGBA(t),a={r:i.r-o.r,g:i.g-o.g,b:i.b-o.b,a:i.a-o.a}):a=t-o;Tween.attrs[r][this._id][e]={start:o,diff:a,end:t,trueEnd:p,trueStart:l},Tween.tweens[r][e]=this._id}_tweenFunc(e){var t=this.node,n=Tween.attrs[t._id][this._id],r,o,a,u,d,h,p,l;for(r in n){if(o=n[r],a=o.start,u=o.diff,l=o.end,Util._isArray(a))if(d=[],p=Math.max(a.length,l.length),r.indexOf("fill")===0)for(h=0;h<p;h++)h%2===0?d.push((a[h]||0)+u[h]*e):d.push("rgba("+Math.round(a[h].r+u[h].r*e)+","+Math.round(a[h].g+u[h].g*e)+","+Math.round(a[h].b+u[h].b*e)+","+(a[h].a+u[h].a*e)+")");else for(h=0;h<p;h++)d.push((a[h]||0)+u[h]*e);else colorAttrs.indexOf(r)!==-1?d="rgba("+Math.round(a.r+u.r*e)+","+Math.round(a.g+u.g*e)+","+Math.round(a.b+u.b*e)+","+(a.a+u.a*e)+")":d=a+u*e;t.setAttr(r,d)}}_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,t=Tween.attrs[e._id][this._id];t.points&&t.points.trueEnd&&e.setAttr("points",t.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var e=this.node,t=Tween.attrs[e._id][this._id];t.points&&t.points.trueStart&&e.points(t.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,t=this._id,n=Tween.tweens[e],r;this.pause();for(r in n)delete Tween.tweens[e][r];delete Tween.attrs[e][t]}}Tween.attrs={};Tween.tweens={};Node.prototype.to=function(s){var e=s.onFinish;s.node=this,s.onFinish=function(){this.destroy(),e&&e()};var t=new Tween(s);t.play()};const Easings={BackEaseIn(s,e,t,n){var r=1.70158;return t*(s/=n)*s*((r+1)*s-r)+e},BackEaseOut(s,e,t,n){var r=1.70158;return t*((s=s/n-1)*s*((r+1)*s+r)+1)+e},BackEaseInOut(s,e,t,n){var r=1.70158;return(s/=n/2)<1?t/2*(s*s*(((r*=1.525)+1)*s-r))+e:t/2*((s-=2)*s*(((r*=1.525)+1)*s+r)+2)+e},ElasticEaseIn(s,e,t,n,r,o){var a=0;return s===0?e:(s/=n)===1?e+t:(o||(o=n*.3),!r||r<Math.abs(t)?(r=t,a=o/4):a=o/(2*Math.PI)*Math.asin(t/r),-(r*Math.pow(2,10*(s-=1))*Math.sin((s*n-a)*(2*Math.PI)/o))+e)},ElasticEaseOut(s,e,t,n,r,o){var a=0;return s===0?e:(s/=n)===1?e+t:(o||(o=n*.3),!r||r<Math.abs(t)?(r=t,a=o/4):a=o/(2*Math.PI)*Math.asin(t/r),r*Math.pow(2,-10*s)*Math.sin((s*n-a)*(2*Math.PI)/o)+t+e)},ElasticEaseInOut(s,e,t,n,r,o){var a=0;return s===0?e:(s/=n/2)===2?e+t:(o||(o=n*(.3*1.5)),!r||r<Math.abs(t)?(r=t,a=o/4):a=o/(2*Math.PI)*Math.asin(t/r),s<1?-.5*(r*Math.pow(2,10*(s-=1))*Math.sin((s*n-a)*(2*Math.PI)/o))+e:r*Math.pow(2,-10*(s-=1))*Math.sin((s*n-a)*(2*Math.PI)/o)*.5+t+e)},BounceEaseOut(s,e,t,n){return(s/=n)<1/2.75?t*(7.5625*s*s)+e:s<2/2.75?t*(7.5625*(s-=1.5/2.75)*s+.75)+e:s<2.5/2.75?t*(7.5625*(s-=2.25/2.75)*s+.9375)+e:t*(7.5625*(s-=2.625/2.75)*s+.984375)+e},BounceEaseIn(s,e,t,n){return t-Easings.BounceEaseOut(n-s,0,t,n)+e},BounceEaseInOut(s,e,t,n){return s<n/2?Easings.BounceEaseIn(s*2,0,t,n)*.5+e:Easings.BounceEaseOut(s*2-n,0,t,n)*.5+t*.5+e},EaseIn(s,e,t,n){return t*(s/=n)*s+e},EaseOut(s,e,t,n){return-t*(s/=n)*(s-2)+e},EaseInOut(s,e,t,n){return(s/=n/2)<1?t/2*s*s+e:-t/2*(--s*(s-2)-1)+e},StrongEaseIn(s,e,t,n){return t*(s/=n)*s*s*s*s+e},StrongEaseOut(s,e,t,n){return t*((s=s/n-1)*s*s*s*s+1)+e},StrongEaseInOut(s,e,t,n){return(s/=n/2)<1?t/2*s*s*s*s*s+e:t/2*((s-=2)*s*s*s*s+2)+e},Linear(s,e,t,n){return t*s/n+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 t=Konva$2.getAngle(this.angle()),n=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,t,n),e.arc(0,0,this.innerRadius(),t,0,!n),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(),t=this.outerRadius(),n=this.clockwise(),r=Konva$2.getAngle(n?360-this.angle():this.angle()),o=Math.cos(Math.min(r,Math.PI)),a=1,u=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),d=Math.sin(Math.min(r,Math.PI/2)),h=o*(o>0?e:t),p=a*t,l=u*(u>0?e:t),i=d*(d>0?t:e);return{x:h,y:n?-1*i:l,width:p-h,height:i-l}}}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(s,e,t,n,r,o,a){var u=Math.sqrt(Math.pow(t-s,2)+Math.pow(n-e,2)),d=Math.sqrt(Math.pow(r-t,2)+Math.pow(o-n,2)),h=a*u/(u+d),p=a*d/(u+d),l=t-h*(r-s),i=n-h*(o-e),c=t+p*(r-s),f=n+p*(o-e);return[l,i,c,f]}function expandPoints(s,e){var t=s.length,n=[],r,o;for(r=2;r<t-2;r+=2)o=getControlPoints(s[r-2],s[r-1],s[r],s[r+1],s[r+2],s[r+3],e),!isNaN(o[0])&&(n.push(o[0]),n.push(o[1]),n.push(s[r]),n.push(s[r+1]),n.push(o[2]),n.push(o[3]));return n}let Line$1=class extends Shape$1{constructor(e){super(e),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(e){var t=this.points(),n=t.length,r=this.tension(),o=this.closed(),a=this.bezier(),u,d,h;if(n){if(e.beginPath(),e.moveTo(t[0],t[1]),r!==0&&n>4){for(u=this.getTensionPoints(),d=u.length,h=o?0:4,o||e.quadraticCurveTo(u[0],u[1],u[2],u[3]);h<d-2;)e.bezierCurveTo(u[h++],u[h++],u[h++],u[h++],u[h++],u[h++]);o||e.quadraticCurveTo(u[d-2],u[d-1],t[n-2],t[n-1])}else if(a)for(h=2;h<n;)e.bezierCurveTo(t[h++],t[h++],t[h++],t[h++],t[h++],t[h++]);else for(h=2;h<n;h+=2)e.lineTo(t[h],t[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(),t=e.length,n=this.tension(),r=getControlPoints(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),o=getControlPoints(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),a=expandPoints(e,n),u=[r[2],r[3]].concat(a).concat([o[0],o[1],e[t-2],e[t-1],o[2],o[3],r[0],r[1],e[0],e[1]]);return u}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 t=e[0],n=e[0],r=e[1],o=e[1],a,u,d=0;d<e.length/2;d++)a=e[d*2],u=e[d*2+1],t=Math.min(t,a),n=Math.max(n,a),r=Math.min(r,u),o=Math.max(o,u);return{x:t,y:r,width:n-t,height:o-r}}};Line$1.prototype.className="Line";Line$1.prototype._attrsAffectingSize=["points","bezier","tension"];_registerNode(Line$1);Factory.addGetterSetter(Line$1,"closed",!1);Factory.addGetterSetter(Line$1,"bezier",!1);Factory.addGetterSetter(Line$1,"tension",0,getNumberValidator());Factory.addGetterSetter(Line$1,"points",[],getNumberArrayValidator());class Path extends Shape$1{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this.dataArray=Path.parsePathData(this.data()),this.pathLength=0;for(var t=0;t<this.dataArray.length;++t)this.pathLength+=this.dataArray[t].pathLength;this.on("dataChange.konva",function(){this.dataArray=Path.parsePathData(this.data()),this.pathLength=0;for(var n=0;n<this.dataArray.length;++n)this.pathLength+=this.dataArray[n].pathLength})}_sceneFunc(e){var t=this.dataArray;e.beginPath();for(var n=!1,r=0;r<t.length;r++){var o=t[r].command,a=t[r].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 u=a[0],d=a[1],h=a[2],p=a[3],l=a[4],i=a[5],c=a[6],f=a[7],g=h>p?h:p,m=h>p?1:h/p,_=h>p?p/h:1;e.translate(u,d),e.rotate(c),e.scale(m,_),e.arc(0,0,g,l,l+i,1-f),e.scale(1/m,1/_),e.rotate(-c),e.translate(-u,-d);break;case"z":n=!0,e.closePath();break}}!n&&!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],l=h.points[5],i=h.points[4]+l,c=Math.PI/180;if(Math.abs(p-i)<c&&(c=Math.abs(p-i)),l<0)for(let f=p-c;f>i;f-=c){const g=Path.getPointOnEllipticalArc(h.points[0],h.points[1],h.points[2],h.points[3],f,0);e.push(g.x,g.y)}else for(let f=p+c;f<i;f+=c){const g=Path.getPointOnEllipticalArc(h.points[0],h.points[1],h.points[2],h.points[3],f,0);e.push(g.x,g.y)}}else if(h.command==="C")for(let f=0;f<=1;f+=.01){const g=Path.getPointOnCubicBezier(f,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 t=e[0],n=e[0],r=e[1],o=e[1],a,u,d=0;d<e.length/2;d++)a=e[d*2],u=e[d*2+1],isNaN(a)||(t=Math.min(t,a),n=Math.max(n,a)),isNaN(u)||(r=Math.min(r,u),o=Math.max(o,u));return{x:t,y:r,width:n-t,height:o-r}}getLength(){return this.pathLength}getPointAtLength(e){var t,n=0,r=this.dataArray.length;if(!r)return null;for(;n<r&&e>this.dataArray[n].pathLength;)e-=this.dataArray[n].pathLength,++n;if(n===r)return t=this.dataArray[n-1].points.slice(-2),{x:t[0],y:t[1]};if(e<.01)return t=this.dataArray[n].points.slice(0,2),{x:t[0],y:t[1]};var o=this.dataArray[n],a=o.points;switch(o.command){case"L":return Path.getPointOnLine(e,o.start.x,o.start.y,a[0],a[1]);case"C":return Path.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 Path.getPointOnQuadraticBezier(e/o.pathLength,o.start.x,o.start.y,a[0],a[1],a[2],a[3]);case"A":var u=a[0],d=a[1],h=a[2],p=a[3],l=a[4],i=a[5],c=a[6];return l+=i*e/o.pathLength,Path.getPointOnEllipticalArc(u,d,h,p,l,c)}return null}static getLineLength(e,t,n,r){return Math.sqrt((n-e)*(n-e)+(r-t)*(r-t))}static getPointOnLine(e,t,n,r,o,a,u){a===void 0&&(a=t),u===void 0&&(u=n);var d=(o-n)/(r-t+1e-8),h=Math.sqrt(e*e/(1+d*d));r<t&&(h*=-1);var p=d*h,l;if(r===t)l={x:a,y:u+p};else if((u-n)/(a-t+1e-8)===d)l={x:a+h,y:u+p};else{var i,c,f=this.getLineLength(t,n,r,o),g=(a-t)*(r-t)+(u-n)*(o-n);g=g/(f*f),i=t+g*(r-t),c=n+g*(o-n);var m=this.getLineLength(a,u,i,c),_=Math.sqrt(e*e-m*m);h=Math.sqrt(_*_/(1+d*d)),r<t&&(h*=-1),p=d*h,l={x:i+h,y:c+p}}return l}static getPointOnCubicBezier(e,t,n,r,o,a,u,d,h){function p(m){return m*m*m}function l(m){return 3*m*m*(1-m)}function i(m){return 3*m*(1-m)*(1-m)}function c(m){return(1-m)*(1-m)*(1-m)}var f=d*p(e)+a*l(e)+r*i(e)+t*c(e),g=h*p(e)+u*l(e)+o*i(e)+n*c(e);return{x:f,y:g}}static getPointOnQuadraticBezier(e,t,n,r,o,a,u){function d(c){return c*c}function h(c){return 2*c*(1-c)}function p(c){return(1-c)*(1-c)}var l=a*d(e)+r*h(e)+t*p(e),i=u*d(e)+o*h(e)+n*p(e);return{x:l,y:i}}static getPointOnEllipticalArc(e,t,n,r,o,a){var u=Math.cos(a),d=Math.sin(a),h={x:n*Math.cos(o),y:r*Math.sin(o)};return{x:e+(h.x*u-h.y*d),y:t+(h.x*d+h.y*u)}}static parsePathData(e){if(!e)return[];var t=e,n=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];t=t.replace(new RegExp(" ","g"),",");for(var r=0;r<n.length;r++)t=t.replace(new RegExp(n[r],"g"),"|"+n[r]);var o=t.split("|"),a=[],u=[],d=0,h=0,p=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,l;for(r=1;r<o.length;r++){var i=o[r],c=i.charAt(0);for(i=i.slice(1),u.length=0;l=p.exec(i);)u.push(l[0]);for(var f=[],g=0,m=u.length;g<m;g++){if(u[g]==="00"){f.push(0,0);continue}var _=parseFloat(u[g]);isNaN(_)?f.push(0):f.push(_)}for(;f.length>0&&!isNaN(f[0]);){var b=null,v=[],T=d,y=h,S,w,k,P,I,F,C,E,$,x;switch(c){case"l":d+=f.shift(),h+=f.shift(),b="L",v.push(d,h);break;case"L":d=f.shift(),h=f.shift(),v.push(d,h);break;case"m":var A=f.shift(),L=f.shift();if(d+=A,h+=L,b="M",a.length>2&&a[a.length-1].command==="z"){for(var B=a.length-2;B>=0;B--)if(a[B].command==="M"){d=a[B].points[0]+A,h=a[B].points[1]+L;break}}v.push(d,h),c="l";break;case"M":d=f.shift(),h=f.shift(),b="M",v.push(d,h),c="L";break;case"h":d+=f.shift(),b="L",v.push(d,h);break;case"H":d=f.shift(),b="L",v.push(d,h);break;case"v":h+=f.shift(),b="L",v.push(d,h);break;case"V":h=f.shift(),b="L",v.push(d,h);break;case"C":v.push(f.shift(),f.shift(),f.shift(),f.shift()),d=f.shift(),h=f.shift(),v.push(d,h);break;case"c":v.push(d+f.shift(),h+f.shift(),d+f.shift(),h+f.shift()),d+=f.shift(),h+=f.shift(),b="C",v.push(d,h);break;case"S":w=d,k=h,S=a[a.length-1],S.command==="C"&&(w=d+(d-S.points[2]),k=h+(h-S.points[3])),v.push(w,k,f.shift(),f.shift()),d=f.shift(),h=f.shift(),b="C",v.push(d,h);break;case"s":w=d,k=h,S=a[a.length-1],S.command==="C"&&(w=d+(d-S.points[2]),k=h+(h-S.points[3])),v.push(w,k,d+f.shift(),h+f.shift()),d+=f.shift(),h+=f.shift(),b="C",v.push(d,h);break;case"Q":v.push(f.shift(),f.shift()),d=f.shift(),h=f.shift(),v.push(d,h);break;case"q":v.push(d+f.shift(),h+f.shift()),d+=f.shift(),h+=f.shift(),b="Q",v.push(d,h);break;case"T":w=d,k=h,S=a[a.length-1],S.command==="Q"&&(w=d+(d-S.points[0]),k=h+(h-S.points[1])),d=f.shift(),h=f.shift(),b="Q",v.push(w,k,d,h);break;case"t":w=d,k=h,S=a[a.length-1],S.command==="Q"&&(w=d+(d-S.points[0]),k=h+(h-S.points[1])),d+=f.shift(),h+=f.shift(),b="Q",v.push(w,k,d,h);break;case"A":P=f.shift(),I=f.shift(),F=f.shift(),C=f.shift(),E=f.shift(),$=d,x=h,d=f.shift(),h=f.shift(),b="A",v=this.convertEndpointToCenterParameterization($,x,d,h,C,E,P,I,F);break;case"a":P=f.shift(),I=f.shift(),F=f.shift(),C=f.shift(),E=f.shift(),$=d,x=h,d+=f.shift(),h+=f.shift(),b="A",v=this.convertEndpointToCenterParameterization($,x,d,h,C,E,P,I,F);break}a.push({command:b||c,points:v,start:{x:T,y},pathLength:this.calcLength(T,y,b||c,v)})}(c==="z"||c==="Z")&&a.push({command:"z",points:[],start:void 0,pathLength:0})}return a}static calcLength(e,t,n,r){var o,a,u,d,h=Path;switch(n){case"L":return h.getLineLength(e,t,r[0],r[1]);case"C":for(o=0,a=h.getPointOnCubicBezier(0,e,t,r[0],r[1],r[2],r[3],r[4],r[5]),d=.01;d<=1;d+=.01)u=h.getPointOnCubicBezier(d,e,t,r[0],r[1],r[2],r[3],r[4],r[5]),o+=h.getLineLength(a.x,a.y,u.x,u.y),a=u;return o;case"Q":for(o=0,a=h.getPointOnQuadraticBezier(0,e,t,r[0],r[1],r[2],r[3]),d=.01;d<=1;d+=.01)u=h.getPointOnQuadraticBezier(d,e,t,r[0],r[1],r[2],r[3]),o+=h.getLineLength(a.x,a.y,u.x,u.y),a=u;return o;case"A":o=0;var p=r[4],l=r[5],i=r[4]+l,c=Math.PI/180;if(Math.abs(p-i)<c&&(c=Math.abs(p-i)),a=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],p,0),l<0)for(d=p-c;d>i;d-=c)u=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],d,0),o+=h.getLineLength(a.x,a.y,u.x,u.y),a=u;else for(d=p+c;d<i;d+=c)u=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],d,0),o+=h.getLineLength(a.x,a.y,u.x,u.y),a=u;return u=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],i,0),o+=h.getLineLength(a.x,a.y,u.x,u.y),o}return 0}static convertEndpointToCenterParameterization(e,t,n,r,o,a,u,d,h){var p=h*(Math.PI/180),l=Math.cos(p)*(e-n)/2+Math.sin(p)*(t-r)/2,i=-1*Math.sin(p)*(e-n)/2+Math.cos(p)*(t-r)/2,c=l*l/(u*u)+i*i/(d*d);c>1&&(u*=Math.sqrt(c),d*=Math.sqrt(c));var f=Math.sqrt((u*u*(d*d)-u*u*(i*i)-d*d*(l*l))/(u*u*(i*i)+d*d*(l*l)));o===a&&(f*=-1),isNaN(f)&&(f=0);var g=f*u*i/d,m=f*-d*l/u,_=(e+n)/2+Math.cos(p)*g-Math.sin(p)*m,b=(t+r)/2+Math.sin(p)*g+Math.cos(p)*m,v=function(I){return Math.sqrt(I[0]*I[0]+I[1]*I[1])},T=function(I,F){return(I[0]*F[0]+I[1]*F[1])/(v(I)*v(F))},y=function(I,F){return(I[0]*F[1]<I[1]*F[0]?-1:1)*Math.acos(T(I,F))},S=y([1,0],[(l-g)/u,(i-m)/d]),w=[(l-g)/u,(i-m)/d],k=[(-1*l-g)/u,(-1*i-m)/d],P=y(w,k);return T(w,k)<=-1&&(P=Math.PI),T(w,k)>=1&&(P=0),a===0&&P>0&&(P=P-2*Math.PI),a===1&&P<0&&(P=P+2*Math.PI),[_,b,u,d,S,P,p,a]}}Path.prototype.className="Path";Path.prototype._attrsAffectingSize=["data"];_registerNode(Path);Factory.addGetterSetter(Path,"data");class Arrow extends Line$1{_sceneFunc(e){super._sceneFunc(e);var t=Math.PI*2,n=this.points(),r=n,o=this.tension()!==0&&n.length>4;o&&(r=this.getTensionPoints());var a=this.pointerLength(),u=n.length,d,h;if(o){const i=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],n[u-2],n[u-1]],c=Path.calcLength(r[r.length-4],r[r.length-3],"C",i),f=Path.getPointOnQuadraticBezier(Math.min(1,1-a/c),i[0],i[1],i[2],i[3],i[4],i[5]);d=n[u-2]-f.x,h=n[u-1]-f.y}else d=n[u-2]-n[u-4],h=n[u-1]-n[u-3];var p=(Math.atan2(h,d)+t)%t,l=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(n[u-2],n[u-1]),e.rotate(p),e.moveTo(0,0),e.lineTo(-a,l/2),e.lineTo(-a,-l/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(n[0],n[1]),o?(d=(r[0]+r[2])/2-n[0],h=(r[1]+r[3])/2-n[1]):(d=n[2]-n[0],h=n[3]-n[1]),e.rotate((Math.atan2(-h,-d)+t)%t),e.moveTo(0,0),e.lineTo(-a,l/2),e.lineTo(-a,-l/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){var t=this.dashEnabled();t&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),t&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),t=this.pointerWidth()/2;return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*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 t=this.radiusX(),n=this.radiusY();e.beginPath(),e.save(),t!==n&&e.scale(1,n/t),e.arc(0,0,t,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 Bt 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 t=this.getWidth(),n=this.getHeight(),r=this.cornerRadius(),o=this.attrs.image;let a;if(o){const u=this.attrs.cropWidth,d=this.attrs.cropHeight;u&&d?a=[o,this.cropX(),this.cropY(),u,d,0,0,t,n]:a=[o,0,0,t,n]}(this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?Util.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)),o&&(r&&e.clip(),e.drawImage.apply(e,a))}_hitFunc(e){var t=this.width(),n=this.height(),r=this.cornerRadius();e.beginPath(),r?Util.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}getWidth(){var e,t;return(e=this.attrs.width)!==null&&e!==void 0?e:(t=this.image())===null||t===void 0?void 0:t.width}getHeight(){var e,t;return(e=this.attrs.height)!==null&&e!==void 0?e:(t=this.image())===null||t===void 0?void 0:t.height}static fromURL(e,t,n=null){var r=Util.createImageElement();r.onload=function(){var o=new Bt({image:r});t(o)},r.onerror=n,r.crossOrigin="Anonymous",r.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;let Label$1=class extends Group$1{constructor(e){super(e),this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){var t=this,n,r=function(){t._sync()};for(n=0;n<attrChangeListLen$1;n++)e.on(ATTR_CHANGE_LIST$2[n]+CHANGE_KONVA$1,r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var e=this.getText(),t=this.getTag(),n,r,o,a,u,d,h;if(e&&t){switch(n=e.width(),r=e.height(),o=t.pointerDirection(),a=t.pointerWidth(),h=t.pointerHeight(),u=0,d=0,o){case UP:u=n/2,d=-1*h;break;case RIGHT$1:u=n+a,d=r/2;break;case DOWN:u=n/2,d=r+h;break;case LEFT$1:u=-1*a,d=r/2;break}t.setAttrs({x:-1*u,y:-1*d,width:n,height:r}),e.setAttrs({x:-1*u,y:-1*d})}}};Label$1.prototype.className="Label";_registerNode(Label$1);let Tag$1=class extends Shape$1{_sceneFunc(e){var t=this.width(),n=this.height(),r=this.pointerDirection(),o=this.pointerWidth(),a=this.pointerHeight(),u=this.cornerRadius();let d=0,h=0,p=0,l=0;typeof u=="number"?d=h=p=l=Math.min(u,t/2,n/2):(d=Math.min(u[0]||0,t/2,n/2),h=Math.min(u[1]||0,t/2,n/2),l=Math.min(u[2]||0,t/2,n/2),p=Math.min(u[3]||0,t/2,n/2)),e.beginPath(),e.moveTo(d,0),r===UP&&(e.lineTo((t-o)/2,0),e.lineTo(t/2,-1*a),e.lineTo((t+o)/2,0)),e.lineTo(t-h,0),e.arc(t-h,h,h,Math.PI*3/2,0,!1),r===RIGHT$1&&(e.lineTo(t,(n-a)/2),e.lineTo(t+o,n/2),e.lineTo(t,(n+a)/2)),e.lineTo(t,n-l),e.arc(t-l,n-l,l,0,Math.PI/2,!1),r===DOWN&&(e.lineTo((t+o)/2,n),e.lineTo(t/2,n+a),e.lineTo((t-o)/2,n)),e.lineTo(p,n),e.arc(p,n-p,p,Math.PI/2,Math.PI,!1),r===LEFT$1&&(e.lineTo(0,(n+a)/2),e.lineTo(-1*o,n/2),e.lineTo(0,(n-a)/2)),e.lineTo(0,d),e.arc(d,d,d,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){var e=0,t=0,n=this.pointerWidth(),r=this.pointerHeight(),o=this.pointerDirection(),a=this.width(),u=this.height();return o===UP?(t-=r,u+=r):o===DOWN?u+=r:o===LEFT$1?(e-=n*1.5,a+=n):o===RIGHT$1&&(a+=n*1.5),{x:e,y:t,width:a,height:u}}};Tag$1.prototype.className="Tag";_registerNode(Tag$1);Factory.addGetterSetter(Tag$1,"pointerDirection",NONE$1);Factory.addGetterSetter(Tag$1,"pointerWidth",0,getNumberValidator());Factory.addGetterSetter(Tag$1,"pointerHeight",0,getNumberValidator());Factory.addGetterSetter(Tag$1,"cornerRadius",0,getNumberOrArrayOfNumbersValidator(4));let Rect$1=class extends Shape$1{_sceneFunc(e){var t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?Util.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};Rect$1.prototype.className="Rect";_registerNode(Rect$1);Factory.addGetterSetter(Rect$1,"cornerRadius",0,getNumberOrArrayOfNumbersValidator(4));class RegularPolygon extends Shape$1{_sceneFunc(e){const t=this._getPoints();e.beginPath(),e.moveTo(t[0].x,t[0].y);for(var n=1;n<t.length;n++)e.lineTo(t[n].x,t[n].y);e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,t=this.attrs.radius||0,n=[];for(var r=0;r<e;r++)n.push({x:t*Math.sin(r*2*Math.PI/e),y:-1*t*Math.cos(r*2*Math.PI/e)});return n}getSelfRect(){const e=this._getPoints();var t=e[0].x,n=e[0].y,r=e[0].x,o=e[0].y;return e.forEach(a=>{t=Math.min(t,a.x),n=Math.max(n,a.x),r=Math.min(r,a.y),o=Math.max(o,a.y)}),{x:t,y:r,width:n-t,height:o-r}}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 t=this._updated;return this._updated=!1,t}),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 t=this.animation(),n=this.frameIndex(),r=n*4,o=this.animations()[t],a=this.frameOffsets(),u=o[r+0],d=o[r+1],h=o[r+2],p=o[r+3],l=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,h,p),e.closePath(),e.fillStrokeShape(this)),l)if(a){var i=a[t],c=n*2;e.drawImage(l,u,d,h,p,i[c+0],i[c+1],h,p)}else e.drawImage(l,u,d,h,p,0,0,h,p)}_hitFunc(e){var t=this.animation(),n=this.frameIndex(),r=n*4,o=this.animations()[t],a=this.frameOffsets(),u=o[r+2],d=o[r+3];if(e.beginPath(),a){var h=a[t],p=n*2;e.rect(h[p+0],h[p+1],u,d)}else e.rect(0,0,u,d);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(),t=this.animation(),n=this.animations(),r=n[t],o=r.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 t=this.innerRadius(),n=this.outerRadius(),r=this.numPoints();e.beginPath(),e.moveTo(0,0-n);for(var o=1;o<r*2;o++){var a=o%2===0?n:t,u=a*Math.sin(o*Math.PI/r),d=-1*a*Math.cos(o*Math.PI/r);e.lineTo(u,d)}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(s){return Array.from(s)}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(s){return s.split(",").map(e=>{e=e.trim();const t=e.indexOf(" ")>=0,n=e.indexOf('"')>=0||e.indexOf("'")>=0;return t&&!n&&(e=`"${e}"`),e}).join(", ")}var dummyContext;function getDummyContext(){return dummyContext||(dummyContext=Util.createCanvasElement().getContext(CONTEXT_2D),dummyContext)}function _fillFunc$1(s){s.fillText(this._partialText,this._partialTextX,this._partialTextY)}function _strokeFunc$1(s){s.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function checkDefaultFill(s){return s=s||{},!s.fillLinearGradientColorStops&&!s.fillRadialGradientColorStops&&!s.fillPatternImage&&(s.fill=s.fill||"black"),s}let Text$1=class extends Shape$1{constructor(e){super(checkDefaultFill(e)),this._partialTextX=0,this._partialTextY=0;for(var t=0;t<attrChangeListLen;t++)this.on(ATTR_CHANGE_LIST$1[t]+CHANGE_KONVA,this._setTextData);this._setTextData()}_sceneFunc(e){var t=this.textArr,n=t.length;if(this.text()){var r=this.padding(),o=this.fontSize(),a=this.lineHeight()*o,u=this.verticalAlign(),d=0,h=this.align(),p=this.getWidth(),l=this.letterSpacing(),i=this.fill(),c=this.textDecoration(),f=c.indexOf("underline")!==-1,g=c.indexOf("line-through")!==-1,m,_=0,_=a/2,b=0,v=0;for(e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",MIDDLE),e.setAttr("textAlign",LEFT),u===MIDDLE?d=(this.getHeight()-n*a-r*2)/2:u===BOTTOM&&(d=this.getHeight()-n*a-r*2),e.translate(r,d+r),m=0;m<n;m++){var b=0,v=0,T=t[m],y=T.text,S=T.width,w=T.lastInParagraph,k,P,I;if(e.save(),h===RIGHT?b+=p-S-r*2:h===CENTER&&(b+=(p-S-r*2)/2),f){e.save(),e.beginPath(),e.moveTo(b,_+v+Math.round(o/2)),k=y.split(" ").length-1,P=k===0,I=h===JUSTIFY&&!w?p-r*2:S,e.lineTo(b+Math.round(I),_+v+Math.round(o/2)),e.lineWidth=o/15;const A=this._getLinearGradient();e.strokeStyle=A||i,e.stroke(),e.restore()}if(g){e.save(),e.beginPath(),e.moveTo(b,_+v),k=y.split(" ").length-1,P=k===0,I=h===JUSTIFY&&w&&!P?p-r*2:S,e.lineTo(b+Math.round(I),_+v),e.lineWidth=o/15;const A=this._getLinearGradient();e.strokeStyle=A||i,e.stroke(),e.restore()}if(l!==0||h===JUSTIFY){k=y.split(" ").length-1;for(var F=stringToArray(y),C=0;C<F.length;C++){var E=F[C];E===" "&&!w&&h===JUSTIFY&&(b+=(p-r*2-S)/k),this._partialTextX=b,this._partialTextY=_+v,this._partialText=E,e.fillStrokeShape(this),b+=this.measureSize(E).width+l}}else this._partialTextX=b,this._partialTextY=_+v,this._partialText=y,e.fillStrokeShape(this);e.restore(),n>1&&(_+=a)}}}_hitFunc(e){var t=this.getWidth(),n=this.getHeight();e.beginPath(),e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}setText(e){var t=Util._isString(e)?e:e==null?"":e+"";return this._setAttr(TEXT,t),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 t=getDummyContext(),n=this.fontSize(),r;return t.save(),t.font=this._getContextFont(),r=t.measureText(e),t.restore(),{width:r.width,height:n}}_getContextFont(){return this.fontStyle()+SPACE+this.fontVariant()+SPACE+(this.fontSize()+PX_SPACE)+normalizeFontFamily(this.fontFamily())}_addTextLine(e){this.align()===JUSTIFY&&(e=e.trim());var n=this._getTextWidth(e);return this.textArr.push({text:e,width:n,lastInParagraph:!1})}_getTextWidth(e){var t=this.letterSpacing(),n=e.length;return getDummyContext().measureText(e).width+(n?t*(n-1):0)}_setTextData(){var e=this.text().split(`
`),t=+this.fontSize(),n=0,r=this.lineHeight()*t,o=this.attrs.width,a=this.attrs.height,u=o!==AUTO&&o!==void 0,d=a!==AUTO&&a!==void 0,h=this.padding(),p=o-h*2,l=a-h*2,i=0,c=this.wrap(),f=c!==NONE,g=c!==CHAR&&f,m=this.ellipsis();this.textArr=[],getDummyContext().font=this._getContextFont();for(var _=m?this._getTextWidth(ELLIPSIS):0,b=0,v=e.length;b<v;++b){var T=e[b],y=this._getTextWidth(T);if(u&&y>p)for(;T.length>0;){for(var S=0,w=T.length,k="",P=0;S<w;){var I=S+w>>>1,F=T.slice(0,I+1),C=this._getTextWidth(F)+_;C<=p?(S=I+1,k=F,P=C):w=I}if(k){if(g){var E,$=T[k.length],x=$===SPACE||$===DASH;x&&P<=p?E=k.length:E=Math.max(k.lastIndexOf(SPACE),k.lastIndexOf(DASH))+1,E>0&&(S=E,k=k.slice(0,S),P=this._getTextWidth(k))}k=k.trimRight(),this._addTextLine(k),n=Math.max(n,P),i+=r;var A=this._shouldHandleEllipsis(i);if(A){this._tryToAddEllipsisToLastLine();break}if(T=T.slice(S),T=T.trimLeft(),T.length>0&&(y=this._getTextWidth(T),y<=p)){this._addTextLine(T),i+=r,n=Math.max(n,y);break}}else break}else this._addTextLine(T),i+=r,n=Math.max(n,y),this._shouldHandleEllipsis(i)&&b<v-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),d&&i+r>l)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){var t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,o=r!==AUTO&&r!==void 0,a=this.padding(),u=r-a*2,d=this.wrap(),h=d!==NONE;return!h||o&&e+n>u}_tryToAddEllipsisToLastLine(){var e=this.attrs.width,t=e!==AUTO&&e!==void 0,n=this.padding(),r=e-n*2,o=this.ellipsis(),a=this.textArr[this.textArr.length-1];if(!(!a||!o)){if(t){var u=this._getTextWidth(a.text+ELLIPSIS)<r;u||(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$1.prototype._fillFunc=_fillFunc$1;Text$1.prototype._strokeFunc=_strokeFunc$1;Text$1.prototype.className=TEXT_UPPER;Text$1.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"];_registerNode(Text$1);Factory.overWriteSetter(Text$1,"width",getNumberOrAutoValidator());Factory.overWriteSetter(Text$1,"height",getNumberOrAutoValidator());Factory.addGetterSetter(Text$1,"fontFamily","Arial");Factory.addGetterSetter(Text$1,"fontSize",12,getNumberValidator());Factory.addGetterSetter(Text$1,"fontStyle",NORMAL$1);Factory.addGetterSetter(Text$1,"fontVariant",NORMAL$1);Factory.addGetterSetter(Text$1,"padding",0,getNumberValidator());Factory.addGetterSetter(Text$1,"align",LEFT);Factory.addGetterSetter(Text$1,"verticalAlign",TOP);Factory.addGetterSetter(Text$1,"lineHeight",1,getNumberValidator());Factory.addGetterSetter(Text$1,"wrap",WORD);Factory.addGetterSetter(Text$1,"ellipsis",!1,getBooleanValidator());Factory.addGetterSetter(Text$1,"letterSpacing",0,getNumberValidator());Factory.addGetterSetter(Text$1,"text","",getStringValidator());Factory.addGetterSetter(Text$1,"textDecoration","");var EMPTY_STRING="",NORMAL="normal";function _fillFunc(s){s.fillText(this.partialText,0,0)}function _strokeFunc(s){s.strokeText(this.partialText,0,0)}class TextPath extends Shape$1{constructor(e){super(e),this.dummyCanvas=Util.createCanvasElement(),this.dataArray=[],this.dataArray=Path.parsePathData(this.attrs.data),this.on("dataChange.konva",function(){this.dataArray=Path.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 t=this.textDecoration(),n=this.fill(),r=this.fontSize(),o=this.glyphInfo;t==="underline"&&e.beginPath();for(var a=0;a<o.length;a++){e.save();var u=o[a].p0;e.translate(u.x,u.y),e.rotate(o[a].rotation),this.partialText=o[a].text,e.fillStrokeShape(this),t==="underline"&&(a===0&&e.moveTo(0,r/2+1),e.lineTo(r,r/2+1)),e.restore()}t==="underline"&&(e.strokeStyle=n,e.lineWidth=r/20,e.stroke()),e.restore()}_hitFunc(e){e.beginPath();var t=this.glyphInfo;if(t.length>=1){var n=t[0].p0;e.moveTo(n.x,n.y)}for(var r=0;r<t.length;r++){var o=t[r].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$1.prototype.setText.call(this,e)}_getContextFont(){return Text$1.prototype._getContextFont.call(this)}_getTextSize(e){var t=this.dummyCanvas,n=t.getContext("2d");n.save(),n.font=this._getContextFont();var r=n.measureText(e);return n.restore(),{width:r.width,height:parseInt(this.attrs.fontSize,10)}}_setTextData(){var e=this,t=this._getTextSize(this.attrs.text),n=this.letterSpacing(),r=this.align(),o=this.kerningFunc();this.textWidth=t.width,this.textHeight=t.height;var a=Math.max(this.textWidth+((this.attrs.text||"").length-1)*n,0);this.glyphInfo=[];for(var u=0,d=0;d<e.dataArray.length;d++)e.dataArray[d].pathLength>0&&(u+=e.dataArray[d].pathLength);var h=0;r==="center"&&(h=Math.max(0,u/2-a/2)),r==="right"&&(h=Math.max(0,u-a));for(var p=stringToArray(this.text()),l=this.text().split(" ").length-1,i,c,f,g=-1,m=0,_=function(){m=0;for(var C=e.dataArray,E=g+1;E<C.length;E++){if(C[E].pathLength>0)return g=E,C[E];C[E].command==="M"&&(i={x:C[E].points[0],y:C[E].points[1]})}return{}},b=function(C){var E=e._getTextSize(C).width+n;C===" "&&r==="justify"&&(E+=(u-a)/l);var $=0,x=0;for(c=void 0;Math.abs(E-$)/E>.01&&x<20;){x++;for(var A=$;f===void 0;)f=_(),f&&A+f.pathLength<E&&(A+=f.pathLength,f=void 0);if(Object.keys(f).length===0||i===void 0)return;var L=!1;switch(f.command){case"L":Path.getLineLength(i.x,i.y,f.points[0],f.points[1])>E?c=Path.getPointOnLine(E,i.x,i.y,f.points[0],f.points[1],i.x,i.y):f=void 0;break;case"A":var B=f.points[4],H=f.points[5],J=f.points[4]+H;m===0?m=B+1e-8:E>$?m+=Math.PI/180*H/Math.abs(H):m-=Math.PI/360*H/Math.abs(H),(H<0&&m<J||H>=0&&m>J)&&(m=J,L=!0),c=Path.getPointOnEllipticalArc(f.points[0],f.points[1],f.points[2],f.points[3],m,f.points[6]);break;case"C":m===0?E>f.pathLength?m=1e-8:m=E/f.pathLength:E>$?m+=(E-$)/f.pathLength/2:m=Math.max(m-($-E)/f.pathLength/2,0),m>1&&(m=1,L=!0),c=Path.getPointOnCubicBezier(m,f.start.x,f.start.y,f.points[0],f.points[1],f.points[2],f.points[3],f.points[4],f.points[5]);break;case"Q":m===0?m=E/f.pathLength:E>$?m+=(E-$)/f.pathLength:m-=($-E)/f.pathLength,m>1&&(m=1,L=!0),c=Path.getPointOnQuadraticBezier(m,f.start.x,f.start.y,f.points[0],f.points[1],f.points[2],f.points[3]);break}c!==void 0&&($=Path.getLineLength(i.x,i.y,c.x,c.y)),L&&(L=!1,f=void 0)}},v="C",T=e._getTextSize(v).width+n,y=h/T-1,S=0;S<y&&(b(v),!(i===void 0||c===void 0));S++)i=c;for(var w=0;w<p.length&&(b(p[w]),!(i===void 0||c===void 0));w++){var k=Path.getLineLength(i.x,i.y,c.x,c.y),P=0;if(o)try{P=o(p[w-1],p[w])*this.fontSize()}catch{P=0}i.x+=P,c.x+=P,this.textWidth+=P;var I=Path.getPointOnLine(P+k/2,i.x,i.y,c.x,c.y),F=Math.atan2(c.y-i.y,c.x-i.x);this.glyphInfo.push({transposeX:I.x,transposeY:I.y,text:p[w],rotation:F,p0:i,p1:c}),i=c}}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 t=e[0]||0,n=e[0]||0,r=e[1]||0,o=e[1]||0,a,u,d=0;d<e.length/2;d++)a=e[d*2],u=e[d*2+1],t=Math.min(t,a),n=Math.max(n,a),r=Math.min(r,u),o=Math.max(o,u);var h=this.fontSize();return{x:t-h/2,y:r-h/2,width:n-t+h,height:o-r+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(s=>s+`.${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(s,e){if(s==="rotater")return"crosshair";e+=Util.degToRad(ANGLES[s]||0);var t=(Util.radToDeg(e)%360+360)%360;return Util._inRange(t,315+22.5,360)||Util._inRange(t,0,22.5)?"ns-resize":Util._inRange(t,45-22.5,45+22.5)?"nesw-resize":Util._inRange(t,90-22.5,90+22.5)?"ew-resize":Util._inRange(t,135-22.5,135+22.5)?"nwse-resize":Util._inRange(t,180-22.5,180+22.5)?"ns-resize":Util._inRange(t,225-22.5,225+22.5)?"nesw-resize":Util._inRange(t,270-22.5,270+22.5)?"ew-resize":Util._inRange(t,315-22.5,315+22.5)?"nwse-resize":(Util.error("Transformer has unknown angle for cursor detection: "+t),"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(s){return{x:s.x+s.width/2*Math.cos(s.rotation)+s.height/2*Math.sin(-s.rotation),y:s.y+s.height/2*Math.cos(s.rotation)+s.width/2*Math.sin(s.rotation)}}function rotateAroundPoint(s,e,t){const n=t.x+(s.x-t.x)*Math.cos(e)-(s.y-t.y)*Math.sin(e),r=t.y+(s.x-t.x)*Math.sin(e)+(s.y-t.y)*Math.cos(e);return Object.assign(Object.assign({},s),{rotation:s.rotation+e,x:n,y:r})}function rotateAroundCenter(s,e){const t=getCenter(s);return rotateAroundPoint(s,e,t)}function getSnap(s,e,t){let n=e;for(let r=0;r<s.length;r++){const o=Konva$2.getAngle(s[r]),a=Math.abs(o-e)%(Math.PI*2);Math.min(a,Math.PI*2-a)<t&&(n=o)}return n}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 t=e.filter(r=>r.isAncestorOf(this)?(Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1):!0);this._nodes=e=t,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(r=>{const o=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()},a=r._attrsAffectingSize.map(u=>u+"Change."+this._getEventNamespace()).join(" ");r.on(a,o),r.on(TRANSFORM_CHANGE_STR.map(u=>u+`.${this._getEventNamespace()}`).join(" "),o),r.on(`absoluteTransformChange.${this._getEventNamespace()}`,o),this._proxyDrag(r)}),this._resetTransformCache();var n=!!this.findOne(".top-left");return n&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back")&&this.startDrag(n,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!t)return;const r=e.getAbsolutePosition(),o=r.x-t.x,a=r.y-t.y;this.nodes().forEach(u=>{if(u===e||u.isDragging())return;const d=u.getAbsolutePosition();u.setAbsolutePosition({x:d.x+o,y:d.y+a}),u.startDrag(n)}),t=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,t=this.rotation(),n){var r=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),o=e.getAbsoluteScale(n),a=e.getAbsolutePosition(n),u=r.x*o.x-e.offsetX()*o.x,d=r.y*o.y-e.offsetY()*o.y;const h=(Konva$2.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2),p={x:a.x+u*Math.cos(h)+d*Math.sin(-h),y:a.y+d*Math.cos(h)+u*Math.sin(h),width:r.width*o.x,height:r.height*o.y,rotation:h};return rotateAroundPoint(p,-Konva$2.getAngle(t),{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 t=[];this.nodes().map(h=>{const p=h.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()});var l=[{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}],i=h.getAbsoluteTransform();l.forEach(function(c){var f=i.point(c);t.push(f)})});const n=new Transform;n.rotate(-Konva$2.getAngle(this.rotation()));var r,o,a,u;t.forEach(function(h){var p=n.point(h);r===void 0&&(r=a=p.x,o=u=p.y),r=Math.min(r,p.x),o=Math.min(o,p.y),a=Math.max(a,p.x),u=Math.max(u,p.y)}),n.invert();const d=n.point({x:r,y:o});return{x:d.x,y:d.y,width:a-r,height:u-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 t=new Rect$1({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:TOUCH_DEVICE?10:"auto"}),n=this;t.on("mousedown touchstart",function(r){n._handleMouseDown(r)}),t.on("dragstart",r=>{t.stopDrag(),r.cancelBubble=!0}),t.on("dragend",r=>{r.cancelBubble=!0}),t.on("mouseenter",()=>{var r=Konva$2.getAngle(this.rotation()),o=getCursor(e,r);t.getStage().content&&(t.getStage().content.style.cursor=o),this._cursorChange=!0}),t.on("mouseout",()=>{t.getStage().content&&(t.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(t)}_createBack(){var e=new Shape$1({name:"back",width:0,height:0,draggable:!0,sceneFunc(t){var n=this.getParent(),r=n.padding();t.beginPath(),t.rect(-r,-r,this.width()+r*2,this.height()+r*2),t.moveTo(this.width()/2,-r),n.rotateEnabled()&&t.lineTo(this.width()/2,-n.rotateAnchorOffset()*Util._sign(this.height())-r),t.fillStrokeShape(this)},hitFunc:(t,n)=>{if(this.shouldOverdrawWholeArea()){var r=this.padding();t.beginPath(),t.rect(-r,-r,n.width()+r*2,n.height()+r*2),t.fillStrokeShape(n)}}});this.add(e),this._proxyDrag(e),e.on("dragstart",t=>{t.cancelBubble=!0}),e.on("dragmove",t=>{t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(e){this._movingAnchorName=e.target.name().split(" ")[0];var t=this._getNodeRect(),n=t.width,r=t.height,o=Math.sqrt(Math.pow(n,2)+Math.pow(r,2));this.sin=Math.abs(r/o),this.cos=Math.abs(n/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(),u=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:u.x-a.x,y:u.y-a.y},this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach(d=>{d._fire("transformstart",{evt:e.evt,target:d})})}_handleMouseMove(e){var t,n,r,o=this.findOne("."+this._movingAnchorName),a=o.getStage();a.setPointersPositions(e);const u=a.getPointerPosition();let d={x:u.x-this._anchorDragOffset.x,y:u.y-this._anchorDragOffset.y};const h=o.getAbsolutePosition();this.anchorDragBoundFunc()&&(d=this.anchorDragBoundFunc()(h,d,e)),o.setAbsolutePosition(d);const p=o.getAbsolutePosition();if(!(h.x===p.x&&h.y===p.y)){if(this._movingAnchorName==="rotater"){var l=this._getNodeRect();t=o.x()-l.width/2,n=-o.y()+l.height/2;let C=Math.atan2(-n,t)+Math.PI/2;l.height<0&&(C-=Math.PI);var i=Konva$2.getAngle(this.rotation());const E=i+C,$=Konva$2.getAngle(this.rotationSnapTolerance()),A=getSnap(this.rotationSnaps(),E,$)-l.rotation,L=rotateAroundCenter(l,A);this._fitNodesInto(L,e);return}var c=this.keepRatio()||e.shiftKey,b=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(c){var f=b?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(f.x-o.x(),2)+Math.pow(f.y-o.y(),2));var g=this.findOne(".top-left").x()>f.x?-1:1,m=this.findOne(".top-left").y()>f.y?-1:1;t=r*this.cos*g,n=r*this.sin*m,this.findOne(".top-left").x(f.x-t),this.findOne(".top-left").y(f.y-n)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(o.y());else if(this._movingAnchorName==="top-right"){if(c){var f=b?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};r=Math.sqrt(Math.pow(o.x()-f.x,2)+Math.pow(f.y-o.y(),2));var g=this.findOne(".top-right").x()<f.x?-1:1,m=this.findOne(".top-right").y()>f.y?-1:1;t=r*this.cos*g,n=r*this.sin*m,this.findOne(".top-right").x(f.x+t),this.findOne(".top-right").y(f.y-n)}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(c){var f=b?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};r=Math.sqrt(Math.pow(f.x-o.x(),2)+Math.pow(o.y()-f.y,2));var g=f.x<o.x()?-1:1,m=o.y()<f.y?-1:1;t=r*this.cos*g,n=r*this.sin*m,o.x(f.x-t),o.y(f.y+n)}_=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(c){var f=b?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};r=Math.sqrt(Math.pow(o.x()-f.x,2)+Math.pow(o.y()-f.y,2));var g=this.findOne(".bottom-right").x()<f.x?-1:1,m=this.findOne(".bottom-right").y()<f.y?-1:1;t=r*this.cos*g,n=r*this.sin*m,this.findOne(".bottom-right").x(f.x+t),this.findOne(".bottom-right").y(f.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));var b=this.centeredScaling()||e.altKey;if(b){var v=this.findOne(".top-left"),T=this.findOne(".bottom-right"),y=v.x(),S=v.y(),w=this.getWidth()-T.x(),k=this.getHeight()-T.y();T.move({x:-y,y:-S}),v.move({x:w,y:k})}var P=this.findOne(".top-left").getAbsolutePosition();t=P.x,n=P.y;var I=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),F=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:n,width:I,height:F,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 t=this.getNode();this._fire("transformend",{evt:e,target:t}),t&&this._nodes.forEach(n=>{n._fire("transformend",{evt:e,target:n})}),this._movingAnchorName=null}}_fitNodesInto(e,t){var n=this._getNodeRect();const r=1;if(Util._inRange(e.width,-this.padding()*2-r,r)){this.update();return}if(Util._inRange(e.height,-this.padding()*2-r,r)){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 l=a.point({x:-this.padding()*2,y:0});if(e.x+=l.x,e.y+=l.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=l.x,this._anchorDragOffset.y-=l.y,!o){this.update();return}}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const l=a.point({x:this.padding()*2,y:0});if(this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=l.x,this._anchorDragOffset.y-=l.y,e.width+=this.padding()*2,!o){this.update();return}}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const l=a.point({x:0,y:-this.padding()*2});if(e.x+=l.x,e.y+=l.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=l.x,this._anchorDragOffset.y-=l.y,e.height+=this.padding()*2,!o){this.update();return}}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const l=a.point({x:0,y:this.padding()*2});if(this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=l.x,this._anchorDragOffset.y-=l.y,e.height+=this.padding()*2,!o){this.update();return}}if(this.boundBoxFunc()){const l=this.boundBoxFunc()(n,e);l?e=l:Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const u=1e7,d=new Transform;d.translate(n.x,n.y),d.rotate(n.rotation),d.scale(n.width/u,n.height/u);const h=new Transform;h.translate(e.x,e.y),h.rotate(e.rotation),h.scale(e.width/u,e.height/u);const p=h.multiply(d.invert());this._nodes.forEach(l=>{var i;const c=l.getParent().getAbsoluteTransform(),f=l.getTransform().copy();f.translate(l.offsetX(),l.offsetY());const g=new Transform;g.multiply(c.copy().invert()).multiply(p).multiply(c).multiply(f);const m=g.decompose();l.setAttrs(m),this._fire("transform",{evt:t,target:l}),l._fire("transform",{evt:t,target:l}),(i=l.getLayer())===null||i===void 0||i.batchDraw()}),this.rotation(Util._getRotation(e.rotation)),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e,t=this._getNodeRect();this.rotation(Util._getRotation(t.rotation));var n=t.width,r=t.height,o=this.enabledAnchors(),a=this.resizeEnabled(),u=this.padding(),d=this.anchorSize();this.find("._anchor").forEach(h=>{h.setAttrs({width:d,height:d,offsetX:d/2,offsetY:d/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:d/2+u,offsetY:d/2+u,visible:a&&o.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:d/2+u,visible:a&&o.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:d/2-u,offsetY:d/2+u,visible:a&&o.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:d/2+u,visible:a&&o.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:r/2,offsetX:d/2-u,visible:a&&o.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:d/2+u,offsetY:d/2-u,visible:a&&o.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:r,offsetY:d/2-u,visible:a&&o.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:r,offsetX:d/2-u,offsetY:d/2-u,visible:a&&o.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:n/2,y:-this.rotateAnchorOffset()*Util._sign(r)-u,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:r,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 t=Node.prototype.clone.call(this,e);return t}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}function validateAnchors(s){return s instanceof Array||Util.warn("enabledAnchors value should be an array"),s instanceof Array&&s.forEach(function(e){ANCHORS_NAMES.indexOf(e)===-1&&Util.warn("Unknown anchor name: "+e+". Available names are: "+ANCHORS_NAMES.join(", "))}),s||[]}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(s,e){var t=s.data,n=s.width,r=s.height,o,a,u,d,h,p,l,i,c,f,g,m,_,b,v,T,y,S,w,k,P,I,F,C,E=e+e+1,$=n-1,x=r-1,A=e+1,L=A*(A+1)/2,B=new BlurStack,H=null,J=B,X=null,ee=null,Q=mul_table[e],re=shg_table[e];for(u=1;u<E;u++)J=J.next=new BlurStack,u===A&&(H=J);for(J.next=B,l=p=0,a=0;a<r;a++){for(T=y=S=w=i=c=f=g=0,m=A*(k=t[p]),_=A*(P=t[p+1]),b=A*(I=t[p+2]),v=A*(F=t[p+3]),i+=L*k,c+=L*P,f+=L*I,g+=L*F,J=B,u=0;u<A;u++)J.r=k,J.g=P,J.b=I,J.a=F,J=J.next;for(u=1;u<A;u++)d=p+(($<u?$:u)<<2),i+=(J.r=k=t[d])*(C=A-u),c+=(J.g=P=t[d+1])*C,f+=(J.b=I=t[d+2])*C,g+=(J.a=F=t[d+3])*C,T+=k,y+=P,S+=I,w+=F,J=J.next;for(X=B,ee=H,o=0;o<n;o++)t[p+3]=F=g*Q>>re,F!==0?(F=255/F,t[p]=(i*Q>>re)*F,t[p+1]=(c*Q>>re)*F,t[p+2]=(f*Q>>re)*F):t[p]=t[p+1]=t[p+2]=0,i-=m,c-=_,f-=b,g-=v,m-=X.r,_-=X.g,b-=X.b,v-=X.a,d=l+((d=o+e+1)<$?d:$)<<2,T+=X.r=t[d],y+=X.g=t[d+1],S+=X.b=t[d+2],w+=X.a=t[d+3],i+=T,c+=y,f+=S,g+=w,X=X.next,m+=k=ee.r,_+=P=ee.g,b+=I=ee.b,v+=F=ee.a,T-=k,y-=P,S-=I,w-=F,ee=ee.next,p+=4;l+=n}for(o=0;o<n;o++){for(y=S=w=T=c=f=g=i=0,p=o<<2,m=A*(k=t[p]),_=A*(P=t[p+1]),b=A*(I=t[p+2]),v=A*(F=t[p+3]),i+=L*k,c+=L*P,f+=L*I,g+=L*F,J=B,u=0;u<A;u++)J.r=k,J.g=P,J.b=I,J.a=F,J=J.next;for(h=n,u=1;u<=e;u++)p=h+o<<2,i+=(J.r=k=t[p])*(C=A-u),c+=(J.g=P=t[p+1])*C,f+=(J.b=I=t[p+2])*C,g+=(J.a=F=t[p+3])*C,T+=k,y+=P,S+=I,w+=F,J=J.next,u<x&&(h+=n);for(p=o,X=B,ee=H,a=0;a<r;a++)d=p<<2,t[d+3]=F=g*Q>>re,F>0?(F=255/F,t[d]=(i*Q>>re)*F,t[d+1]=(c*Q>>re)*F,t[d+2]=(f*Q>>re)*F):t[d]=t[d+1]=t[d+2]=0,i-=m,c-=_,f-=b,g-=v,m-=X.r,_-=X.g,b-=X.b,v-=X.a,d=o+((d=a+A)<x?d:x)*n<<2,i+=T+=X.r=t[d],c+=y+=X.g=t[d+1],f+=S+=X.b=t[d+2],g+=w+=X.a=t[d+3],X=X.next,m+=k=ee.r,_+=P=ee.g,b+=I=ee.b,v+=F=ee.a,T-=k,y-=P,S-=I,w-=F,ee=ee.next,p+=n}}const Blur=function s(e){var t=Math.round(this.blurRadius());t>0&&filterGaussBlurRGBA(e,t)};Factory.addGetterSetter(Node,"blurRadius",0,getNumberValidator(),Factory.afterSetFilter);const Brighten=function(s){var e=this.brightness()*255,t=s.data,n=t.length,r;for(r=0;r<n;r+=4)t[r]+=e,t[r+1]+=e,t[r+2]+=e};Factory.addGetterSetter(Node,"brightness",0,getNumberValidator(),Factory.afterSetFilter);const Contrast=function(s){var e=Math.pow((this.contrast()+100)/100,2),t=s.data,n=t.length,r=150,o=150,a=150,u;for(u=0;u<n;u+=4)r=t[u],o=t[u+1],a=t[u+2],r/=255,r-=.5,r*=e,r+=.5,r*=255,o/=255,o-=.5,o*=e,o+=.5,o*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,r=r<0?0:r>255?255:r,o=o<0?0:o>255?255:o,a=a<0?0:a>255?255:a,t[u]=r,t[u+1]=o,t[u+2]=a};Factory.addGetterSetter(Node,"contrast",0,getNumberValidator(),Factory.afterSetFilter);const Emboss=function(s){var e=this.embossStrength()*10,t=this.embossWhiteLevel()*255,n=this.embossDirection(),r=this.embossBlend(),o=0,a=0,u=s.data,d=s.width,h=s.height,p=d*4,l=h;switch(n){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: "+n)}do{var i=(l-1)*p,c=o;l+c<1&&(c=0),l+c>h&&(c=0);var f=(l-1+c)*d*4,g=d;do{var m=i+(g-1)*4,_=a;g+_<1&&(_=0),g+_>d&&(_=0);var b=f+(g-1+_)*4,v=u[m]-u[b],T=u[m+1]-u[b+1],y=u[m+2]-u[b+2],S=v,w=S>0?S:-S,k=T>0?T:-T,P=y>0?y:-y;if(k>w&&(S=T),P>w&&(S=y),S*=e,r){var I=u[m]+S,F=u[m+1]+S,C=u[m+2]+S;u[m]=I>255?255:I<0?0:I,u[m+1]=F>255?255:F<0?0:F,u[m+2]=C>255?255:C<0?0:C}else{var E=t-S;E<0?E=0:E>255&&(E=255),u[m]=u[m+1]=u[m+2]=E}}while(--g)}while(--l)};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(s,e,t,n,r){var o=t-e,a=r-n,u;return o===0?n+a/2:a===0?n:(u=(s-e)/o,u=a*u+n,u)}const Enhance=function(s){var e=s.data,t=e.length,n=e[0],r=n,o,a=e[1],u=a,d,h=e[2],p=h,l,i,c=this.enhance();if(c!==0){for(i=0;i<t;i+=4)o=e[i+0],o<n?n=o:o>r&&(r=o),d=e[i+1],d<a?a=d:d>u&&(u=d),l=e[i+2],l<h?h=l:l>p&&(p=l);r===n&&(r=255,n=0),u===a&&(u=255,a=0),p===h&&(p=255,h=0);var f,g,m,_,b,v,T,y,S;for(c>0?(g=r+c*(255-r),m=n-c*(n-0),b=u+c*(255-u),v=a-c*(a-0),y=p+c*(255-p),S=h-c*(h-0)):(f=(r+n)*.5,g=r+c*(r-f),m=n+c*(n-f),_=(u+a)*.5,b=u+c*(u-_),v=a+c*(a-_),T=(p+h)*.5,y=p+c*(p-T),S=h+c*(h-T)),i=0;i<t;i+=4)e[i+0]=remap(e[i+0],n,r,m,g),e[i+1]=remap(e[i+1],a,u,v,b),e[i+2]=remap(e[i+2],h,p,S,y)}};Factory.addGetterSetter(Node,"enhance",0,getNumberValidator(),Factory.afterSetFilter);const Grayscale=function(s){var e=s.data,t=e.length,n,r;for(n=0;n<t;n+=4)r=.34*e[n]+.5*e[n+1]+.16*e[n+2],e[n]=r,e[n+1]=r,e[n+2]=r};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(s){var e=s.data,t=e.length,n=1,r=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,a=this.luminance()*127,u,d=n*r*Math.cos(o*Math.PI/180),h=n*r*Math.sin(o*Math.PI/180),p=.299*n+.701*d+.167*h,l=.587*n-.587*d+.33*h,i=.114*n-.114*d-.497*h,c=.299*n-.299*d-.328*h,f=.587*n+.413*d+.035*h,g=.114*n-.114*d+.293*h,m=.299*n-.3*d+1.25*h,_=.587*n-.586*d-1.05*h,b=.114*n+.886*d-.2*h,v,T,y,S;for(u=0;u<t;u+=4)v=e[u+0],T=e[u+1],y=e[u+2],S=e[u+3],e[u+0]=p*v+l*T+i*y+a,e[u+1]=c*v+f*T+g*y+a,e[u+2]=m*v+_*T+b*y+a,e[u+3]=S},HSV=function(s){var e=s.data,t=e.length,n=Math.pow(2,this.value()),r=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,a,u=n*r*Math.cos(o*Math.PI/180),d=n*r*Math.sin(o*Math.PI/180),h=.299*n+.701*u+.167*d,p=.587*n-.587*u+.33*d,l=.114*n-.114*u-.497*d,i=.299*n-.299*u-.328*d,c=.587*n+.413*u+.035*d,f=.114*n-.114*u+.293*d,g=.299*n-.3*u+1.25*d,m=.587*n-.586*u-1.05*d,_=.114*n+.886*u-.2*d,b,v,T,y;for(a=0;a<t;a+=4)b=e[a+0],v=e[a+1],T=e[a+2],y=e[a+3],e[a+0]=h*b+p*v+l*T,e[a+1]=i*b+c*v+f*T,e[a+2]=g*b+m*v+_*T,e[a+3]=y};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(s){var e=s.data,t=e.length,n;for(n=0;n<t;n+=4)e[n]=255-e[n],e[n+1]=255-e[n+1],e[n+2]=255-e[n+2]};var ToPolar=function(s,e,t){var n=s.data,r=e.data,o=s.width,a=s.height,u=t.polarCenterX||o/2,d=t.polarCenterY||a/2,h,p,l,i=0,c=0,f=0,g=0,m,_=Math.sqrt(u*u+d*d);p=o-u,l=a-d,m=Math.sqrt(p*p+l*l),_=m>_?m:_;var b=a,v=o,T,y,S=360/v*Math.PI/180,w,k;for(y=0;y<v;y+=1)for(w=Math.sin(y*S),k=Math.cos(y*S),T=0;T<b;T+=1)p=Math.floor(u+_*T/b*k),l=Math.floor(d+_*T/b*w),h=(l*o+p)*4,i=n[h+0],c=n[h+1],f=n[h+2],g=n[h+3],h=(y+T*o)*4,r[h+0]=i,r[h+1]=c,r[h+2]=f,r[h+3]=g},FromPolar=function(s,e,t){var n=s.data,r=e.data,o=s.width,a=s.height,u=t.polarCenterX||o/2,d=t.polarCenterY||a/2,h,p,l,i,c,f=0,g=0,m=0,_=0,b,v=Math.sqrt(u*u+d*d);p=o-u,l=a-d,b=Math.sqrt(p*p+l*l),v=b>v?b:v;var T=a,y=o,S,w,k=t.polarRotation||0,P,I;for(p=0;p<o;p+=1)for(l=0;l<a;l+=1)i=p-u,c=l-d,S=Math.sqrt(i*i+c*c)*T/v,w=(Math.atan2(c,i)*180/Math.PI+360+k)%360,w=w*y/360,P=Math.floor(w),I=Math.floor(S),h=(I*o+P)*4,f=n[h+0],g=n[h+1],m=n[h+2],_=n[h+3],h=(l*o+p)*4,r[h+0]=f,r[h+1]=g,r[h+2]=m,r[h+3]=_};const Kaleidoscope=function(s){var e=s.width,t=s.height,n,r,o,a,u,d,h,p,l,i,c=Math.round(this.kaleidoscopePower()),f=Math.round(this.kaleidoscopeAngle()),g=Math.floor(e*(f%360)/360);if(!(c<1)){var m=Util.createCanvasElement();m.width=e,m.height=t;var _=m.getContext("2d").getImageData(0,0,e,t);Util.releaseCanvas(m),ToPolar(s,_,{polarCenterX:e/2,polarCenterY:t/2});for(var b=e/Math.pow(2,c);b<=8;)b=b*2,c-=1;b=Math.ceil(b);var v=b,T=0,y=v,S=1;for(g+b>e&&(T=v,y=0,S=-1),r=0;r<t;r+=1)for(n=T;n!==y;n+=S)o=Math.round(n+g)%e,l=(e*r+o)*4,u=_.data[l+0],d=_.data[l+1],h=_.data[l+2],p=_.data[l+3],i=(e*r+n)*4,_.data[i+0]=u,_.data[i+1]=d,_.data[i+2]=h,_.data[i+3]=p;for(r=0;r<t;r+=1)for(v=Math.floor(b),a=0;a<c;a+=1){for(n=0;n<v+1;n+=1)l=(e*r+n)*4,u=_.data[l+0],d=_.data[l+1],h=_.data[l+2],p=_.data[l+3],i=(e*r+v*2-n-1)*4,_.data[i+0]=u,_.data[i+1]=d,_.data[i+2]=h,_.data[i+3]=p;v*=2}FromPolar(_,s,{polarRotation:0})}};Factory.addGetterSetter(Node,"kaleidoscopePower",2,getNumberValidator(),Factory.afterSetFilter);Factory.addGetterSetter(Node,"kaleidoscopeAngle",0,getNumberValidator(),Factory.afterSetFilter);function pixelAt(s,e,t){var n=(t*s.width+e)*4,r=[];return r.push(s.data[n++],s.data[n++],s.data[n++],s.data[n++]),r}function rgbDistance(s,e){return Math.sqrt(Math.pow(s[0]-e[0],2)+Math.pow(s[1]-e[1],2)+Math.pow(s[2]-e[2],2))}function rgbMean(s){for(var e=[0,0,0],t=0;t<s.length;t++)e[0]+=s[t][0],e[1]+=s[t][1],e[2]+=s[t][2];return e[0]/=s.length,e[1]/=s.length,e[2]/=s.length,e}function backgroundMask(s,e){var t=pixelAt(s,0,0),n=pixelAt(s,s.width-1,0),r=pixelAt(s,0,s.height-1),o=pixelAt(s,s.width-1,s.height-1),a=e||10;if(rgbDistance(t,n)<a&&rgbDistance(n,o)<a&&rgbDistance(o,r)<a&&rgbDistance(r,t)<a){for(var u=rgbMean([n,t,o,r]),d=[],h=0;h<s.width*s.height;h++){var p=rgbDistance(u,[s.data[h*4],s.data[h*4+1],s.data[h*4+2]]);d[h]=p<a?0:255}return d}}function applyMask(s,e){for(var t=0;t<s.width*s.height;t++)s.data[4*t+3]=e[t]}function erodeMask(s,e,t){for(var n=[1,1,1,1,0,1,1,1,1],r=Math.round(Math.sqrt(n.length)),o=Math.floor(r/2),a=[],u=0;u<t;u++)for(var d=0;d<e;d++){for(var h=u*e+d,p=0,l=0;l<r;l++)for(var i=0;i<r;i++){var c=u+l-o,f=d+i-o;if(c>=0&&c<t&&f>=0&&f<e){var g=c*e+f,m=n[l*r+i];p+=s[g]*m}}a[h]=p===255*8?255:0}return a}function dilateMask(s,e,t){for(var n=[1,1,1,1,1,1,1,1,1],r=Math.round(Math.sqrt(n.length)),o=Math.floor(r/2),a=[],u=0;u<t;u++)for(var d=0;d<e;d++){for(var h=u*e+d,p=0,l=0;l<r;l++)for(var i=0;i<r;i++){var c=u+l-o,f=d+i-o;if(c>=0&&c<t&&f>=0&&f<e){var g=c*e+f,m=n[l*r+i];p+=s[g]*m}}a[h]=p>=255*4?255:0}return a}function smoothEdgeMask(s,e,t){for(var n=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],r=Math.round(Math.sqrt(n.length)),o=Math.floor(r/2),a=[],u=0;u<t;u++)for(var d=0;d<e;d++){for(var h=u*e+d,p=0,l=0;l<r;l++)for(var i=0;i<r;i++){var c=u+l-o,f=d+i-o;if(c>=0&&c<t&&f>=0&&f<e){var g=c*e+f,m=n[l*r+i];p+=s[g]*m}}a[h]=p}return a}const Mask=function(s){var e=this.threshold(),t=backgroundMask(s,e);return t&&(t=erodeMask(t,s.width,s.height),t=dilateMask(t,s.width,s.height),t=smoothEdgeMask(t,s.width,s.height),applyMask(s,t)),s};Factory.addGetterSetter(Node,"threshold",0,getNumberValidator(),Factory.afterSetFilter);const Noise=function(s){var e=this.noise()*255,t=s.data,n=t.length,r=e/2,o;for(o=0;o<n;o+=4)t[o+0]+=r-2*r*Math.random(),t[o+1]+=r-2*r*Math.random(),t[o+2]+=r-2*r*Math.random()};Factory.addGetterSetter(Node,"noise",.2,getNumberValidator(),Factory.afterSetFilter);const Pixelate=function(s){var e=Math.ceil(this.pixelSize()),t=s.width,n=s.height,r,o,a,u,d,h,p,l=Math.ceil(t/e),i=Math.ceil(n/e),c,f,g,m,_,b,v,T=s.data;if(e<=0){Util.error("pixelSize value can not be <= 0");return}for(_=0;_<l;_+=1)for(b=0;b<i;b+=1){for(u=0,d=0,h=0,p=0,c=_*e,f=c+e,g=b*e,m=g+e,v=0,r=c;r<f;r+=1)if(!(r>=t))for(o=g;o<m;o+=1)o>=n||(a=(t*o+r)*4,u+=T[a+0],d+=T[a+1],h+=T[a+2],p+=T[a+3],v+=1);for(u=u/v,d=d/v,h=h/v,p=p/v,r=c;r<f;r+=1)if(!(r>=t))for(o=g;o<m;o+=1)o>=n||(a=(t*o+r)*4,T[a+0]=u,T[a+1]=d,T[a+2]=h,T[a+3]=p)}};Factory.addGetterSetter(Node,"pixelSize",8,getNumberValidator(),Factory.afterSetFilter);const Posterize=function(s){var e=Math.round(this.levels()*254)+1,t=s.data,n=t.length,r=255/e,o;for(o=0;o<n;o+=1)t[o]=Math.floor(t[o]/r)*r};Factory.addGetterSetter(Node,"levels",.5,getNumberValidator(),Factory.afterSetFilter);const RGB=function(s){var e=s.data,t=e.length,n=this.red(),r=this.green(),o=this.blue(),a,u;for(a=0;a<t;a+=4)u=(.34*e[a]+.5*e[a+1]+.16*e[a+2])/255,e[a]=u*n,e[a+1]=u*r,e[a+2]=u*o,e[a+3]=e[a+3]};Factory.addGetterSetter(Node,"red",0,function(s){return this._filterUpToDate=!1,s>255?255:s<0?0:Math.round(s)});Factory.addGetterSetter(Node,"green",0,function(s){return this._filterUpToDate=!1,s>255?255:s<0?0:Math.round(s)});Factory.addGetterSetter(Node,"blue",0,RGBComponent,Factory.afterSetFilter);const RGBA=function(s){var e=s.data,t=e.length,n=this.red(),r=this.green(),o=this.blue(),a=this.alpha(),u,d;for(u=0;u<t;u+=4)d=1-a,e[u]=n*a+e[u]*d,e[u+1]=r*a+e[u+1]*d,e[u+2]=o*a+e[u+2]*d};Factory.addGetterSetter(Node,"red",0,function(s){return this._filterUpToDate=!1,s>255?255:s<0?0:Math.round(s)});Factory.addGetterSetter(Node,"green",0,function(s){return this._filterUpToDate=!1,s>255?255:s<0?0:Math.round(s)});Factory.addGetterSetter(Node,"blue",0,RGBComponent,Factory.afterSetFilter);Factory.addGetterSetter(Node,"alpha",1,function(s){return this._filterUpToDate=!1,s>1?1:s<0?0:s});const Sepia=function(s){var e=s.data,t=e.length,n,r,o,a;for(n=0;n<t;n+=4)r=e[n+0],o=e[n+1],a=e[n+2],e[n+0]=Math.min(255,r*.393+o*.769+a*.189),e[n+1]=Math.min(255,r*.349+o*.686+a*.168),e[n+2]=Math.min(255,r*.272+o*.534+a*.131)},Solarize=function(s){var e=s.data,t=s.width,n=s.height,r=t*4,o=n;do{var a=(o-1)*r,u=t;do{var d=a+(u-1)*4,h=e[d],p=e[d+1],l=e[d+2];h>127&&(h=255-h),p>127&&(p=255-p),l>127&&(l=255-l),e[d]=h,e[d+1]=p,e[d+2]=l}while(--u)}while(--o)},Threshold=function(s){var e=this.threshold()*255,t=s.data,n=t.length,r;for(r=0;r<n;r+=1)t[r]=t[r]<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:Label$1,Tag:Tag$1,Line:Line$1,Path,Rect:Rect$1,RegularPolygon,Ring,Sprite,Star,Text:Text$1,TextPath,Transformer,Wedge,Filters:{Blur,Brighten,Contrast,Emboss,Enhance,Grayscale,HSL,HSV,Invert,Kaleidoscope,Mask,Noise,Pixelate,Posterize,RGB,RGBA,Sepia,Solarize,Threshold}}),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(s,e){KONVA_EVENTS.forEach(t=>{e.on(t,n=>{s(t,n,{cancelable:!0})||(n.cancelBubble=!0)})})}const CONTAINER_COMPONENT_KEYS=["svelte-konva-stage","svelte-konva-layer","svelte-konva-group","svelte-konva-label"];var Container;(function(s){s[s.Stage=0]="Stage",s[s.Layer=1]="Layer",s[s.Group=2]="Group",s[s.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(s,e){CONTAINER_COMPONENT_KEYS.forEach(t=>{setContext(t,null)}),setContext(CONTAINER_COMPONENT_KEYS[s],e)}function getParentContainer(){for(let s=1;s<4;s++){const e=getContext(CONTAINER_COMPONENT_KEYS[s]);if(e)return e}throw new Error(CONTAINER_ERROR)}function getParentStage(){const s=getContext(CONTAINER_COMPONENT_KEYS[Container.Stage]);if(s)return s;throw new Error(LAYER_ERROR)}function copyExistingKeys(s,e){for(const t in s)Object.prototype.hasOwnProperty.call(e,t)&&(s[t]=e[t])}function instance$l(s,e,t){let n,{config:r}=e,{handle:o=new Konva.Circle(r)}=e,a=getParentContainer();component_subscribe(s,a,d=>t(3,n=d));let u=createEventDispatcher();return onMount(()=>{n.add(o),o.on("transformend",()=>{copyExistingKeys(r,o.getAttrs()),t(1,r)}),o.on("dragend",()=>{copyExistingKeys(r,o.getAttrs()),t(1,r)}),registerEvents(u,o)}),onDestroy(()=>{o.destroy()}),s.$$set=d=>{"config"in d&&t(1,r=d.config),"handle"in d&&t(2,o=d.handle)},s.$$.update=()=>{s.$$.dirty&6&&o.setAttrs(r)},[a,r,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$a(s){let e;const t=s[5].default,n=create_slot(t,s,s[4],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&16)&&update_slot_base(n,t,r,r[4],e?get_slot_changes(t,r[4],o,null):get_all_dirty_from_scope(r[4]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$h(s){let e,t,n=s[0]&&create_if_block$a(s);return{c(){n&&n.c(),e=empty()},l(r){n&&n.l(r),e=empty()},m(r,o){n&&n.m(r,o),insert_hydration(r,e,o),t=!0},p(r,[o]){r[0]?n?(n.p(r,o),o&1&&transition_in(n,1)):(n=create_if_block$a(r),n.c(),transition_in(n,1),n.m(e.parentNode,e)):n&&(group_outros(),transition_out(n,1,1,()=>{n=null}),check_outros())},i(r){t||(transition_in(n),t=!0)},o(r){transition_out(n),t=!1},d(r){r&&detach(e),n&&n.d(r)}}}function instance$k(s,e,t){let n,{$$slots:r={},$$scope:o}=e,{config:a={}}=e,{handle:u=new Konva.Group(a)}=e,d=writable(null),h=createEventDispatcher(),p=!1,l=getParentContainer();return component_subscribe(s,l,i=>t(6,n=i)),onMount(()=>{n.add(u),u.on("transformend",()=>{copyExistingKeys(a,u.getAttrs()),t(2,a)}),u.on("dragend",()=>{copyExistingKeys(a,u.getAttrs()),t(2,a)}),registerEvents(h,u),d.set(u),t(0,p=!0)}),onDestroy(()=>{u&&u.destroy()}),setContainerContext(Container.Group,d),s.$$set=i=>{"config"in i&&t(2,a=i.config),"handle"in i&&t(3,u=i.handle),"$$scope"in i&&t(4,o=i.$$scope)},s.$$.update=()=>{s.$$.dirty&12&&u&&u.setAttrs(a)},[p,l,a,u,o,r]}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(s,e,t){let n,{config:r}=e,{handle:o=new Konva.Image(r)}=e,a=getParentContainer();component_subscribe(s,a,d=>t(3,n=d));let u=createEventDispatcher();return onMount(()=>{n.add(o),o.on("transformend",()=>{copyExistingKeys(r,o.getAttrs()),t(1,r)}),o.on("dragend",()=>{copyExistingKeys(r,o.getAttrs()),t(1,r)}),registerEvents(u,o)}),onDestroy(()=>{o.destroy()}),s.$$set=d=>{"config"in d&&t(1,r=d.config),"handle"in d&&t(2,o=d.handle)},s.$$.update=()=>{s.$$.dirty&6&&o.setAttrs(r)},[a,r,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$9(s){let e;const t=s[5].default,n=create_slot(t,s,s[4],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&16)&&update_slot_base(n,t,r,r[4],e?get_slot_changes(t,r[4],o,null):get_all_dirty_from_scope(r[4]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$g(s){let e,t,n=s[0]&&create_if_block$9(s);return{c(){n&&n.c(),e=empty()},l(r){n&&n.l(r),e=empty()},m(r,o){n&&n.m(r,o),insert_hydration(r,e,o),t=!0},p(r,[o]){r[0]?n?(n.p(r,o),o&1&&transition_in(n,1)):(n=create_if_block$9(r),n.c(),transition_in(n,1),n.m(e.parentNode,e)):n&&(group_outros(),transition_out(n,1,1,()=>{n=null}),check_outros())},i(r){t||(transition_in(n),t=!0)},o(r){transition_out(n),t=!1},d(r){r&&detach(e),n&&n.d(r)}}}function instance$i(s,e,t){let n,{$$slots:r={},$$scope:o}=e,{config:a}=e,{handle:u=new Konva.Label(a)}=e,d=writable(null),h=createEventDispatcher(),p=!1,l=getParentContainer();return component_subscribe(s,l,i=>t(6,n=i)),onMount(()=>{n.add(u),u.on("transformend",()=>{copyExistingKeys(a,u.getAttrs()),t(2,a)}),u.on("dragend",()=>{copyExistingKeys(a,u.getAttrs()),t(2,a)}),registerEvents(h,u),d.set(u),t(0,p=!0)}),onDestroy(()=>{u.destroy()}),setContainerContext(Container.Label,d),s.$$set=i=>{"config"in i&&t(2,a=i.config),"handle"in i&&t(3,u=i.handle),"$$scope"in i&&t(4,o=i.$$scope)},s.$$.update=()=>{s.$$.dirty&12&&u.setAttrs(a)},[p,l,a,u,o,r]}class Label extends SvelteComponent{constructor(e){super(),init(this,e,instance$i,create_fragment$g,safe_not_equal,{config:2,handle:3})}}function create_if_block$8(s){let e;const t=s[5].default,n=create_slot(t,s,s[4],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&16)&&update_slot_base(n,t,r,r[4],e?get_slot_changes(t,r[4],o,null):get_all_dirty_from_scope(r[4]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$f(s){let e,t,n=s[0]&&create_if_block$8(s);return{c(){n&&n.c(),e=empty()},l(r){n&&n.l(r),e=empty()},m(r,o){n&&n.m(r,o),insert_hydration(r,e,o),t=!0},p(r,[o]){r[0]?n?(n.p(r,o),o&1&&transition_in(n,1)):(n=create_if_block$8(r),n.c(),transition_in(n,1),n.m(e.parentNode,e)):n&&(group_outros(),transition_out(n,1,1,()=>{n=null}),check_outros())},i(r){t||(transition_in(n),t=!0)},o(r){transition_out(n),t=!1},d(r){r&&detach(e),n&&n.d(r)}}}function instance$h(s,e,t){let n,{$$slots:r={},$$scope:o}=e,{config:a={}}=e,{handle:u=new Konva.Layer(a)}=e,d=writable(null),h=createEventDispatcher(),p=!1,l=getParentStage();return component_subscribe(s,l,i=>t(6,n=i)),onMount(()=>{n.add(u),u.on("transformend",()=>{copyExistingKeys(a,u.getAttrs()),t(2,a)}),u.on("dragend",()=>{copyExistingKeys(a,u.getAttrs()),t(2,a)}),registerEvents(h,u),d.set(u),t(0,p=!0)}),onDestroy(()=>{u&&u.destroy()}),setContainerContext(Container.Layer,d),s.$$set=i=>{"config"in i&&t(2,a=i.config),"handle"in i&&t(3,u=i.handle),"$$scope"in i&&t(4,o=i.$$scope)},s.$$.update=()=>{s.$$.dirty&12&&u&&u.setAttrs(a)},[p,l,a,u,o,r]}class Layer extends SvelteComponent{constructor(e){super(),init(this,e,instance$h,create_fragment$f,safe_not_equal,{config:2,handle:3})}}function instance$g(s,e,t){let n,{config:r}=e,{handle:o=new Konva.Line(r)}=e,a=getParentContainer();component_subscribe(s,a,d=>t(3,n=d));let u=createEventDispatcher();return onMount(()=>{n.add(o),o.on("transformend",()=>{copyExistingKeys(r,o.getAttrs()),t(1,r)}),o.on("dragend",()=>{copyExistingKeys(r,o.getAttrs()),t(1,r)}),registerEvents(u,o)}),onDestroy(()=>{o.destroy()}),s.$$set=d=>{"config"in d&&t(1,r=d.config),"handle"in d&&t(2,o=d.handle)},s.$$.update=()=>{s.$$.dirty&6&&o.setAttrs(r)},[a,r,o]}class Line extends SvelteComponent{constructor(e){super(),init(this,e,instance$g,null,safe_not_equal,{config:1,handle:2})}}function instance$f(s,e,t){let n,{config:r}=e,{handle:o=new Konva.Rect(r)}=e,a=getParentContainer();component_subscribe(s,a,d=>t(3,n=d));let u=createEventDispatcher();return onMount(()=>{n.add(o),o.on("transformend",()=>{copyExistingKeys(r,o.getAttrs()),t(1,r)}),o.on("dragend",()=>{copyExistingKeys(r,o.getAttrs()),t(1,r)}),registerEvents(u,o)}),onDestroy(()=>{o.destroy()}),s.$$set=d=>{"config"in d&&t(1,r=d.config),"handle"in d&&t(2,o=d.handle)},s.$$.update=()=>{s.$$.dirty&6&&o.setAttrs(r)},[a,r,o]}class Rect extends SvelteComponent{constructor(e){super(),init(this,e,instance$f,null,safe_not_equal,{config:1,handle:2})}}function instance$e(s,e,t){let n,{config:r}=e,{handle:o=new Konva.Shape(r)}=e,a=getParentContainer();component_subscribe(s,a,d=>t(3,n=d));let u=createEventDispatcher();return onMount(()=>{n.add(o),o.on("transformend",()=>{copyExistingKeys(r,o.getAttrs()),t(1,r)}),o.on("dragend",()=>{copyExistingKeys(r,o.getAttrs()),t(1,r)}),registerEvents(u,o)}),onDestroy(()=>{o.destroy()}),s.$$set=d=>{"config"in d&&t(1,r=d.config),"handle"in d&&t(2,o=d.handle)},s.$$.update=()=>{s.$$.dirty&6&&o.setAttrs(r)},[a,r,o]}class Shape extends SvelteComponent{constructor(e){super(),init(this,e,instance$e,null,safe_not_equal,{config:1,handle:2})}}function create_if_block$7(s){let e;const t=s[6].default,n=create_slot(t,s,s[5],null);return{c(){n&&n.c()},l(r){n&&n.l(r)},m(r,o){n&&n.m(r,o),e=!0},p(r,o){n&&n.p&&(!e||o&32)&&update_slot_base(n,t,r,r[5],e?get_slot_changes(t,r[5],o,null):get_all_dirty_from_scope(r[5]),null)},i(r){e||(transition_in(n,r),e=!0)},o(r){transition_out(n,r),e=!1},d(r){n&&n.d(r)}}}function create_fragment$e(s){let e,t,n=s[1]&&create_if_block$7(s),r=[s[2]],o={};for(let a=0;a<r.length;a+=1)o=assign(o,r[a]);return{c(){e=element("div"),n&&n.c(),this.h()},l(a){e=claim_element(a,"DIV",{});var u=children(e);n&&n.l(u),u.forEach(detach),this.h()},h(){set_attributes(e,o)},m(a,u){insert_hydration(a,e,u),n&&n.m(e,null),s[7](e),t=!0},p(a,[u]){a[1]?n?(n.p(a,u),u&2&&transition_in(n,1)):(n=create_if_block$7(a),n.c(),transition_in(n,1),n.m(e,null)):n&&(group_outros(),transition_out(n,1,1,()=>{n=null}),check_outros()),set_attributes(e,o=get_spread_update(r,[u&4&&a[2]]))},i(a){t||(transition_in(n),t=!0)},o(a){transition_out(n),t=!1},d(a){a&&detach(e),n&&n.d(),s[7](null)}}}function instance$d(s,e,t){const n=["config","handle"];let r=compute_rest_props(e,n),{$$slots:o={},$$scope:a}=e,{config:u}=e,{handle:d=null}=e,h=writable(null),p,l=createEventDispatcher(),i=!1;onMount(()=>{t(4,d=new Konva.Stage({container:p,...u})),d.on("dragend",()=>{copyExistingKeys(u,d.getAttrs()),t(3,u)}),registerEvents(l,d),h.set(d),t(1,i=!0)}),onDestroy(()=>{d&&d.destroy()}),setContainerContext(Container.Stage,h);function c(f){binding_callbacks[f?"unshift":"push"](()=>{p=f,t(0,p)})}return s.$$set=f=>{e=assign(assign({},e),exclude_internal_props(f)),t(2,r=compute_rest_props(e,n)),"config"in f&&t(3,u=f.config),"handle"in f&&t(4,d=f.handle),"$$scope"in f&&t(5,a=f.$$scope)},s.$$.update=()=>{s.$$.dirty&24&&d&&d.setAttrs(u)},[p,i,r,u,d,a,o,c]}class Stage extends SvelteComponent{constructor(e){super(),init(this,e,instance$d,create_fragment$e,safe_not_equal,{config:3,handle:4})}}function instance$c(s,e,t){let n,{config:r}=e,{handle:o=new Konva.Text(r)}=e,a=getParentContainer();component_subscribe(s,a,d=>t(3,n=d));let u=createEventDispatcher();return onMount(()=>{n.add(o),o.on("transformend",()=>{copyExistingKeys(r,o.getAttrs()),t(1,r)}),o.on("dragend",()=>{copyExistingKeys(r,o.getAttrs()),t(1,r)}),registerEvents(u,o)}),onDestroy(()=>{o.destroy()}),s.$$set=d=>{"config"in d&&t(1,r=d.config),"handle"in d&&t(2,o=d.handle)},s.$$.update=()=>{s.$$.dirty&6&&o.setAttrs(r)},[a,r,o]}class Text extends SvelteComponent{constructor(e){super(),init(this,e,instance$c,null,safe_not_equal,{config:1,handle:2})}}function instance$b(s,e,t){let n,{config:r}=e,{handle:o=new Konva.Tag(r)}=e,a=getParentContainer();component_subscribe(s,a,d=>t(3,n=d));let u=createEventDispatcher();return onMount(()=>{n.add(o),o.on("transformend",()=>{copyExistingKeys(r,o.getAttrs()),t(1,r)}),o.on("dragend",()=>{copyExistingKeys(r,o.getAttrs()),t(1,r)}),registerEvents(u,o)}),onDestroy(()=>{o.destroy()}),s.$$set=d=>{"config"in d&&t(1,r=d.config),"handle"in d&&t(2,o=d.handle)},s.$$.update=()=>{s.$$.dirty&6&&o.setAttrs(r)},[a,r,o]}class Tag extends SvelteComponent{constructor(e){super(),init(this,e,instance$b,null,safe_not_equal,{config:1,handle:2})}}const INPUTPOINT_RADIUS=6,INPUTPOINT_STROKEWIDTH=3,INPUTRECT_STROKEWIDTH=1.5,BBOX_STROKEWIDTH=2,MASK_STROKEWIDTH=2,POINT_SELECTION="POINT_SELECTION";function addMask(s,e,t,n,r,o,a){const u=n.x(),d=n.y(),h=n.scale(),p=new Option().style;p.color=e;function l(f){const g=f.split(" "),m=g[0].slice(1);return{x:parseInt(m),y:parseInt(g[1])}}function i(f){const g=f.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 c=new Konva.Shape({id:s.id,x:u,y:d,width:o.width(),height:o.height(),fill:`rgba(${p.color.replace("rgb(","").replace(")","")}, 0.35)`,stroke:p.color,strokeWidth:MASK_STROKEWIDTH/a[r],scale:h,visible:s.visible,opacity:s.opacity,listening:!1,sceneFunc:(f,g)=>{f.beginPath();for(let m=0;m<s.svg.length;++m){const _=l(s.svg[m]);f.moveTo(_.x,_.y);const b=i(s.svg[m]);for(const v of b)f.lineTo(v.x,v.y)}f.fillStrokeShape(g)}});t.add(c)}function findOrCreateCurrentMask(s,e){const n=e.findOne(`#${s}`).findOne("#currentAnnotation");let r=n.findOne("#currentMask");return r||(r=new Konva.Group({id:"currentMask"}),n.add(r)),r}function clearCurrentAnn(s,e,t){const n=e==null?void 0:e.findOne(`#${s}`);if(n){const o=n.findOne("#currentAnnotation").findOne("#currentMask");o&&o.destroy(),t!=null&&t.postProcessor&&t.postProcessor.reset()}}var simplify$1={exports:{}};(function(s){(function(){function e(u,d){var h=u.x-d.x,p=u.y-d.y;return h*h+p*p}function t(u,d,h){var p=d.x,l=d.y,i=h.x-p,c=h.y-l;if(i!==0||c!==0){var f=((u.x-p)*i+(u.y-l)*c)/(i*i+c*c);f>1?(p=h.x,l=h.y):f>0&&(p+=i*f,l+=c*f)}return i=u.x-p,c=u.y-l,i*i+c*c}function n(u,d){for(var h=u[0],p=[h],l,i=1,c=u.length;i<c;i++)l=u[i],e(l,h)>d&&(p.push(l),h=l);return h!==l&&p.push(l),p}function r(u,d,h,p,l){for(var i=p,c,f=d+1;f<h;f++){var g=t(u[f],u[d],u[h]);g>i&&(c=f,i=g)}i>p&&(c-d>1&&r(u,d,c,p,l),l.push(u[c]),h-c>1&&r(u,c,h,p,l))}function o(u,d){var h=u.length-1,p=[u[0]];return r(u,0,h,d,p),p.push(u[h]),p}function a(u,d,h){if(u.length<=2)return u;var p=d!==void 0?d*d:1;return u=h?u:n(u,p),u=o(u,p),u}s.exports=a,s.exports.default=a})()})(simplify$1);var simplifyExports=simplify$1.exports;const simplify=getDefaultExportFromCjs(simplifyExports),parseSvgPath=s=>{const e=/([ML]?)\s*([\d.]+)\s+([\d.]+)/g;let t,n=[];for(;(t=e.exec(s))!==null;){const[,,r,o]=t;n.push({x:parseFloat(r),y:parseFloat(o)})}return n=simplify(n,4,!0),n.map((r,o)=>({...r,id:o}))},convertPointToSvg=s=>s.reduce((e,t,n)=>n===0?`M${t.x} ${t.y}`:n===1?`${e} L${t.x} ${t.y}`:`${e} ${t.x} ${t.y}`,""),hexToRGBA=(s,e)=>{const t=parseInt(s.slice(1,3),16),n=parseInt(s.slice(3,5),16),r=parseInt(s.slice(5,7),16);return`rgba(${t},${n},${r},${e})`};function m_part(s){const e=s.split(" "),t=e[0].slice(1);return{x:parseInt(t),y:parseInt(e[1])}}function l_part(s){var r;const e=s.split(" "),t=(r=e[2])==null?void 0:r.slice(1),n=[{x:parseInt(t),y:parseInt(e[3])}];for(let o=4;o<e.length;o+=2)n.push({x:parseInt(e[o]),y:parseInt(e[o+1])});return n}const sceneFunc=(s,e,t)=>{s.beginPath();for(let n=0;n<t.length;++n){const r=m_part(t[n]);s.moveTo(r.x,r.y);const o=l_part(t[n]);for(const a of o)s.lineTo(a.x,a.y)}s.fillStrokeShape(e)};function svgPathToBitmap(s,e,t){const n=document.createElement("canvas");n.width=e,n.height=t;const r=n.getContext("2d");r.clearRect(0,0,e,t),r.fillStyle="black",r.fill(new Path2D(s));const o=r.getImageData(0,0,e,t).data,a=[];for(let u=0;u<o.length;u+=4)a.push(o[u+3]===0?0:1);return a}function rleEncode(s){const e=[];let t=1;for(let n=1;n<s.length;n++)s[n]===s[n-1]?t++:(e.push(t),t=1);return e.push(t),e}function reshapeArray(s,e,t){if(s.length!==e*t)throw new Error("Can't reshape with length != cols*rows");const n=[];for(let r=0;r<t;r++)for(let o=0;o<e;o++)n.push(s[o*t+r]);return n}function runLengthEncode(s,e,t){let n=svgPathToBitmap(s,e,t);return n=reshapeArray(n,t,e),rleEncode(n)}function get_each_context$1(s,e,t){const n=s.slice();return n[14]=e[t],n[16]=t,n}function get_each_context_1$1(s,e,t){const n=s.slice();return n[17]=e[t],n[19]=t,n}function create_each_block_1$1(s){let e,t;function n(){return s[9](s[19])}function r(){return s[10](s[17],s[16])}function o(...u){return s[12](s[16],s[17],...u)}function a(){return s[13](s[17],s[16])}return e=new Circle({props:{config:{x:s[17].x,y:s[17].y,radius:(s[19]===0?6:4)/s[1][s[0]],fill:s[19]===0?"#781e60":"rgb(0,128,0)",stroke:"white",strokeWidth:1/s[1][s[0]],id:`dot-${s[2]}-${s[16]}-${s[17].id}`,draggable:!0}}}),e.$on("click",n),e.$on("dragmove",r),e.$on("dragend",s[11]),e.$on("mouseover",o),e.$on("mouseleave",a),{c(){create_component(e.$$.fragment)},l(u){claim_component(e.$$.fragment,u)},m(u,d){mount_component(e,u,d),t=!0},p(u,d){s=u;const h={};d&15&&(h.config={x:s[17].x,y:s[17].y,radius:(s[19]===0?6:4)/s[1][s[0]],fill:s[19]===0?"#781e60":"rgb(0,128,0)",stroke:"white",strokeWidth:1/s[1][s[0]],id:`dot-${s[2]}-${s[16]}-${s[17].id}`,draggable:!0}),e.$set(h)},i(u){t||(transition_in(e.$$.fragment,u),t=!0)},o(u){transition_out(e.$$.fragment,u),t=!1},d(u){destroy_component(e,u)}}}function create_each_block$1(s){let e,t,n=ensure_array_like(s[14]),r=[];for(let a=0;a<n.length;a+=1)r[a]=create_each_block_1$1(get_each_context_1$1(s,n,a));const o=a=>transition_out(r[a],1,1,()=>{r[a]=null});return{c(){for(let a=0;a<r.length;a+=1)r[a].c();e=empty()},l(a){for(let u=0;u<r.length;u+=1)r[u].l(a);e=empty()},m(a,u){for(let d=0;d<r.length;d+=1)r[d]&&r[d].m(a,u);insert_hydration(a,e,u),t=!0},p(a,u){if(u&255){n=ensure_array_like(a[14]);let d;for(d=0;d<n.length;d+=1){const h=get_each_context_1$1(a,n,d);r[d]?(r[d].p(h,u),transition_in(r[d],1)):(r[d]=create_each_block_1$1(h),r[d].c(),transition_in(r[d],1),r[d].m(e.parentNode,e))}for(group_outros(),d=n.length;d<r.length;d+=1)o(d);check_outros()}},i(a){if(!t){for(let u=0;u<n.length;u+=1)transition_in(r[u]);t=!0}},o(a){r=r.filter(Boolean);for(let u=0;u<r.length;u+=1)transition_out(r[u]);t=!1},d(a){a&&detach(e),destroy_each(r,a)}}}function create_fragment$d(s){let e,t,n=ensure_array_like(s[3]),r=[];for(let a=0;a<n.length;a+=1)r[a]=create_each_block$1(get_each_context$1(s,n,a));const o=a=>transition_out(r[a],1,1,()=>{r[a]=null});return{c(){for(let a=0;a<r.length;a+=1)r[a].c();e=empty()},l(a){for(let u=0;u<r.length;u+=1)r[u].l(a);e=empty()},m(a,u){for(let d=0;d<r.length;d+=1)r[d]&&r[d].m(a,u);insert_hydration(a,e,u),t=!0},p(a,[u]){if(u&255){n=ensure_array_like(a[3]);let d;for(d=0;d<n.length;d+=1){const h=get_each_context$1(a,n,d);r[d]?(r[d].p(h,u),transition_in(r[d],1)):(r[d]=create_each_block$1(h),r[d].c(),transition_in(r[d],1),r[d].m(e.parentNode,e))}for(group_outros(),d=n.length;d<r.length;d+=1)o(d);check_outros()}},i(a){if(!t){for(let u=0;u<n.length;u+=1)transition_in(r[u]);t=!0}},o(a){r=r.filter(Boolean);for(let u=0;u<r.length;u+=1)transition_out(r[u]);t=!1},d(a){a&&detach(e),destroy_each(r,a)}}}function instance$a(s,e,t){let{viewId:n}=e,{stage:r}=e,{zoomFactor:o}=e,{polygonId:a}=e,{points:u}=e,{handlePolygonPointsClick:d}=e,{handlePolygonPointsDragMove:h}=e,{handlePolygonPointsDragEnd:p}=e;function l(_,b,v){const T=r.findOne(`#dot-${a}-${b}-${_}`);T.scaleX(v),T.scaleY(v)}const i=_=>d==null?void 0:d(_,n),c=(_,b)=>h==null?void 0:h(_.id,b),f=()=>p==null?void 0:p(),g=(_,b,v)=>{var T,y;((y=(T=v.detail.target)==null?void 0:T.attrs)==null?void 0:y.id)===`dot-${a}-${_}-${b.id}`&&l(b.id,_,2)},m=(_,b)=>l(_.id,b,1);return s.$$set=_=>{"viewId"in _&&t(0,n=_.viewId),"stage"in _&&t(8,r=_.stage),"zoomFactor"in _&&t(1,o=_.zoomFactor),"polygonId"in _&&t(2,a=_.polygonId),"points"in _&&t(3,u=_.points),"handlePolygonPointsClick"in _&&t(4,d=_.handlePolygonPointsClick),"handlePolygonPointsDragMove"in _&&t(5,h=_.handlePolygonPointsDragMove),"handlePolygonPointsDragEnd"in _&&t(6,p=_.handlePolygonPointsDragEnd)},[n,o,a,u,d,h,p,l,r,i,c,f,g,m]}class PolygonPoints extends SvelteComponent{constructor(e){super(),init(this,e,instance$a,create_fragment$d,safe_not_equal,{viewId:0,stage:8,zoomFactor:1,polygonId:2,points:3,handlePolygonPointsClick:4,handlePolygonPointsDragMove:5,handlePolygonPointsDragEnd:6})}}function create_else_block(s){let e,t;return e=new Shape({props:{config:{sceneFunc:s[16],stroke:s[3],strokeWidth:s[2].strokeFactor,closed:!0,fill:hexToRGBA(s[3],.5),id:s[2].id}}}),e.$on("dblclick",s[11]),e.$on("click",s[12]),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p(n,r){const o={};r&12&&(o.config={sceneFunc:n[16],stroke:n[3],strokeWidth:n[2].strokeFactor,closed:!0,fill:hexToRGBA(n[3],.5),id:n[2].id}),e.$set(o)},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_if_block$6(s){let e,t,n,r;return e=new Shape({props:{config:{sceneFunc:s[15],stroke:s[3],strokeWidth:2/s[4][s[0]],closed:!0,fill:hexToRGBA(s[3],.5)}}}),n=new PolygonPoints({props:{viewId:s[0],stage:s[1],zoomFactor:s[4],polygonId:s[2].id,points:s[6].simplifiedPoints,handlePolygonPointsClick:null,handlePolygonPointsDragMove:s[8],handlePolygonPointsDragEnd:s[9]}}),{c(){create_component(e.$$.fragment),t=space(),create_component(n.$$.fragment)},l(o){claim_component(e.$$.fragment,o),t=claim_space(o),claim_component(n.$$.fragment,o)},m(o,a){mount_component(e,o,a),insert_hydration(o,t,a),mount_component(n,o,a),r=!0},p(o,a){const u={};a&89&&(u.config={sceneFunc:o[15],stroke:o[3],strokeWidth:2/o[4][o[0]],closed:!0,fill:hexToRGBA(o[3],.5)}),e.$set(u);const d={};a&1&&(d.viewId=o[0]),a&2&&(d.stage=o[1]),a&16&&(d.zoomFactor=o[4]),a&4&&(d.polygonId=o[2].id),a&64&&(d.points=o[6].simplifiedPoints),n.$set(d)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(n.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(n.$$.fragment,o),r=!1},d(o){o&&detach(t),destroy_component(e,o),destroy_component(n,o)}}}function create_default_slot$6(s){let e,t,n,r;const o=[create_if_block$6,create_else_block],a=[];function u(d,h){return d[7]?0:1}return e=u(s),t=a[e]=o[e](s),{c(){t.c(),n=empty()},l(d){t.l(d),n=empty()},m(d,h){a[e].m(d,h),insert_hydration(d,n,h),r=!0},p(d,h){let p=e;e=u(d),e===p?a[e].p(d,h):(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros(),t=a[e],t?t.p(d,h):(t=a[e]=o[e](d),t.c()),transition_in(t,1),t.m(n.parentNode,n))},i(d){r||(transition_in(t),r=!0)},o(d){transition_out(t),r=!1},d(d){d&&detach(n),a[e].d(d)}}}function create_fragment$c(s){let e,t;return e=new Group({props:{config:{id:`polygon-${s[2].id}`,draggable:s[7],visible:s[2].visible,opacity:s[2].opacity,listening:s[5].type==="PAN"},$$slots:{default:[create_default_slot$6]},$$scope:{ctx:s}}}),e.$on("dragend",s[17]),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p(n,[r]){const o={};r&164&&(o.config={id:`polygon-${n[2].id}`,draggable:n[7],visible:n[2].visible,opacity:n[2].opacity,listening:n[5].type==="PAN"}),r&262367&&(o.$$scope={dirty:r,ctx:n}),e.$set(o)},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function instance$9(s,e,t){let{viewId:n}=e,{newShape:r}=e,{stage:o}=e,{images:a={}}=e,{mask:u}=e,{color:d}=e,{zoomFactor:h}=e,{selectedTool:p}=e,l=!1,i={simplifiedSvg:u.svg,simplifiedPoints:u.svg.reduce((y,S)=>[...y,parseSvgPath(S)],[])};const c=(y,S)=>{const w=o.findOne(`#dot-${u.id}-${S}-${y}`).position(),k=i.simplifiedPoints.map((P,I)=>I===S?P.map(F=>F.id===y?{...F,x:w.x,y:w.y}:F):P);t(6,i.simplifiedPoints=k,i)},f=y=>{const S=runLengthEncode(y||i.simplifiedSvg,a[n].width,a[n].height);u.editing&&t(13,r={status:"editing",type:"mask",shapeId:u.id,counts:S})},g=y=>{if(y.id()!==`polygon-${u.id}`)return;const S=y.x(),w=y.y(),k=i.simplifiedPoints.map(F=>F.map(C=>({...C,x:C.x+S,y:C.y+w})));o.findOne(`#polygon-${u.id}`).position({x:0,y:0}),t(6,i.simplifiedPoints=k,i);const I=i.simplifiedPoints.map(F=>convertPointToSvg(F));f(I)},m=()=>{t(13,r={status:"editing",shapeId:u.id,highlighted:"self",type:"none"})},_=()=>{u.highlighted!=="self"&&t(13,r={status:"editing",shapeId:u.id,highlighted:"all",type:"none"})},b=(y,S)=>sceneFunc(y,S,i.simplifiedSvg),v=(y,S)=>sceneFunc(y,S,u.svg),T=y=>g(y.detail.target);return s.$$set=y=>{"viewId"in y&&t(0,n=y.viewId),"newShape"in y&&t(13,r=y.newShape),"stage"in y&&t(1,o=y.stage),"images"in y&&t(14,a=y.images),"mask"in y&&t(2,u=y.mask),"color"in y&&t(3,d=y.color),"zoomFactor"in y&&t(4,h=y.zoomFactor),"selectedTool"in y&&t(5,p=y.selectedTool)},s.$$.update=()=>{s.$$.dirty&4&&t(7,l=u.editing),s.$$.dirty&4&&t(6,i.simplifiedPoints=u.svg.reduce((y,S)=>[...y,parseSvgPath(S)],[]),i),s.$$.dirty&64&&t(6,i.simplifiedSvg=i.simplifiedPoints.map(y=>convertPointToSvg(y)),i)},[n,o,u,d,h,p,i,l,c,f,g,m,_,r,a,b,v,T]}class PolygonGroup extends SvelteComponent{constructor(e){super(),init(this,e,instance$9,create_fragment$c,safe_not_equal,{viewId:0,newShape:13,stage:1,images:14,mask:2,color:3,zoomFactor:4,selectedTool:5})}}function create_if_block$5(s){let e,t;return e=new Group({props:{config:{id:"polygon",draggable:!0},$$slots:{default:[create_default_slot$5]},$$scope:{ctx:s}}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p(n,r){const o={};r&2174&&(o.$$scope={dirty:r,ctx:n}),e.$set(o)},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_default_slot$5(s){let e,t,n,r;return e=new Line({props:{config:{points:s[6],stroke:"hsl(316deg 60% 29.41%)",strokeWidth:INPUTRECT_STROKEWIDTH/s[3][s[1]],fill:"#f9f4f773",closed:s[5]}}}),n=new PolygonPoints({props:{viewId:s[1],stage:s[2],zoomFactor:s[3],polygonId:POLYGON_ID,points:s[4],handlePolygonPointsClick:s[7],handlePolygonPointsDragMove:s[8],handlePolygonPointsDragEnd:null}}),{c(){create_component(e.$$.fragment),t=space(),create_component(n.$$.fragment)},l(o){claim_component(e.$$.fragment,o),t=claim_space(o),claim_component(n.$$.fragment,o)},m(o,a){mount_component(e,o,a),insert_hydration(o,t,a),mount_component(n,o,a),r=!0},p(o,a){const u={};a&106&&(u.config={points:o[6],stroke:"hsl(316deg 60% 29.41%)",strokeWidth:INPUTRECT_STROKEWIDTH/o[3][o[1]],fill:"#f9f4f773",closed:o[5]}),e.$set(u);const d={};a&2&&(d.viewId=o[1]),a&4&&(d.stage=o[2]),a&8&&(d.zoomFactor=o[3]),a&16&&(d.points=o[4]),n.$set(d)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(n.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(n.$$.fragment,o),r=!1},d(o){o&&detach(t),destroy_component(e,o),destroy_component(n,o)}}}function create_fragment$b(s){let e,t,n="viewId"in s[0]&&s[0].viewId===s[1]&&create_if_block$5(s);return{c(){n&&n.c(),e=empty()},l(r){n&&n.l(r),e=empty()},m(r,o){n&&n.m(r,o),insert_hydration(r,e,o),t=!0},p(r,[o]){"viewId"in r[0]&&r[0].viewId===r[1]?n?(n.p(r,o),o&3&&transition_in(n,1)):(n=create_if_block$5(r),n.c(),transition_in(n,1),n.m(e.parentNode,e)):n&&(group_outros(),transition_out(n,1,1,()=>{n=null}),check_outros())},i(r){t||(transition_in(n),t=!0)},o(r){transition_out(n),t=!1},d(r){r&&detach(e),n&&n.d(r)}}}const POLYGON_ID="creating";function instance$8(s,e,t){let n,{viewId:r}=e,{selectedItemId:o}=e,{newShape:a}=e,{stage:u}=e,{images:d={}}=e,{zoomFactor:h}=e,p=[],l=!1;function i(f,g){if(f===0){const m=p.map(b=>convertPointToSvg(b)),_=runLengthEncode(m,d[g].width,d[g].height);t(0,a={status:"saving",masksImageSVG:[],rle:{counts:_,size:[d[g].height,d[g].width]},type:"mask",viewId:g,itemId:o,imageWidth:d[g].width,imageHeight:d[g].height}),t(5,l=!0)}}function c(f,g){const m=u.findOne(`#dot-${POLYGON_ID}-${g}-${f}`).position(),_=p.map((b,v)=>v===g?b.map(T=>T.id===f?{...T,x:m.x,y:m.y}:T):b);t(4,p=_)}return s.$$set=f=>{"viewId"in f&&t(1,r=f.viewId),"selectedItemId"in f&&t(9,o=f.selectedItemId),"newShape"in f&&t(0,a=f.newShape),"stage"in f&&t(2,u=f.stage),"images"in f&&t(10,d=f.images),"zoomFactor"in f&&t(3,h=f.zoomFactor)},s.$$.update=()=>{var f,g;if(s.$$.dirty&17){if(a.status==="creating"&&a.type==="mask"){const m=a.points.at(-1),_=(f=p==null?void 0:p[0])==null?void 0:f.at(-1);m&&(m==null?void 0:m.id)!==(_==null?void 0:_.id)&&t(4,p=[[...p[0]||[],m]]),a.points.length===0&&t(4,p=[])}a.status==="none"&&(t(4,p=[]),t(5,l=!1))}s.$$.dirty&16&&t(6,n=(g=p[0])==null?void 0:g.reduce((m,_)=>[...m,_.x,_.y],[]))},[a,r,u,h,p,l,n,i,c,o,d]}class CreatePolygon extends SvelteComponent{constructor(e){super(),init(this,e,instance$8,create_fragment$b,safe_not_equal,{viewId:1,selectedItemId:9,newShape:0,stage:2,images:10,zoomFactor:3})}}const toggleIsEditingBBox=(s,e,t)=>{const n=e.findOne(`#rect${t}`),r=e.findOne("#transformer");if(n){const o=r==null?void 0:r.nodes();r==null||r.nodes(s==="on"?[n]:[...o.filter(a=>a.id()!==n.id())])}else r==null||r.nodes([])},onDragMove=(s,e,t,n,r)=>{const a=e.findOne(`#${t}`).findOne(`#image-${t}`);if(!a)return;const u=a.getSize();s.target.x()<0&&n.x(0),s.target.x()>u.width-n.width()&&n.x(u.width-n.width()),s.target.y()<0&&n.y(0),s.target.y()>u.height-n.height()&&n.y(u.height-n.height());const d=e.findOne(`#tooltip${r}`);stickLabelsToRectangle(d,n)},getNewRectangleDimensions=(s,e,t)=>{const o=e.findOne(`#${t}`).findOne(`#image-${t}`).getSize(),a=s==null?void 0:s.width(),u=s==null?void 0:s.height(),d=o.width,h=o.height,p=(s==null?void 0:s.x())/d,l=(s==null?void 0:s.y())/h,i=a/d,c=u/h;return[p,l,i,c]},stickLabelsToRectangle=(s,e)=>{s.x(e.x()),s.y(e.y())};function create_default_slot$4(s){let e,t,n,r;return e=new Tag({props:{config:{fill:s[7],stroke:s[6]?s[7]:"transparent"}}}),n=new Text({props:{config:{id:`text${s[0]}`,x:0,y:0,text:s[6],fontSize:12,fontStyle:"100"}}}),{c(){create_component(e.$$.fragment),t=space(),create_component(n.$$.fragment)},l(o){claim_component(e.$$.fragment,o),t=claim_space(o),claim_component(n.$$.fragment,o)},m(o,a){mount_component(e,o,a),insert_hydration(o,t,a),mount_component(n,o,a),r=!0},p(o,a){const u={};a&192&&(u.config={fill:o[7],stroke:o[6]?o[7]:"transparent"}),e.$set(u);const d={};a&65&&(d.config={id:`text${o[0]}`,x:0,y:0,text:o[6],fontSize:12,fontStyle:"100"}),n.$set(d)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(n.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(n.$$.fragment,o),r=!1},d(o){o&&detach(t),destroy_component(e,o),destroy_component(n,o)}}}function create_fragment$a(s){let e,t;return e=new Label({props:{config:{id:`tooltip${s[0]}`,x:s[1],y:s[2],width:500,height:50,offsetY:12,visible:s[3],scale:{x:1/s[4],y:1/s[4]},opacity:s[5]},$$slots:{default:[create_default_slot$4]},$$scope:{ctx:s}}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p(n,[r]){const o={};r&63&&(o.config={id:`tooltip${n[0]}`,x:n[1],y:n[2],width:500,height:50,offsetY:12,visible:n[3],scale:{x:1/n[4],y:1/n[4]},opacity:n[5]}),r&449&&(o.$$scope={dirty:r,ctx:n}),e.$set(o)},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function instance$7(s,e,t){let{id:n}=e,{x:r}=e,{y:o}=e,{visible:a=!0}=e,{zoomFactor:u}=e,{opacity:d=1}=e,{tooltip:h}=e,{color:p}=e;return s.$$set=l=>{"id"in l&&t(0,n=l.id),"x"in l&&t(1,r=l.x),"y"in l&&t(2,o=l.y),"visible"in l&&t(3,a=l.visible),"zoomFactor"in l&&t(4,u=l.zoomFactor),"opacity"in l&&t(5,d=l.opacity),"tooltip"in l&&t(6,h=l.tooltip),"color"in l&&t(7,p=l.color)},[n,r,o,a,u,d,h,p]}class LabelTag extends SvelteComponent{constructor(e){super(),init(this,e,instance$7,create_fragment$a,safe_not_equal,{id:0,x:1,y:2,visible:3,zoomFactor:4,opacity:5,tooltip:6,color:7})}}function create_default_slot$3(s){let e,t,n,r;return e=new Rect({props:{config:{id:`rect${s[0].id}`,x:s[0].bbox[0],y:s[0].bbox[1],width:s[0].bbox[2],height:s[0].bbox[3],stroke:s[1](s[0].id),strokeWidth:s[0].strokeFactor*(BBOX_STROKEWIDTH/s[2]),opacity:s[0].opacity,visible:s[0].visible,draggable:s[0].editing}}}),n=new LabelTag({props:{id:s[0].id,x:s[0].bbox[0],y:s[0].bbox[1],visible:s[0].visible,zoomFactor:s[2],opacity:s[0].opacity,tooltip:s[0].tooltip,color:s[1](s[0].id)}}),{c(){create_component(e.$$.fragment),t=space(),create_component(n.$$.fragment)},l(o){claim_component(e.$$.fragment,o),t=claim_space(o),claim_component(n.$$.fragment,o)},m(o,a){mount_component(e,o,a),insert_hydration(o,t,a),mount_component(n,o,a),r=!0},p(o,a){const u={};a&7&&(u.config={id:`rect${o[0].id}`,x:o[0].bbox[0],y:o[0].bbox[1],width:o[0].bbox[2],height:o[0].bbox[3],stroke:o[1](o[0].id),strokeWidth:o[0].strokeFactor*(BBOX_STROKEWIDTH/o[2]),opacity:o[0].opacity,visible:o[0].visible,draggable:o[0].editing}),e.$set(u);const d={};a&1&&(d.id=o[0].id),a&1&&(d.x=o[0].bbox[0]),a&1&&(d.y=o[0].bbox[1]),a&1&&(d.visible=o[0].visible),a&4&&(d.zoomFactor=o[2]),a&1&&(d.opacity=o[0].opacity),a&1&&(d.tooltip=o[0].tooltip),a&3&&(d.color=o[1](o[0].id)),n.$set(d)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(n.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(n.$$.fragment,o),r=!1},d(o){o&&detach(t),destroy_component(e,o),destroy_component(n,o)}}}function create_fragment$9(s){var n;let e,t;return e=new Group({props:{config:{listening:((n=s[3])==null?void 0:n.type)==="PAN"},$$slots:{default:[create_default_slot$3]},$$scope:{ctx:s}}}),e.$on("dblclick",s[4]),e.$on("click",s[5]),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,o){mount_component(e,r,o),t=!0},p(r,[o]){var u;const a={};o&8&&(a.config={listening:((u=r[3])==null?void 0:u.type)==="PAN"}),o&4103&&(a.$$scope={dirty:o,ctx:r}),e.$set(a)},i(r){t||(transition_in(e.$$.fragment,r),t=!0)},o(r){transition_out(e.$$.fragment,r),t=!1},d(r){destroy_component(e,r)}}}function instance$6(s,e,t){let{stage:n}=e,{bbox:r}=e,{colorScale:o}=e,{zoomFactor:a}=e,{viewId:u}=e,{newShape:d}=e,{selectedTool:h}=e,p=n.findOne(`#rect${r.id}`);function l(g){const m=getNewRectangleDimensions(g,n,u);t(6,d={status:"editing",type:"rectangle",shapeId:r.id,coords:m})}const i=()=>{const g=n.findOne(`#${u}`),m=p.getClientRect({skipTransform:!1,skipShadow:!0,skipStroke:!0,relativeTo:g});p.setAttrs({x:m.x,y:m.y,width:m.width,height:m.height,rotation:0,scaleX:1,scaleY:1});const _=n.findOne(`#tooltip${r.id}`);stickLabelsToRectangle(_,p)},c=()=>{t(6,d={status:"editing",shapeId:r.id,highlighted:"self",type:"none"})},f=()=>{r.highlighted!=="self"&&t(6,d={status:"editing",shapeId:r.id,highlighted:"all",type:"none"})};return onDestroy(()=>{const g=n.findOne("#transformer");g&&g.nodes([])}),s.$$set=g=>{"stage"in g&&t(7,n=g.stage),"bbox"in g&&t(0,r=g.bbox),"colorScale"in g&&t(1,o=g.colorScale),"zoomFactor"in g&&t(2,a=g.zoomFactor),"viewId"in g&&t(8,u=g.viewId),"newShape"in g&&t(6,d=g.newShape),"selectedTool"in g&&t(3,h=g.selectedTool)},s.$$.update=()=>{if(s.$$.dirty&129&&toggleIsEditingBBox(r.editing?"on":"off",n,r.id),s.$$.dirty&897){const g=n.findOne(`#${u}`);t(9,p=g.findOne(`#rect${r.id}`)),p&&(p.on("dragmove",m=>onDragMove(m,n,u,p,r.id)),p.on("transform",()=>i()),p.on("transformend dragend",()=>{l(p)}))}},[r,o,a,h,c,f,d,n,u,p]}class Rectangle extends SvelteComponent{constructor(e){super(),init(this,e,instance$6,create_fragment$9,safe_not_equal,{stage:7,bbox:0,colorScale:1,zoomFactor:2,viewId:8,newShape:6,selectedTool:3})}}function create_if_block$4(s){let e,t,n;function r(a){s[11](a)}let o={config:{id:"drag-rect-group"},$$slots:{default:[create_default_slot$2]},$$scope:{ctx:s}};return s[3]!==void 0&&(o.handle=s[3]),e=new Group({props:o}),binding_callbacks.push(()=>bind(e,"handle",r)),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,u){mount_component(e,a,u),n=!0},p(a,u){const d={};u&5105&&(d.$$scope={dirty:u,ctx:a}),!t&&u&8&&(t=!0,d.handle=a[3],add_flush_callback(()=>t=!1)),e.$set(d)},i(a){n||(transition_in(e.$$.fragment,a),n=!0)},o(a){transition_out(e.$$.fragment,a),n=!1},d(a){destroy_component(e,a)}}}function create_if_block_1$3(s){let e,t;return e=new LabelTag({props:{id:"drag-rect-tag",x:s[8],y:s[9],zoomFactor:s[0],tooltip:`${Math.round(Math.abs(s[6]))}px x ${Math.round(Math.abs(s[7]))}px`,color:"#fff"}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p(n,r){const o={};r&256&&(o.x=n[8]),r&512&&(o.y=n[9]),r&1&&(o.zoomFactor=n[0]),r&192&&(o.tooltip=`${Math.round(Math.abs(n[6]))}px x ${Math.round(Math.abs(n[7]))}px`),e.$set(o)},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_default_slot$2(s){let e,t,n,r;e=new Rect({props:{config:{id:"drag-rect",x:s[4],y:s[5],width:s[6],height:s[7],stroke:"hsl(316deg 60% 29.41%)",fill:"#f9f4f773",strokeWidth:INPUTRECT_STROKEWIDTH/s[0],listening:!1}}});let o=s[8]&&s[9]&&create_if_block_1$3(s);return{c(){create_component(e.$$.fragment),t=space(),o&&o.c(),n=empty()},l(a){claim_component(e.$$.fragment,a),t=claim_space(a),o&&o.l(a),n=empty()},m(a,u){mount_component(e,a,u),insert_hydration(a,t,u),o&&o.m(a,u),insert_hydration(a,n,u),r=!0},p(a,u){const d={};u&241&&(d.config={id:"drag-rect",x:a[4],y:a[5],width:a[6],height:a[7],stroke:"hsl(316deg 60% 29.41%)",fill:"#f9f4f773",strokeWidth:INPUTRECT_STROKEWIDTH/a[0],listening:!1}),e.$set(d),a[8]&&a[9]?o?(o.p(a,u),u&768&&transition_in(o,1)):(o=create_if_block_1$3(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(e.$$.fragment,a),transition_in(o),r=!0)},o(a){transition_out(e.$$.fragment,a),transition_out(o),r=!1},d(a){a&&(detach(t),detach(n)),destroy_component(e,a),o&&o.d(a)}}}function create_fragment$8(s){let e,t,n=s[1].viewId===s[2]&&create_if_block$4(s);return{c(){n&&n.c(),e=empty()},l(r){n&&n.l(r),e=empty()},m(r,o){n&&n.m(r,o),insert_hydration(r,e,o),t=!0},p(r,[o]){r[1].viewId===r[2]?n?(n.p(r,o),o&6&&transition_in(n,1)):(n=create_if_block$4(r),n.c(),transition_in(n,1),n.m(e.parentNode,e)):n&&(group_outros(),transition_out(n,1,1,()=>{n=null}),check_outros())},i(r){t||(transition_in(n),t=!0)},o(r){transition_out(n),t=!1},d(r){r&&detach(e),n&&n.d(r)}}}function instance$5(s,e,t){let{zoomFactor:n}=e,{newShape:r}=e,{stage:o}=e,{viewId:a}=e,u,d,h,p,l,i,c;function f(g){u=g,t(3,u)}return s.$$set=g=>{"zoomFactor"in g&&t(0,n=g.zoomFactor),"newShape"in g&&t(1,r=g.newShape),"stage"in g&&t(10,o=g.stage),"viewId"in g&&t(2,a=g.viewId)},s.$$.update=()=>{if(s.$$.dirty&1038&&r.status==="creating"){const g=u==null?void 0:u.findOne("#drag-rect");if(g){const m=o.findOne(`#${a}`),_=g.getClientRect({skipTransform:!1,skipShadow:!0,skipStroke:!0,relativeTo:m});t(4,d=r.x),t(5,h=r.y),t(6,p=r.width),t(7,l=r.height),t(8,i=_==null?void 0:_.x),t(9,c=_==null?void 0:_.y)}}},[n,r,a,u,d,h,p,l,i,c,o,f]}class CreateRectangle extends SvelteComponent{constructor(e){super(),init(this,e,instance$5,create_fragment$8,safe_not_equal,{zoomFactor:0,newShape:1,stage:10,viewId:2})}}function get_each_context(s,e,t){const n=s.slice();return n[75]=e[t],n}function get_each_context_1(s,e,t){const n=s.slice();return n[78]=e[t],n}function get_each_context_2(s,e,t){const n=s.slice();return n[81]=e[t],n}function create_if_block_1$2(s){let e,t;function n(...r){return s[34](s[75],...r)}return e=new Layer({props:{config:{id:s[75].id},$$slots:{default:[create_default_slot_1]},$$scope:{ctx:s}}}),e.$on("wheel",n),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,o){mount_component(e,r,o),t=!0},p(r,o){s=r;const a={};o[0]&8&&(a.config={id:s[75].id}),o[0]&5311|o[2]&4194304&&(a.$$scope={dirty:o,ctx:s}),e.$set(a)},i(r){t||(transition_in(e.$$.fragment,r),t=!0)},o(r){transition_out(e.$$.fragment,r),t=!1},d(r){destroy_component(e,r)}}}function create_if_block_4(s){let e,t;return e=new CreateRectangle({props:{zoomFactor:s[10][s[75].id],newShape:s[1],stage:s[5],viewId:s[75].id}}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p(n,r){const o={};r[0]&1032&&(o.zoomFactor=n[10][n[75].id]),r[0]&2&&(o.newShape=n[1]),r[0]&32&&(o.stage=n[5]),r[0]&8&&(o.viewId=n[75].id),e.$set(o)},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_if_block_3$1(s){let e=s[81].id,t,n,r=create_key_block_1(s);return{c(){r.c(),t=empty()},l(o){r.l(o),t=empty()},m(o,a){r.m(o,a),insert_hydration(o,t,a),n=!0},p(o,a){a[0]&1&&safe_not_equal(e,e=o[81].id)?(group_outros(),transition_out(r,1,1,noop),check_outros(),r=create_key_block_1(o),r.c(),transition_in(r,1),r.m(t.parentNode,t)):r.p(o,a)},i(o){n||(transition_in(r),n=!0)},o(o){transition_out(r),n=!1},d(o){o&&detach(t),r.d(o)}}}function create_key_block_1(s){let e,t,n;function r(a){s[31](a)}let o={bbox:s[81],colorScale:s[7],zoomFactor:s[10][s[75].id],stage:s[5],viewId:s[75].id,selectedTool:s[4]};return s[1]!==void 0&&(o.newShape=s[1]),e=new Rectangle({props:o}),binding_callbacks.push(()=>bind(e,"newShape",r)),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,u){mount_component(e,a,u),n=!0},p(a,u){const d={};u[0]&1&&(d.bbox=a[81]),u[0]&128&&(d.colorScale=a[7]),u[0]&1032&&(d.zoomFactor=a[10][a[75].id]),u[0]&32&&(d.stage=a[5]),u[0]&8&&(d.viewId=a[75].id),u[0]&16&&(d.selectedTool=a[4]),!t&&u[0]&2&&(t=!0,d.newShape=a[1],add_flush_callback(()=>t=!1)),e.$set(d)},i(a){n||(transition_in(e.$$.fragment,a),n=!0)},o(a){transition_out(e.$$.fragment,a),n=!1},d(a){destroy_component(e,a)}}}function create_each_block_2(s){let e,t,n=s[81].viewId===s[75].id&&create_if_block_3$1(s);return{c(){n&&n.c(),e=empty()},l(r){n&&n.l(r),e=empty()},m(r,o){n&&n.m(r,o),insert_hydration(r,e,o),t=!0},p(r,o){r[81].viewId===r[75].id?n?(n.p(r,o),o[0]&9&&transition_in(n,1)):(n=create_if_block_3$1(r),n.c(),transition_in(n,1),n.m(e.parentNode,e)):n&&(group_outros(),transition_out(n,1,1,()=>{n=null}),check_outros())},i(r){t||(transition_in(n),t=!0)},o(r){transition_out(n),t=!1},d(r){r&&detach(e),n&&n.d(r)}}}function create_if_block_2$1(s){let e,t,n;function r(a){s[33](a)}let o={viewId:s[75].id,stage:s[5],images:s[12],zoomFactor:s[10],mask:s[78],color:s[7](s[78].id),selectedTool:s[4]};return s[1]!==void 0&&(o.newShape=s[1]),e=new PolygonGroup({props:o}),binding_callbacks.push(()=>bind(e,"newShape",r)),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,u){mount_component(e,a,u),n=!0},p(a,u){const d={};u[0]&8&&(d.viewId=a[75].id),u[0]&32&&(d.stage=a[5]),u[0]&4096&&(d.images=a[12]),u[0]&1024&&(d.zoomFactor=a[10]),u[0]&4&&(d.mask=a[78]),u[0]&132&&(d.color=a[7](a[78].id)),u[0]&16&&(d.selectedTool=a[4]),!t&&u[0]&2&&(t=!0,d.newShape=a[1],add_flush_callback(()=>t=!1)),e.$set(d)},i(a){n||(transition_in(e.$$.fragment,a),n=!0)},o(a){transition_out(e.$$.fragment,a),n=!1},d(a){destroy_component(e,a)}}}function create_key_block$1(s){let e,t,n=s[78].viewId===s[75].id&&create_if_block_2$1(s);return{c(){n&&n.c(),e=empty()},l(r){n&&n.l(r),e=empty()},m(r,o){n&&n.m(r,o),insert_hydration(r,e,o),t=!0},p(r,o){r[78].viewId===r[75].id?n?(n.p(r,o),o[0]&12&&transition_in(n,1)):(n=create_if_block_2$1(r),n.c(),transition_in(n,1),n.m(e.parentNode,e)):n&&(group_outros(),transition_out(n,1,1,()=>{n=null}),check_outros())},i(r){t||(transition_in(n),t=!0)},o(r){transition_out(n),t=!1},d(r){r&&detach(e),n&&n.d(r)}}}function create_each_block_1(s){let e=s[78].id,t,n,r=create_key_block$1(s);return{c(){r.c(),t=empty()},l(o){r.l(o),t=empty()},m(o,a){r.m(o,a),insert_hydration(o,t,a),n=!0},p(o,a){a[0]&4&&safe_not_equal(e,e=o[78].id)?(group_outros(),transition_out(r,1,1,noop),check_outros(),r=create_key_block$1(o),r.c(),transition_in(r,1),r.m(t.parentNode,t)):r.p(o,a)},i(o){n||(transition_in(r),n=!0)},o(o){transition_out(r),n=!1},d(o){o&&detach(t),r.d(o)}}}function create_default_slot_1(s){let e,t,n,r,o,a,u,d,h,p,l,i,c,f,g,m,_;function b(...$){return s[28](s[75],...$)}function v(){return s[29](s[75])}function T(){return s[30](s[75])}e=new Image$1({props:{config:{image:s[12][s[75].id],id:`image-${s[75].id}`}}}),e.$on("pointerdown",b),e.$on("pointerup",v),e.$on("dblclick",T),n=new Group({props:{config:{id:"currentAnnotation"}}}),o=new Group({props:{config:{id:"masks"}}}),u=new Group({props:{config:{id:"bboxes"}}}),h=new Group({props:{config:{id:"input"}}});let y=(s[1].status==="creating"&&s[1].type==="rectangle"||s[1].status==="saving"&&s[1].type==="rectangle")&&create_if_block_4(s),S=ensure_array_like(s[0]),w=[];for(let $=0;$<S.length;$+=1)w[$]=create_each_block_2(get_each_context_2(s,S,$));const k=$=>transition_out(w[$],1,1,()=>{w[$]=null});function P($){s[32]($)}let I={viewId:s[75].id,stage:s[5],images:s[12],zoomFactor:s[10],selectedItemId:s[3].id};s[1]!==void 0&&(I.newShape=s[1]),c=new CreatePolygon({props:I}),binding_callbacks.push(()=>bind(c,"newShape",P));let F=ensure_array_like(s[2]),C=[];for(let $=0;$<F.length;$+=1)C[$]=create_each_block_1(get_each_context_1(s,F,$));const E=$=>transition_out(C[$],1,1,()=>{C[$]=null});return{c(){create_component(e.$$.fragment),t=space(),create_component(n.$$.fragment),r=space(),create_component(o.$$.fragment),a=space(),create_component(u.$$.fragment),d=space(),create_component(h.$$.fragment),p=space(),y&&y.c(),l=space();for(let $=0;$<w.length;$+=1)w[$].c();i=space(),create_component(c.$$.fragment),g=space();for(let $=0;$<C.length;$+=1)C[$].c();m=empty()},l($){claim_component(e.$$.fragment,$),t=claim_space($),claim_component(n.$$.fragment,$),r=claim_space($),claim_component(o.$$.fragment,$),a=claim_space($),claim_component(u.$$.fragment,$),d=claim_space($),claim_component(h.$$.fragment,$),p=claim_space($),y&&y.l($),l=claim_space($);for(let x=0;x<w.length;x+=1)w[x].l($);i=claim_space($),claim_component(c.$$.fragment,$),g=claim_space($);for(let x=0;x<C.length;x+=1)C[x].l($);m=empty()},m($,x){mount_component(e,$,x),insert_hydration($,t,x),mount_component(n,$,x),insert_hydration($,r,x),mount_component(o,$,x),insert_hydration($,a,x),mount_component(u,$,x),insert_hydration($,d,x),mount_component(h,$,x),insert_hydration($,p,x),y&&y.m($,x),insert_hydration($,l,x);for(let A=0;A<w.length;A+=1)w[A]&&w[A].m($,x);insert_hydration($,i,x),mount_component(c,$,x),insert_hydration($,g,x);for(let A=0;A<C.length;A+=1)C[A]&&C[A].m($,x);insert_hydration($,m,x),_=!0},p($,x){s=$;const A={};if(x[0]&4104&&(A.config={image:s[12][s[75].id],id:`image-${s[75].id}`}),e.$set(A),s[1].status==="creating"&&s[1].type==="rectangle"||s[1].status==="saving"&&s[1].type==="rectangle"?y?(y.p(s,x),x[0]&2&&transition_in(y,1)):(y=create_if_block_4(s),y.c(),transition_in(y,1),y.m(l.parentNode,l)):y&&(group_outros(),transition_out(y,1,1,()=>{y=null}),check_outros()),x[0]&1211){S=ensure_array_like(s[0]);let B;for(B=0;B<S.length;B+=1){const H=get_each_context_2(s,S,B);w[B]?(w[B].p(H,x),transition_in(w[B],1)):(w[B]=create_each_block_2(H),w[B].c(),transition_in(w[B],1),w[B].m(i.parentNode,i))}for(group_outros(),B=S.length;B<w.length;B+=1)k(B);check_outros()}const L={};if(x[0]&8&&(L.viewId=s[75].id),x[0]&32&&(L.stage=s[5]),x[0]&4096&&(L.images=s[12]),x[0]&1024&&(L.zoomFactor=s[10]),x[0]&8&&(L.selectedItemId=s[3].id),!f&&x[0]&2&&(f=!0,L.newShape=s[1],add_flush_callback(()=>f=!1)),c.$set(L),x[0]&5310){F=ensure_array_like(s[2]);let B;for(B=0;B<F.length;B+=1){const H=get_each_context_1(s,F,B);C[B]?(C[B].p(H,x),transition_in(C[B],1)):(C[B]=create_each_block_1(H),C[B].c(),transition_in(C[B],1),C[B].m(m.parentNode,m))}for(group_outros(),B=F.length;B<C.length;B+=1)E(B);check_outros()}},i($){if(!_){transition_in(e.$$.fragment,$),transition_in(n.$$.fragment,$),transition_in(o.$$.fragment,$),transition_in(u.$$.fragment,$),transition_in(h.$$.fragment,$),transition_in(y);for(let x=0;x<S.length;x+=1)transition_in(w[x]);transition_in(c.$$.fragment,$);for(let x=0;x<F.length;x+=1)transition_in(C[x]);_=!0}},o($){transition_out(e.$$.fragment,$),transition_out(n.$$.fragment,$),transition_out(o.$$.fragment,$),transition_out(u.$$.fragment,$),transition_out(h.$$.fragment,$),transition_out(y),w=w.filter(Boolean);for(let x=0;x<w.length;x+=1)transition_out(w[x]);transition_out(c.$$.fragment,$),C=C.filter(Boolean);for(let x=0;x<C.length;x+=1)transition_out(C[x]);_=!1},d($){$&&(detach(t),detach(r),detach(a),detach(d),detach(p),detach(l),detach(i),detach(g),detach(m)),destroy_component(e,$),destroy_component(n,$),destroy_component(o,$),destroy_component(u,$),destroy_component(h,$),y&&y.d($),destroy_each(w,$),destroy_component(c,$),destroy_each(C,$)}}}function create_each_block(s){let e,t,n=s[12][s[75].id]&&create_if_block_1$2(s);return{c(){n&&n.c(),e=empty()},l(r){n&&n.l(r),e=empty()},m(r,o){n&&n.m(r,o),insert_hydration(r,e,o),t=!0},p(r,o){r[12][r[75].id]?n?(n.p(r,o),o[0]&4104&&transition_in(n,1)):(n=create_if_block_1$2(r),n.c(),transition_in(n,1),n.m(e.parentNode,e)):n&&(group_outros(),transition_out(n,1,1,()=>{n=null}),check_outros())},i(r){t||(transition_in(n),t=!0)},o(r){transition_out(n),t=!1},d(r){r&&detach(e),n&&n.d(r)}}}function create_default_slot$1(s){let e,t,n,r,o=ensure_array_like(Object.values(s[3].views)),a=[];for(let p=0;p<o.length;p+=1)a[p]=create_each_block(get_each_context(s,o,p));const u=p=>transition_out(a[p],1,1,()=>{a[p]=null});function d(p){s[35](p)}let h={config:{name:"tools"}};return s[13]!==void 0&&(h.handle=s[13]),t=new Layer({props:h}),binding_callbacks.push(()=>bind(t,"handle",d)),{c(){for(let p=0;p<a.length;p+=1)a[p].c();e=space(),create_component(t.$$.fragment)},l(p){for(let l=0;l<a.length;l+=1)a[l].l(p);e=claim_space(p),claim_component(t.$$.fragment,p)},m(p,l){for(let i=0;i<a.length;i+=1)a[i]&&a[i].m(p,l);insert_hydration(p,e,l),mount_component(t,p,l),r=!0},p(p,l){if(l[0]&3937471){o=ensure_array_like(Object.values(p[3].views));let c;for(c=0;c<o.length;c+=1){const f=get_each_context(p,o,c);a[c]?(a[c].p(f,l),transition_in(a[c],1)):(a[c]=create_each_block(f),a[c].c(),transition_in(a[c],1),a[c].m(e.parentNode,e))}for(group_outros(),c=o.length;c<a.length;c+=1)u(c);check_outros()}const i={};!n&&l[0]&8192&&(n=!0,i.handle=p[13],add_flush_callback(()=>n=!1)),t.$set(i)},i(p){if(!r){for(let l=0;l<o.length;l+=1)transition_in(a[l]);transition_in(t.$$.fragment,p),r=!0}},o(p){a=a.filter(Boolean);for(let l=0;l<a.length;l+=1)transition_out(a[l]);transition_out(t.$$.fragment,p),r=!1},d(p){p&&detach(e),destroy_each(a,p),destroy_component(t,p)}}}function create_if_block$3(s){let e,t;return e=new WarningModal({props:{message:"No embeddings found for view '"+s[9]+"'.",details:"The embeddings may not have finished loading yet. Please try again."}}),e.$on("confirm",s[39]),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p(n,r){const o={};r[0]&512&&(o.message="No embeddings found for view '"+n[9]+"'."),e.$set(o)},i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_fragment$7(s){let e,t,n,r,o,a,u,d,h,p;function l(g){s[36](g)}function i(g){s[37](g)}let c={$$slots:{default:[create_default_slot$1]},$$scope:{ctx:s}};s[14]!==void 0&&(c.config=s[14]),s[5]!==void 0&&(c.handle=s[5]),t=new Stage({props:c}),binding_callbacks.push(()=>bind(t,"config",l)),binding_callbacks.push(()=>bind(t,"handle",i)),t.$on("mousemove",s[15]),t.$on("mouseenter",s[16]),t.$on("mouseleave",s[17]);let f=s[8]&&create_if_block$3(s);return{c(){e=element("div"),create_component(t.$$.fragment),a=space(),f&&f.c(),u=empty(),this.h()},l(g){e=claim_element(g,"DIV",{class:!0});var m=children(e);claim_component(t.$$.fragment,m),m.forEach(detach),a=claim_space(g),f&&f.l(g),u=empty(),this.h()},h(){attr(e,"class",o=cn("flex h-full w-full bg-slate-800 transition-opacity duration-300 delay-100",{"opacity-0":!s[6]}))},m(g,m){insert_hydration(g,e,m),mount_component(t,e,null),s[38](e),insert_hydration(g,a,m),f&&f.m(g,m),insert_hydration(g,u,m),d=!0,h||(p=listen(window,"keydown",s[22]),h=!0)},p(g,m){const _={};m[0]&13503|m[2]&4194304&&(_.$$scope={dirty:m,ctx:g}),!n&&m[0]&16384&&(n=!0,_.config=g[14],add_flush_callback(()=>n=!1)),!r&&m[0]&32&&(r=!0,_.handle=g[5],add_flush_callback(()=>r=!1)),t.$set(_),(!d||m[0]&64&&o!==(o=cn("flex h-full w-full bg-slate-800 transition-opacity duration-300 delay-100",{"opacity-0":!g[6]})))&&attr(e,"class",o),g[8]?f?(f.p(g,m),m[0]&256&&transition_in(f,1)):(f=create_if_block$3(g),f.c(),transition_in(f,1),f.m(u.parentNode,u)):f&&(group_outros(),transition_out(f,1,1,()=>{f=null}),check_outros())},i(g){d||(transition_in(t.$$.fragment,g),transition_in(f),d=!0)},o(g){transition_out(t.$$.fragment,g),transition_out(f),d=!1},d(g){g&&(detach(e),detach(a),detach(u)),destroy_component(t),s[38](null),f&&f.d(g),h=!1,p()}}}function zoom(s,e,t){const r=s.findOne(`#${t}`),o=r.scaleX(),a=s.getRelativePointerPosition(),u={x:(a.x-r.x())/o,y:(a.y-r.y())/o},d=e>0?o*1.05:o/1.05,h={x:a.x-u.x*d,y:a.y-u.y*d};return r.scale({x:d,y:d}),r.position(h),d}function instance$4(s,e,t){let{selectedItem:n}=e,{colorRange:r=["0","10"]}=e,{masks:o}=e,{bboxes:a}=e,{embeddings:u={}}=e,{currentAnn:d=null}=e,{selectedTool:h}=e,{newShape:p}=e,l=!1,i,c=!1,f="",g,m,_={},b,v,T={},y,S,w=null,k=new Konva.Transformer({id:"transformer",rotateEnabled:!1}),P={width:1024,height:780,name:"konva",id:"stage"},I={rows:0,cols:0},F;const C=new ResizeObserver(N=>{for(const j of N)if(j.target===v){let Z,te;if(j.contentBoxSize){const ie=j.contentBoxSize instanceof ResizeObserverSize?j.contentBoxSize:j.contentBoxSize[0];Z=ie.inlineSize,te=ie.blockSize}else Z=j.contentRect.width,te=j.contentRect.height;y.width(Z),y.height(te),y.batchDraw()}});onMount(()=>{E(),C.observe(v)}),onDestroy(()=>{$e()}),afterUpdate(()=>{F!==n.id&&E(),h?H():y.container().style.cursor="default",d&&d.validated&&B();for(const N of Object.keys(n.views)){const j=y.findOne(`#${N}`);j&&j.add(k)}});function E(){I.cols=Math.ceil(Math.sqrt(Object.keys(n.views).length)),I.rows=Math.ceil(Object.keys(n.views).length/I.cols),F&&$e();for(const N of Object.values(n.views))t(10,_[N.id]=1,_),t(12,T[N.id]=new Image,T),isValidURL(N.uri)?t(12,T[N.id].src=`${N.uri}`||N.url,T):t(12,T[N.id].src=`/${N.uri}`||N.url,T),t(12,T[N.id].onload=()=>{F&&y.findOne(`#${N.id}`).findOne(`#image-${N.id}`).image(T[N.id]),$(N),x(N),t(6,l=!0),t(2,o),t(0,a)},T);F=n.id}function $(N){const j=y.findOne(`#${N.id}`);if(j){const Z=y.width()/I.cols,te=y.height()/I.rows;let ie=0;for(const me of Object.keys(n.views)){if(me===N.id)break;ie++}const ue={x:ie%I.cols,y:Math.floor(ie/I.cols)},le=te/T[N.id].height,Ne=Z/T[N.id].width,Re=Math.min(Ne,le);t(10,_[N.id]=Re,_),j.scale({x:Re,y:Re});const W=(Z-T[N.id].width*Re)/2+ue.x*Z,de=(te-T[N.id].height*Re)/2+ue.y*te;j.x(W),j.y(de)}else console.log("Canvas2D.scaleView - Error: Cannot scale")}function x(N){const j=y.findOne(`#${N.id}`),Z=j.findOne("#input");for(const le of Z.children)le instanceof Konva.Circle&&(le.radius(INPUTPOINT_RADIUS/_[N.id]),le.strokeWidth(INPUTPOINT_STROKEWIDTH/_[N.id])),le instanceof Konva.Rect&&le.strokeWidth(INPUTRECT_STROKEWIDTH/_[N.id]);const te=j.findOne("#bboxes");if(!te)return;for(const le of te.children)if(le instanceof Konva.Group)for(const Ne of le.children)Ne instanceof Konva.Rect&&Ne.strokeWidth(BBOX_STROKEWIDTH/_[N.id]),Ne instanceof Konva.Label&&Ne.scale({x:1/_[N.id],y:1/_[N.id]});const ie=j.findOne("#masks");for(const le of ie.children)le instanceof Konva.Shape&&le.strokeWidth(MASK_STROKEWIDTH/_[N.id]);const ue=findOrCreateCurrentMask(N.id,y);for(const le of ue.children)le instanceof Konva.Shape&&le.strokeWidth(MASK_STROKEWIDTH/_[N.id])}function A(N){let j;return N.getAncestors().forEach(Z=>{Z instanceof Konva.Layer&&(j=Z.id())}),j}async function L(N){const j=fe(N),Z=Oe(N),te={image:T[N],embedding:N in u?u[N]:null,points:j,box:Z};if(h.postProcessor==null)$e();else if(u[N]==null)t(8,c=!0),t(9,f=N),$e();else{const ie=await h.postProcessor.segmentImage(te);if(ie){t(1,p={masksImageSVG:ie.masksImageSVG,rle:ie.rle,type:"mask",viewId:N,itemId:n.id,imageWidth:T[N].width,imageHeight:T[N].height,status:"saving"});const ue=findOrCreateCurrentMask(N,y),Ne=y.findOne(`#${N}`).findOne(`#image-${N}`);ue.removeChildren(),t(23,d={id:nanoid(10),viewId:N,label:"",catId:-1,output:ie,input_points:j,input_box:Z,validated:!1});const Re={id:d.id,viewId:N,svg:d.output.masksImageSVG,rle:d.output.rle,catId:d.catId,visible:!0,opacity:1};addMask(Re,"#008000",ue,Ne,N,y,_)}}}function B(){if(d.validated){const N=findOrCreateCurrentMask(d.viewId,y);N&&N.destroyChildren(),w&&ye(w),J(d.viewId),t(23,d=null)}}function H(){switch(S&&S.moveToTop(),h.type){case"POINT_SELECTION":re(h);break;case"RECTANGLE":pe(h);break;case"DELETE":$e(),Ae(h);break;case"PAN":ee(h);break;case"CLASSIFICATION":Q(h);break}}function J(N){const j=y==null?void 0:y.findOne(`#${N}`);j&&j.findOne("#input").destroyChildren()}function X(N){if((p==null?void 0:p.status)==="saving")return;const Z=y.findOne(`#${N}`).getRelativePointerPosition(),te=Math.round(Z.x),ie=Math.round(Z.y),ue=p.status==="creating"&&p.type==="mask"?p.points:[];t(1,p={status:"creating",type:"mask",points:[...ue,{x:te,y:ie,id:ue.length||0}],viewId:N})}function ee(N){if(S){const j=y.findOne(`#${POINT_SELECTION}`);j&&j.destroy();const Z=y.findOne("#crossline");Z&&Z.destroy(),w||(y.container().style.cursor=N.cursor),ge(!1)}}function Q(N){if(S){const j=y.findOne(`#${POINT_SELECTION}`);j&&j.destroy();const Z=y.findOne("#crossline");Z&&Z.destroy(),w||(y.container().style.cursor=N.cursor),ge(!1)}}function re(N){if(S){const j=S.findOne("#crossline");j&&j.destroy();const Z=ce(N.type),te=N.label===1?"green":"red";Z.stroke(te),w||(y.container().style.cursor=N.cursor),ge(!0)}}function oe(N){const j=ce(h.type),Z=y.scaleX(),te=Math.max(1,1/Z);j.scaleX(te),j.scaleY(te),j.x(N.x+1),j.y(N.y+1)}function ce(N,j=null){let Z=y.findOne(`#${N}`);if(!Z){let te=1;j&&(te=_[j]),Z=new Konva.Circle({id:N,x:0,y:0,radius:INPUTPOINT_RADIUS/te,fill:"white",strokeWidth:INPUTPOINT_STROKEWIDTH/te,visible:!1,listening:!1,opacity:.5}),S.add(Z)}return Z}function fe(N){const j=[],te=y.findOne(`#${N}`).findOne("#input");for(const ie of te.children)if(ie instanceof Konva.Circle){const ue={x:ie.x(),y:ie.y(),label:parseInt(ie.name())};j.push(ue)}return j}function ge(N){const j=y.find("#input");for(const Z of j)for(const te of Z.children)te instanceof Konva.Circle&&te.listening(N)}function we(){y.container().style.cursor="grab"}function xe(N,j){y.container().style.cursor="grabbing";const ie=y.findOne(`#${j}`).findOne(`#image-${j}`).getSize();N.x()<0?N.x(0):N.x()>ie.width&&N.x(ie.width),N.y()<0?N.y(0):N.y()>ie.height&&N.y(ie.height),clearTimeout(b),b=setTimeout(()=>L(j),50)}function _e(N,j){ce(h.type,j).hide(),N.radius(1.5*INPUTPOINT_RADIUS/_[j]),w=N,y.container().style.cursor="grab"}function ye(N,j=null){ce(h.type,j).show(),j||(j=A(N)),N.radius(INPUTPOINT_RADIUS/_[j]),w=null,y.container().style.cursor=h.cursor,y.batchDraw()}function pe(N){if(S){const j=y.findOne(`#${POINT_SELECTION}`);j&&j.destroy(),w||(y.container().style.cursor=N.cursor),ge(!0)}}function Se(N){const j=y.scaleX(),Z=Math.max(1,1/j),[te,ie]=Ie(),ue=y.height();te.scaleY(Z),te.points([N.x,0,N.x,ue]);const le=y.width();ie.scaleX(Z),ie.points([0,N.y,le,N.y])}function Ie(){const N=y.height(),j=y.width();let Z=S.findOne("#crossline"),te,ie;return Z?(te=Z.findOne("#xline"),ie=Z.findOne("#yline")):(Z=new Konva.Group({id:"crossline"}),te=new Konva.Line({id:"xline",points:[0,0,0,N],stroke:"white",strokeWidth:1,opacity:.75,dash:[5,1]}),ie=new Konva.Line({id:"yline",points:[0,0,j,0],stroke:"white",strokeWidth:1,opacity:.75,dash:[5,1]}),Z.add(te),Z.add(ie),S.add(Z)),[te,ie]}function Oe(N){let j=null;const te=y.findOne(`#${N}`).findOne("#input");for(const ie of te.children)if(ie instanceof Konva.Rect){const ue=ie.size(),le=ie.position();j={x:le.x,y:le.y,width:ue.width,height:ue.height};break}return j}function Pe(N){if((h==null?void 0:h.type)==="RECTANGLE"){const Z=y.findOne(`#${N}`).getRelativePointerPosition(),te=p.status==="creating"&&p.type==="rectangle"?p.x:Z.x,ie=p.status==="creating"&&p.type==="rectangle"?p.y:Z.y;t(1,p={status:"creating",type:"rectangle",x:te,y:ie,width:Z.x-te,height:Z.y-ie,viewId:N})}}async function Ce(N){if((h==null?void 0:h.type)=="RECTANGLE"){const j=y.findOne(`#${N}`),Z=y.findOne("#drag-rect");if(Z){const{width:te,height:ie}=Z.size();if(te==0||ie==0)t(1,p={status:"none"});else{if(!h.isSmart){const ue=Z.getClientRect({skipTransform:!1,skipShadow:!0,skipStroke:!0,relativeTo:j});t(1,p={status:"saving",attrs:{x:ue.x,y:ue.y,width:ue.width,height:ue.height},type:"rectangle",viewId:N,itemId:n.id,imageWidth:T[N].width,imageHeight:T[N].height})}h.isSmart&&await L(N)}j.off("pointermove"),j.off("pointerup")}h.isSmart&&Z.destroy()}}function Ae(N){if(S){const j=y.findOne(`#${POINT_SELECTION}`);j&&j.destroy();const Z=y.findOne("#crossline");Z&&Z.destroy(),w||(y.container().style.cursor=N.cursor),ge(!1)}}function $e(){if(!y)return;for(const Z of Object.keys(n.views))J(Z),clearCurrentAnn(Z,y,h);h&&(y.container().style.cursor=h.cursor);const N=y.findOne(`#${POINT_SELECTION}`);N&&N.destroy();const j=S==null?void 0:S.findOne("#crossline");j&&j.destroy(),t(23,d=null)}function Me(){const N=y.getRelativePointerPosition();(h==null?void 0:h.type)==="POINT_SELECTION"&&oe(N),(h==null?void 0:h.type)==="RECTANGLE"&&Se(N)}function ke(){for(const N of S.children)N.show()}function Fe(){for(const N of S.children)N.hide()}function Ze(N){const j=y.findOne(`#${N}`);j.draggable(!1),j.off("dragend dragmove")}function We(N){const j=y.findOne(`#${N}`);if(j.draggable(!1),j.off("dragend dragmove"),(h==null?void 0:h.type)==="POLYGON"&&X(N),w){const Z=j.getRelativePointerPosition(),te=w.position();(Z.x!==te.x||Z.y!==te.y)&&ye(w,N)}}function je(N){y.findOne(`#${N}`).moveToTop(),S.moveToTop()}async function Ge(N,j){const Z=y.findOne(`#${j}`);if((p.status==="none"||p.status=="editing"&&p.type=="none")&&t(1,p={status:"editing",type:"none",shapeId:null,highlighted:"all"}),(h==null?void 0:h.type)=="PAN"||N.button==1)Z.draggable(!0),Z.on("dragmove",Me),Z.on("dragend",()=>Ze(j));else if((h==null?void 0:h.type)=="POINT_SELECTION"){const te=Z.getRelativePointerPosition(),ie=new Konva.Circle({name:`${h.label}`,x:te.x,y:te.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});ie.on("pointerenter",le=>_e(le.target,j)),ie.on("pointerout",le=>ye(le.target,j)),ie.on("dragmove",le=>void xe(le.target,j)),ie.on("dragend",()=>we()),Z.findOne("#input").add(ie),_e(ie,j),await L(j)}else(h==null?void 0:h.type)=="RECTANGLE"&&(Z.on("pointermove",()=>Pe(j)),Z.on("pointerup",()=>void Ce(j)))}function ze(N,j){N.preventDefault();let Z=N.deltaY<0?1:-1;N.ctrlKey&&(Z=-Z),t(10,_[j.id]=zoom(y,Z,j.id),_),x(j),w&&_e(w,j.id)}async function qe(N){var j,Z;if(N.key=="Delete"&&w!=null){const te=A(w),ie=w;ye(w,te),ie.destroy(),y.findOne(`#${te}`).findOne("#input").children.length>0?await L(te):clearCurrentAnn(te,y,h)}if(N.key=="i"){console.log("Canvas2D - Infos"),console.log("masks",o),console.log("bboxes",a),console.log("currentAnn",d),console.log("stage",y);for(const te of Object.keys(n.views)){const ie=y.findOne(`#${te}`),ue=ie.findOne("#masks"),le=ie.findOne("#bboxes");console.log("masks Konva group:",ue),console.log("masks children length:",(j=ue.children)==null?void 0:j.length),console.log("bboxes Konva group:",le),console.log("bboxes children length:",(Z=le.children)==null?void 0:Z.length)}}}const Qe=(N,j)=>Ge(j.detail.evt,N.id),Ke=N=>We(N.id),Ue=N=>je(N.id);function Ye(N){p=N,t(1,p)}function He(N){p=N,t(1,p)}function se(N){p=N,t(1,p)}const Be=(N,j)=>ze(j.detail.evt,N);function Xe(N){S=N,t(13,S)}function R(N){P=N,t(14,P)}function U(N){y=N,t(5,y)}function G(N){binding_callbacks[N?"unshift":"push"](()=>{v=N,t(11,v)})}const Y=()=>t(8,c=!1);return s.$$set=N=>{"selectedItem"in N&&t(3,n=N.selectedItem),"colorRange"in N&&t(24,r=N.colorRange),"masks"in N&&t(2,o=N.masks),"bboxes"in N&&t(0,a=N.bboxes),"embeddings"in N&&t(25,u=N.embeddings),"currentAnn"in N&&t(23,d=N.currentAnn),"selectedTool"in N&&t(4,h=N.selectedTool),"newShape"in N&&t(1,p=N.newShape)},s.$$.update=()=>{if(s.$$.dirty[0]&134217744&&((!(m!=null&&m.isSmart)||!(h!=null&&h.isSmart))&&$e(),t(27,m=h)),s.$$.dirty[0]&2&&p.status==="none"&&p.shouldReset&&$e(),s.$$.dirty[0]&16777216&&t(7,i=ordinalColorScale(r)),s.$$.dirty[0]&67108897){if(y&&g!==(a==null?void 0:a.length)){const N=y==null?void 0:y.findOne("#drag-rect");N&&N.destroy()}t(26,g=a.length)}},[a,p,o,n,h,y,l,i,c,f,_,v,T,S,P,Me,ke,Fe,We,je,Ge,ze,qe,d,r,u,g,m,Qe,Ke,Ue,Ye,He,se,Be,Xe,R,U,G,Y]}class Canvas2D extends SvelteComponent{constructor(e){super(),init(this,e,instance$4,create_fragment$7,safe_not_equal,{selectedItem:3,colorRange:24,masks:2,bboxes:0,embeddings:25,currentAnn:23,selectedTool:4,newShape:1},null,[-1,-1,-1])}}function create_key_block(s){let e,t,n,r,o;function a(p){s[9](p)}function u(p){s[10](p)}function d(p){s[11](p)}let h={selectedItem:s[1],colorRange:s[5],bboxes:s[6],masks:s[7],embeddings:s[2]};return s[4]!==void 0&&(h.selectedTool=s[4]),s[0]!==void 0&&(h.currentAnn=s[0]),s[3]!==void 0&&(h.newShape=s[3]),e=new Canvas2D({props:h}),binding_callbacks.push(()=>bind(e,"selectedTool",a)),binding_callbacks.push(()=>bind(e,"currentAnn",u)),binding_callbacks.push(()=>bind(e,"newShape",d)),{c(){create_component(e.$$.fragment)},l(p){claim_component(e.$$.fragment,p)},m(p,l){mount_component(e,p,l),o=!0},p(p,l){const i={};l&2&&(i.selectedItem=p[1]),l&32&&(i.colorRange=p[5]),l&64&&(i.bboxes=p[6]),l&128&&(i.masks=p[7]),l&4&&(i.embeddings=p[2]),!t&&l&16&&(t=!0,i.selectedTool=p[4],add_flush_callback(()=>t=!1)),!n&&l&1&&(n=!0,i.currentAnn=p[0],add_flush_callback(()=>n=!1)),!r&&l&8&&(r=!0,i.newShape=p[3],add_flush_callback(()=>r=!1)),e.$set(i)},i(p){o||(transition_in(e.$$.fragment,p),o=!0)},o(p){transition_out(e.$$.fragment,p),o=!1},d(p){destroy_component(e,p)}}}function create_fragment$6(s){let e=s[1].id,t,n,r=create_key_block(s);return{c(){r.c(),t=empty()},l(o){r.l(o),t=empty()},m(o,a){r.m(o,a),insert_hydration(o,t,a),n=!0},p(o,[a]){a&2&&safe_not_equal(e,e=o[1].id)?(group_outros(),transition_out(r,1,1,noop),check_outros(),r=create_key_block(o),r.c(),transition_in(r,1),r.m(t.parentNode,t)):r.p(o,a)},i(o){n||(transition_in(r),n=!0)},o(o){transition_out(r),n=!1},d(o){o&&detach(t),r.d(o)}}}function instance$3(s,e,t){let n,r,o,a;component_subscribe(s,selectedTool,g=>t(4,n=g)),component_subscribe(s,preAnnotationIsActive,g=>t(8,r=g)),component_subscribe(s,itemBboxes,g=>t(6,o=g)),component_subscribe(s,itemMasks,g=>t(7,a=g));let{selectedItem:u}=e,{embeddings:d}=e,{currentAnn:h=null}=e,p,l=[];itemObjects.subscribe(g=>{t(5,l=g.map(m=>m.id))});function i(g){n=g,selectedTool.set(n)}function c(g){h=g,t(0,h)}function f(g){p=g,t(3,p)}return s.$$set=g=>{"selectedItem"in g&&t(1,u=g.selectedItem),"embeddings"in g&&t(2,d=g.embeddings),"currentAnn"in g&&t(0,h=g.currentAnn)},s.$$.update=()=>{s.$$.dirty&264&&(newShape.set(p),(p==null?void 0:p.status)==="editing"&&!r&&(itemObjects.update(g=>updateExistingObject(g,p)),canSave.update(g=>g||(p==null?void 0:p.status)==="editing"&&p.type!=="none"))),s.$$.dirty&16&&selectedTool.set(n)},newShape.subscribe(g=>{t(3,p=g)}),[h,u,d,p,n,l,o,a,r,i,c,f]}class ImageViewer extends SvelteComponent{constructor(e){super(),init(this,e,instance$3,create_fragment$6,safe_not_equal,{selectedItem:1,embeddings:2,currentAnn:0})}}function create_fragment$5(s){let e,t="Video player should be displayed here";return{c(){e=element("div"),e.textContent=t},l(n){e=claim_element(n,"DIV",{"data-svelte-h":!0}),get_svelte_dataset(e)!=="svelte-1ig6pgx"&&(e.textContent=t)},m(n,r){insert_hydration(n,e,r)},p:noop,i:noop,o:noop,d(n){n&&detach(e)}}}class VideoViewer extends SvelteComponent{constructor(e){super(),init(this,e,null,create_fragment$5,safe_not_equal,{})}}function create_fragment$4(s){let e,t="Display here the 3D viewer";return{c(){e=element("div"),e.textContent=t,this.h()},l(n){e=claim_element(n,"DIV",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(e)!=="svelte-112fjhm"&&(e.textContent=t),this.h()},h(){attr(e,"class","bg-white p-12")},m(n,r){insert_hydration(n,e,r)},p:noop,i:noop,o:noop,d(n){n&&detach(e)}}}class Canvas3D extends SvelteComponent{constructor(e){super(),init(this,e,null,create_fragment$4,safe_not_equal,{})}}function create_fragment$3(s){let e,t;return e=new Canvas3D({}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p:noop,i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}class _3DViewer extends SvelteComponent{constructor(e){super(),init(this,e,null,create_fragment$3,safe_not_equal,{})}}function create_if_block_3(s){let e,t;return e=new _3DViewer({}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p:noop,i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_if_block_2(s){let e,t;return e=new VideoViewer({}),{c(){create_component(e.$$.fragment)},l(n){claim_component(e.$$.fragment,n)},m(n,r){mount_component(e,n,r),t=!0},p:noop,i(n){t||(transition_in(e.$$.fragment,n),t=!0)},o(n){transition_out(e.$$.fragment,n),t=!1},d(n){destroy_component(e,n)}}}function create_if_block_1$1(s){let e,t,n;function r(a){s[5](a)}let o={selectedItem:s[1],embeddings:s[2]};return s[0]!==void 0&&(o.currentAnn=s[0]),e=new ImageViewer({props:o}),binding_callbacks.push(()=>bind(e,"currentAnn",r)),{c(){create_component(e.$$.fragment)},l(a){claim_component(e.$$.fragment,a)},m(a,u){mount_component(e,a,u),n=!0},p(a,u){const d={};u&2&&(d.selectedItem=a[1]),u&4&&(d.embeddings=a[2]),!t&&u&1&&(t=!0,d.currentAnn=a[0],add_flush_callback(()=>t=!1)),e.$set(d)},i(a){n||(transition_in(e.$$.fragment,a),n=!0)},o(a){transition_out(e.$$.fragment,a),n=!1},d(a){destroy_component(e,a)}}}function create_if_block$2(s){let e,t,n;return t=new Loader_2({props:{class:"animate-spin text-white"}}),{c(){e=element("div"),create_component(t.$$.fragment),this.h()},l(r){e=claim_element(r,"DIV",{class:!0});var o=children(e);claim_component(t.$$.fragment,o),o.forEach(detach),this.h()},h(){attr(e,"class","h-full w-full flex justify-center items-center")},m(r,o){insert_hydration(r,e,o),mount_component(t,e,null),n=!0},p:noop,i(r){n||(transition_in(t.$$.fragment,r),n=!0)},o(r){transition_out(t.$$.fragment,r),n=!1},d(r){r&&detach(e),destroy_component(t)}}}function create_fragment$2(s){let e,t,n,r;const o=[create_if_block$2,create_if_block_1$1,create_if_block_2,create_if_block_3],a=[];function u(d,h){return d[3]?0:d[4]==="image"?1:d[4]==="video"?2:d[4]==="3d"?3:-1}return~(t=u(s))&&(n=a[t]=o[t](s)),{c(){e=element("div"),n&&n.c(),this.h()},l(d){e=claim_element(d,"DIV",{class:!0});var h=children(e);n&&n.l(h),h.forEach(detach),this.h()},h(){attr(e,"class","max-w-[100%] bg-slate-800")},m(d,h){insert_hydration(d,e,h),~t&&a[t].m(e,null),r=!0},p(d,[h]){let p=t;t=u(d),t===p?~t&&a[t].p(d,h):(n&&(group_outros(),transition_out(a[p],1,1,()=>{a[p]=null}),check_outros()),~t?(n=a[t],n?n.p(d,h):(n=a[t]=o[t](d),n.c()),transition_in(n,1),n.m(e,null)):n=null)},i(d){r||(transition_in(n),r=!0)},o(d){transition_out(n),r=!1},d(d){d&&detach(e),~t&&a[t].d()}}}function instance$2(s,e,t){let n,{selectedItem:r}=e,{embeddings:o}=e,{currentAnn:a=null}=e,{isLoading:u}=e;function d(h){a=h,t(0,a)}return s.$$set=h=>{"selectedItem"in h&&t(1,r=h.selectedItem),"embeddings"in h&&t(2,o=h.embeddings),"currentAnn"in h&&t(0,a=h.currentAnn),"isLoading"in h&&t(3,u=h.isLoading)},s.$$.update=()=>{s.$$.dirty&2&&t(4,n=Object.values(r.views).map(h=>h.type)[0])},[a,r,o,u,n,d]}class DatasetItemViewer extends SvelteComponent{constructor(e){super(),init(this,e,instance$2,create_fragment$2,safe_not_equal,{selectedItem:1,embeddings:2,currentAnn:0,isLoading:3})}}function create_if_block$1(s){let e,t,n;return t=new Loader_2({props:{class:"animate-spin"}}),{c(){e=element("div"),create_component(t.$$.fragment),this.h()},l(r){e=claim_element(r,"DIV",{class:!0});var o=children(e);claim_component(t.$$.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-slate-300 z-50 opacity-30")},m(r,o){insert_hydration(r,e,o),mount_component(t,e,null),n=!0},i(r){n||(transition_in(t.$$.fragment,r),n=!0)},o(r){transition_out(t.$$.fragment,r),n=!1},d(r){r&&detach(e),destroy_component(t)}}}function create_fragment$1(s){let e,t,n,r,o,a,u,d,h,p,l,i=s[4]&&create_if_block$1();n=new Toolbar({}),o=new DatasetItemViewer({props:{selectedItem:s[1],embeddings:s[5],isLoading:s[3]}}),u=new InspectorInspector({props:{isLoading:s[3]}}),u.$on("click",s[6]);function c(g){s[10](g)}let f={models:s[2],currentDatasetId:s[0].id,selectedItemId:s[1].id};return s[5]!==void 0&&(f.embeddings=s[5]),h=new LoadModelModal({props:f}),binding_callbacks.push(()=>bind(h,"embeddings",c)),{c(){e=element("div"),i&&i.c(),t=space(),create_component(n.$$.fragment),r=space(),create_component(o.$$.fragment),a=space(),create_component(u.$$.fragment),d=space(),create_component(h.$$.fragment),this.h()},l(g){e=claim_element(g,"DIV",{class:!0});var m=children(e);i&&i.l(m),t=claim_space(m),claim_component(n.$$.fragment,m),r=claim_space(m),claim_component(o.$$.fragment,m),a=claim_space(m),claim_component(u.$$.fragment,m),d=claim_space(m),claim_component(h.$$.fragment,m),m.forEach(detach),this.h()},h(){attr(e,"class","w-full h-full grid grid-cols-[48px_calc(100%-380px-48px)_380px]")},m(g,m){insert_hydration(g,e,m),i&&i.m(e,null),append_hydration(e,t),mount_component(n,e,null),append_hydration(e,r),mount_component(o,e,null),append_hydration(e,a),mount_component(u,e,null),append_hydration(e,d),mount_component(h,e,null),l=!0},p(g,[m]){g[4]?i?m&16&&transition_in(i,1):(i=create_if_block$1(),i.c(),transition_in(i,1),i.m(e,t)):i&&(group_outros(),transition_out(i,1,1,()=>{i=null}),check_outros());const _={};m&2&&(_.selectedItem=g[1]),m&32&&(_.embeddings=g[5]),m&8&&(_.isLoading=g[3]),o.$set(_);const b={};m&8&&(b.isLoading=g[3]),u.$set(b);const v={};m&4&&(v.models=g[2]),m&1&&(v.currentDatasetId=g[0].id),m&2&&(v.selectedItemId=g[1].id),!p&&m&32&&(p=!0,v.embeddings=g[5],add_flush_callback(()=>p=!1)),h.$set(v)},i(g){l||(transition_in(i),transition_in(n.$$.fragment,g),transition_in(o.$$.fragment,g),transition_in(u.$$.fragment,g),transition_in(h.$$.fragment,g),l=!0)},o(g){transition_out(i),transition_out(n.$$.fragment,g),transition_out(o.$$.fragment,g),transition_out(u.$$.fragment,g),transition_out(h.$$.fragment,g),l=!1},d(g){g&&detach(e),i&&i.d(),destroy_component(n),destroy_component(o),destroy_component(u),destroy_component(h)}}}function instance$1(s,e,t){let{currentDataset:n}=e,{selectedItem:r}=e,{models:o=[]}=e,{handleSaveItem:a}=e,{isLoading:u}=e,{canSaveCurrentItem:d}=e,{shouldSaveCurrentItem:h}=e,p=!1,l={};canSave.subscribe(f=>t(7,d=f));const i=async()=>{t(4,p=!0);let f={...r};itemObjects.subscribe(g=>{f.objects=g.reduce((m,_)=>(m[_.id]=_,m),{})}),itemMetas.subscribe(g=>{f.features=g.mainFeatures}),await a(f),canSave.set(!1),t(4,p=!1)};function c(f){l=f,t(5,l)}return s.$$set=f=>{"currentDataset"in f&&t(0,n=f.currentDataset),"selectedItem"in f&&t(1,r=f.selectedItem),"models"in f&&t(2,o=f.models),"handleSaveItem"in f&&t(8,a=f.handleSaveItem),"isLoading"in f&&t(3,u=f.isLoading),"canSaveCurrentItem"in f&&t(7,d=f.canSaveCurrentItem),"shouldSaveCurrentItem"in f&&t(9,h=f.shouldSaveCurrentItem)},s.$$.update=()=>{var f;s.$$.dirty&2&&itemObjects.update(g=>Object.values(r.objects||{}).flat().map(m=>{const _=g.find(b=>b.id===m.id);return _?{..._,...m}:m})),s.$$.dirty&3&&itemMetas.set({mainFeatures:r.features,objectFeatures:(f=Object.values(r.objects||{})[0])==null?void 0:f.features,featuresList:n.features_values||{main:{},objects:{}},views:r.views,id:r.id}),s.$$.dirty&2&&r&&(newShape.update(g=>({...g,status:"none"})),canSave.set(!1)),s.$$.dirty&512&&h&&i().catch(g=>console.error(g))},[n,r,o,u,p,l,i,d,a,h,c]}class DatasetItemWorkspace extends SvelteComponent{constructor(e){super(),init(this,e,instance$1,create_fragment$1,safe_not_equal,{currentDataset:0,selectedItem:1,models:2,handleSaveItem:8,isLoading:3,canSaveCurrentItem:7,shouldSaveCurrentItem:9})}}function create_if_block_1(s){let e,t,n,r;function o(u){s[10](u)}let a={selectedItem:s[0],models:s[3],currentDataset:s[1],handleSaveItem:s[8],isLoading:s[5],shouldSaveCurrentItem:s[6]};return s[2]!==void 0&&(a.canSaveCurrentItem=s[2]),t=new DatasetItemWorkspace({props:a}),binding_callbacks.push(()=>bind(t,"canSaveCurrentItem",o)),{c(){e=element("div"),create_component(t.$$.fragment),this.h()},l(u){e=claim_element(u,"DIV",{class:!0});var d=children(e);claim_component(t.$$.fragment,d),d.forEach(detach),this.h()},h(){attr(e,"class","pt-20 h-1 min-h-screen")},m(u,d){insert_hydration(u,e,d),mount_component(t,e,null),r=!0},p(u,d){const h={};d&1&&(h.selectedItem=u[0]),d&8&&(h.models=u[3]),d&2&&(h.currentDataset=u[1]),d&32&&(h.isLoading=u[5]),d&64&&(h.shouldSaveCurrentItem=u[6]),!n&&d&4&&(n=!0,h.canSaveCurrentItem=u[2],add_flush_callback(()=>n=!1)),t.$set(h)},i(u){r||(transition_in(t.$$.fragment,u),r=!0)},o(u){transition_out(t.$$.fragment,u),r=!1},d(u){u&&detach(e),destroy_component(t)}}}function create_if_block(s){let e,t,n="Current item could not be loaded",r,o,a;return o=new PrimaryButton({props:{$$slots:{default:[create_default_slot]},$$scope:{ctx:s}}}),o.$on("click",s[11]),{c(){e=element("div"),t=element("p"),t.textContent=n,r=space(),create_component(o.$$.fragment),this.h()},l(u){e=claim_element(u,"DIV",{class:!0});var d=children(e);t=claim_element(d,"P",{"data-svelte-h":!0}),get_svelte_dataset(t)!=="svelte-7sd7em"&&(t.textContent=n),r=claim_space(d),claim_component(o.$$.fragment,d),d.forEach(detach),this.h()},h(){attr(e,"class","w-full pt-40 text-center flex flex-col gap-5 items-center")},m(u,d){insert_hydration(u,e,d),append_hydration(e,t),append_hydration(e,r),mount_component(o,e,null),a=!0},p(u,d){const h={};d&8192&&(h.$$scope={dirty:d,ctx:u}),o.$set(h)},i(u){a||(transition_in(o.$$.fragment,u),a=!0)},o(u){transition_out(o.$$.fragment,u),a=!1},d(u){u&&detach(e),destroy_component(o)}}}function create_default_slot(s){let e;return{c(){e=text("Back to dataset")},l(t){e=claim_text(t,"Back to dataset")},m(t,n){insert_hydration(t,e,n)},d(t){t&&detach(e)}}}function create_fragment(s){let e,t,n,r=s[0]&&s[1]&&create_if_block_1(s),o=!s[0]&&s[7]&&create_if_block(s);return{c(){r&&r.c(),e=space(),o&&o.c(),t=empty()},l(a){r&&r.l(a),e=claim_space(a),o&&o.l(a),t=empty()},m(a,u){r&&r.m(a,u),insert_hydration(a,e,u),o&&o.m(a,u),insert_hydration(a,t,u),n=!0},p(a,[u]){a[0]&&a[1]?r?(r.p(a,u),u&3&&transition_in(r,1)):(r=create_if_block_1(a),r.c(),transition_in(r,1),r.m(e.parentNode,e)):r&&(group_outros(),transition_out(r,1,1,()=>{r=null}),check_outros()),!a[0]&&a[7]?o?(o.p(a,u),u&129&&transition_in(o,1)):(o=create_if_block(a),o.c(),transition_in(o,1),o.m(t.parentNode,t)):o&&(group_outros(),transition_out(o,1,1,()=>{o=null}),check_outros())},i(a){n||(transition_in(r),transition_in(o),n=!0)},o(a){transition_out(r),transition_out(o),n=!1},d(a){a&&(detach(e),detach(t)),r&&r.d(a),o&&o.d(a)}}}function instance(s,e,t){let n,r,o,a,u,d=!1,h=!1,p=!1,l=!1;modelsStore$1.subscribe(m=>{t(3,o=m)}),saveCurrentItemStore.subscribe(m=>{t(2,h=m.canSave),t(6,p=m.shouldSave)});const i=(m,_)=>{m&&getDatasetItem(m.id,encodeURIComponent(_)).then(b=>{t(0,n=b),Object.keys(b).length===0?t(7,l=!0):t(7,l=!1)}).then(()=>isLoadingNewItemStore.set(!1)).catch(b=>console.error(b))};page.subscribe(m=>{t(4,a=m.params.dataset),t(9,u=m.params.itemId)}),datasetsStore.subscribe(m=>{const _=m==null?void 0:m.find(b=>b.name===a);_&&t(1,r=_)});async function c(m){await postDatasetItem(r.id,m),i(r,u),saveCurrentItemStore.update(_=>({..._,shouldSave:!1}))}function f(m){h=m,t(2,h)}const g=()=>goto(`/${a}/dataset`);return s.$$.update=()=>{s.$$.dirty&4&&saveCurrentItemStore.update(m=>({...m,canSave:h})),s.$$.dirty&515&&u!==(n==null?void 0:n.id)&&(isLoadingNewItemStore.set(!0),i(r,u))},isLoadingNewItemStore.subscribe(m=>{t(5,d=m)}),[n,r,h,o,a,d,p,l,c,u,f,g]}class Page extends SvelteComponent{constructor(e){super(),init(this,e,instance,create_fragment,safe_not_equal,{})}}export{Page as component,_page as universal};
