portfolio/dist/assets/index-DMCgMsst.js

5017 lines
1.2 MiB
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function xT(n,e){for(var t=0;t<e.length;t++){const r=e[t];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in n)){const o=Object.getOwnPropertyDescriptor(r,s);o&&Object.defineProperty(n,s,o.get?o:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function t(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=t(s);fetch(s.href,o)}})();var ey=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xf(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function D3(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var e=n.default;if(typeof e=="function"){var t=function r(){var s=!1;try{s=this instanceof r}catch{}return s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var s=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:function(){return n[r]}})}),t}var Qw={exports:{}},dm={},Jw={exports:{}},_t={};var m$;function O3(){if(m$)return _t;m$=1;var n=Symbol.for("react.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),i=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),c=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),p=Symbol.iterator;function m(V){return V===null||typeof V!="object"?null:(V=p&&V[p]||V["@@iterator"],typeof V=="function"?V:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,b={};function w(V,X,xe){this.props=V,this.context=X,this.refs=b,this.updater=xe||y}w.prototype.isReactComponent={},w.prototype.setState=function(V,X){if(typeof V!="object"&&typeof V!="function"&&V!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,V,X,"setState")},w.prototype.forceUpdate=function(V){this.updater.enqueueForceUpdate(this,V,"forceUpdate")};function k(){}k.prototype=w.prototype;function I(V,X,xe){this.props=V,this.context=X,this.refs=b,this.updater=xe||y}var N=I.prototype=new k;N.constructor=I,v(N,w.prototype),N.isPureReactComponent=!0;var T=Array.isArray,A=Object.prototype.hasOwnProperty,O={current:null},P={key:!0,ref:!0,__self:!0,__source:!0};function B(V,X,xe){var Ie,ke={},Ee=null,Me=null;if(X!=null)for(Ie in X.ref!==void 0&&(Me=X.ref),X.key!==void 0&&(Ee=""+X.key),X)A.call(X,Ie)&&!P.hasOwnProperty(Ie)&&(ke[Ie]=X[Ie]);var ze=arguments.length-2;if(ze===1)ke.children=xe;else if(1<ze){for(var Be=Array(ze),Je=0;Je<ze;Je++)Be[Je]=arguments[Je+2];ke.children=Be}if(V&&V.defaultProps)for(Ie in ze=V.defaultProps,ze)ke[Ie]===void 0&&(ke[Ie]=ze[Ie]);return{$$typeof:n,type:V,key:Ee,ref:Me,props:ke,_owner:O.current}}function z(V,X){return{$$typeof:n,type:V.type,key:X,ref:V.ref,props:V.props,_owner:V._owner}}function L(V){return typeof V=="object"&&V!==null&&V.$$typeof===n}function _(V){var X={"=":"=0",":":"=2"};return"$"+V.replace(/[=:]/g,function(xe){return X[xe]})}var H=/\/+/g;function Y(V,X){return typeof V=="object"&&V!==null&&V.key!=null?_(""+V.key):X.toString(36)}function re(V,X,xe,Ie,ke){var Ee=typeof V;(Ee==="undefined"||Ee==="boolean")&&(V=null);var Me=!1;if(V===null)Me=!0;else switch(Ee){case"string":case"number":Me=!0;break;case"object":switch(V.$$typeof){case n:case e:Me=!0}}if(Me)return Me=V,ke=ke(Me),V=Ie===""?"."+Y(Me,0):Ie,T(ke)?(xe="",V!=null&&(xe=V.replace(H,"$&/")+"/"),re(ke,X,xe,"",function(Je){return Je})):ke!=null&&(L(ke)&&(ke=z(ke,xe+(!ke.key||Me&&Me.key===ke.key?"":(""+ke.key).replace(H,"$&/")+"/")+V)),X.push(ke)),1;if(Me=0,Ie=Ie===""?".":Ie+":",T(V))for(var ze=0;ze<V.length;ze++){Ee=V[ze];var Be=Ie+Y(Ee,ze);Me+=re(Ee,X,xe,Be,ke)}else if(Be=m(V),typeof Be=="function")for(V=Be.call(V),ze=0;!(Ee=V.next()).done;)Ee=Ee.value,Be=Ie+Y(Ee,ze++),Me+=re(Ee,X,xe,Be,ke);else if(Ee==="object")throw X=String(V),Error("Objects are not valid as a React child (found: "+(X==="[object Object]"?"object with keys {"+Object.keys(V).join(", ")+"}":X)+"). If you meant to render a collection of children, use an array instead.");return Me}function te(V,X,xe){if(V==null)return V;var Ie=[],ke=0;return re(V,Ie,"","",function(Ee){return X.call(xe,Ee,ke++)}),Ie}function le(V){if(V._status===-1){var X=V._result;X=X(),X.then(function(xe){(V._status===0||V._status===-1)&&(V._status=1,V._result=xe)},function(xe){(V._status===0||V._status===-1)&&(V._status=2,V._result=xe)}),V._status===-1&&(V._status=0,V._result=X)}if(V._status===1)return V._result.default;throw V._result}var de={current:null},j={transition:null},ie={ReactCurrentDispatcher:de,ReactCurrentBatchConfig:j,ReactCurrentOwner:O};function se(){throw Error("act(...) is not supported in production builds of React.")}return _t.Children={map:te,forEach:function(V,X,xe){te(V,function(){X.apply(this,arguments)},xe)},count:function(V){var X=0;return te(V,function(){X++}),X},toArray:function(V){return te(V,function(X){return X})||[]},only:function(V){if(!L(V))throw Error("React.Children.only expected to receive a single React element child.");return V}},_t.Component=w,_t.Fragment=t,_t.Profiler=s,_t.PureComponent=I,_t.StrictMode=r,_t.Suspense=l,_t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ie,_t.act=se,_t.cloneElement=function(V,X,xe){if(V==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+V+".");var Ie=v({},V.props),ke=V.key,Ee=V.ref,Me=V._owner;if(X!=null){if(X.ref!==void 0&&(Ee=X.ref,Me=O.current),X.key!==void 0&&(ke=""+X.key),V.type&&V.type.defaultProps)var ze=V.type.defaultProps;for(Be in X)A.call(X,Be)&&!P.hasOwnProperty(Be)&&(Ie[Be]=X[Be]===void 0&&ze!==void 0?ze[Be]:X[Be])}var Be=arguments.length-2;if(Be===1)Ie.children=xe;else if(1<Be){ze=Array(Be);for(var Je=0;Je<Be;Je++)ze[Je]=arguments[Je+2];Ie.children=ze}return{$$typeof:n,type:V.type,key:ke,ref:Ee,props:Ie,_owner:Me}},_t.createContext=function(V){return V={$$typeof:i,_currentValue:V,_currentValue2:V,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},V.Provider={$$typeof:o,_context:V},V.Consumer=V},_t.createElement=B,_t.createFactory=function(V){var X=B.bind(null,V);return X.type=V,X},_t.createRef=function(){return{current:null}},_t.forwardRef=function(V){return{$$typeof:a,render:V}},_t.isValidElement=L,_t.lazy=function(V){return{$$typeof:d,_payload:{_status:-1,_result:V},_init:le}},_t.memo=function(V,X){return{$$typeof:c,type:V,compare:X===void 0?null:X}},_t.startTransition=function(V){var X=j.transition;j.transition={};try{V()}finally{j.transition=X}},_t.unstable_act=se,_t.useCallback=function(V,X){return de.current.useCallback(V,X)},_t.useContext=function(V){return de.current.useContext(V)},_t.useDebugValue=function(){},_t.useDeferredValue=function(V){return de.current.useDeferredValue(V)},_t.useEffect=function(V,X){return de.current.useEffect(V,X)},_t.useId=function(){return de.current.useId()},_t.useImperativeHandle=function(V,X,xe){return de.current.useImperativeHandle(V,X,xe)},_t.useInsertionEffect=function(V,X){return de.current.useInsertionEffect(V,X)},_t.useLayoutEffect=function(V,X){return de.current.useLayoutEffect(V,X)},_t.useMemo=function(V,X){return de.current.useMemo(V,X)},_t.useReducer=function(V,X,xe){return de.current.useReducer(V,X,xe)},_t.useRef=function(V){return de.current.useRef(V)},_t.useState=function(V){return de.current.useState(V)},_t.useSyncExternalStore=function(V,X,xe){return de.current.useSyncExternalStore(V,X,xe)},_t.useTransition=function(){return de.current.useTransition()},_t.version="18.3.1",_t}var g$;function Xm(){return g$||(g$=1,Jw.exports=O3()),Jw.exports}var x$;function F3(){if(x$)return dm;x$=1;var n=Xm(),e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,c){var d,p={},m=null,y=null;c!==void 0&&(m=""+c),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(y=l.ref);for(d in l)r.call(l,d)&&!o.hasOwnProperty(d)&&(p[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)p[d]===void 0&&(p[d]=l[d]);return{$$typeof:e,type:a,key:m,ref:y,props:p,_owner:s.current}}return dm.Fragment=t,dm.jsx=i,dm.jsxs=i,dm}var y$;function P3(){return y$||(y$=1,Qw.exports=F3()),Qw.exports}var ee=P3(),Re=Xm();const $t=xf(Re),L3=xT({__proto__:null,default:$t},[Re]);var ty={},Zw={exports:{}},Gs={},eb={exports:{}},tb={};var v$;function M3(){return v$||(v$=1,(function(n){function e(j,ie){var se=j.length;j.push(ie);e:for(;0<se;){var V=se-1>>>1,X=j[V];if(0<s(X,ie))j[V]=ie,j[se]=X,se=V;else break e}}function t(j){return j.length===0?null:j[0]}function r(j){if(j.length===0)return null;var ie=j[0],se=j.pop();if(se!==ie){j[0]=se;e:for(var V=0,X=j.length,xe=X>>>1;V<xe;){var Ie=2*(V+1)-1,ke=j[Ie],Ee=Ie+1,Me=j[Ee];if(0>s(ke,se))Ee<X&&0>s(Me,ke)?(j[V]=Me,j[Ee]=se,V=Ee):(j[V]=ke,j[Ie]=se,V=Ie);else if(Ee<X&&0>s(Me,se))j[V]=Me,j[Ee]=se,V=Ee;else break e}}return ie}function s(j,ie){var se=j.sortIndex-ie.sortIndex;return se!==0?se:j.id-ie.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;n.unstable_now=function(){return o.now()}}else{var i=Date,a=i.now();n.unstable_now=function(){return i.now()-a}}var l=[],c=[],d=1,p=null,m=3,y=!1,v=!1,b=!1,w=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function N(j){for(var ie=t(c);ie!==null;){if(ie.callback===null)r(c);else if(ie.startTime<=j)r(c),ie.sortIndex=ie.expirationTime,e(l,ie);else break;ie=t(c)}}function T(j){if(b=!1,N(j),!v)if(t(l)!==null)v=!0,le(A);else{var ie=t(c);ie!==null&&de(T,ie.startTime-j)}}function A(j,ie){v=!1,b&&(b=!1,k(B),B=-1),y=!0;var se=m;try{for(N(ie),p=t(l);p!==null&&(!(p.expirationTime>ie)||j&&!_());){var V=p.callback;if(typeof V=="function"){p.callback=null,m=p.priorityLevel;var X=V(p.expirationTime<=ie);ie=n.unstable_now(),typeof X=="function"?p.callback=X:p===t(l)&&r(l),N(ie)}else r(l);p=t(l)}if(p!==null)var xe=!0;else{var Ie=t(c);Ie!==null&&de(T,Ie.startTime-ie),xe=!1}return xe}finally{p=null,m=se,y=!1}}var O=!1,P=null,B=-1,z=5,L=-1;function _(){return!(n.unstable_now()-L<z)}function H(){if(P!==null){var j=n.unstable_now();L=j;var ie=!0;try{ie=P(!0,j)}finally{ie?Y():(O=!1,P=null)}}else O=!1}var Y;if(typeof I=="function")Y=function(){I(H)};else if(typeof MessageChannel<"u"){var re=new MessageChannel,te=re.port2;re.port1.onmessage=H,Y=function(){te.postMessage(null)}}else Y=function(){w(H,0)};function le(j){P=j,O||(O=!0,Y())}function de(j,ie){B=w(function(){j(n.unstable_now())},ie)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(j){j.callback=null},n.unstable_continueExecution=function(){v||y||(v=!0,le(A))},n.unstable_forceFrameRate=function(j){0>j||125<j?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<j?Math.floor(1e3/j):5},n.unstable_getCurrentPriorityLevel=function(){return m},n.unstable_getFirstCallbackNode=function(){return t(l)},n.unstable_next=function(j){switch(m){case 1:case 2:case 3:var ie=3;break;default:ie=m}var se=m;m=ie;try{return j()}finally{m=se}},n.unstable_pauseExecution=function(){},n.unstable_requestPaint=function(){},n.unstable_runWithPriority=function(j,ie){switch(j){case 1:case 2:case 3:case 4:case 5:break;default:j=3}var se=m;m=j;try{return ie()}finally{m=se}},n.unstable_scheduleCallback=function(j,ie,se){var V=n.unstable_now();switch(typeof se=="object"&&se!==null?(se=se.delay,se=typeof se=="number"&&0<se?V+se:V):se=V,j){case 1:var X=-1;break;case 2:X=250;break;case 5:X=1073741823;break;case 4:X=1e4;break;default:X=5e3}return X=se+X,j={id:d++,callback:ie,priorityLevel:j,startTime:se,expirationTime:X,sortIndex:-1},se>V?(j.sortIndex=se,e(c,j),t(l)===null&&j===t(c)&&(b?(k(B),B=-1):b=!0,de(T,se-V))):(j.sortIndex=X,e(l,j),v||y||(v=!0,le(A))),j},n.unstable_shouldYield=_,n.unstable_wrapCallback=function(j){var ie=m;return function(){var se=m;m=ie;try{return j.apply(this,arguments)}finally{m=se}}}})(tb)),tb}var w$;function z3(){return w$||(w$=1,eb.exports=M3()),eb.exports}var b$;function B3(){if(b$)return Gs;b$=1;var n=Xm(),e=z3();function t(u){for(var h="https://reactjs.org/docs/error-decoder.html?invariant="+u,x=1;x<arguments.length;x++)h+="&args[]="+encodeURIComponent(arguments[x]);return"Minified React error #"+u+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function o(u,h){i(u,h),i(u+"Capture",h)}function i(u,h){for(s[u]=h,u=0;u<h.length;u++)r.add(h[u])}var a=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),l=Object.prototype.hasOwnProperty,c=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,d={},p={};function m(u){return l.call(p,u)?!0:l.call(d,u)?!1:c.test(u)?p[u]=!0:(d[u]=!0,!1)}function y(u,h,x,C){if(x!==null&&x.type===0)return!1;switch(typeof h){case"function":case"symbol":return!0;case"boolean":return C?!1:x!==null?!x.acceptsBooleans:(u=u.toLowerCase().slice(0,5),u!=="data-"&&u!=="aria-");default:return!1}}function v(u,h,x,C){if(h===null||typeof h>"u"||y(u,h,x,C))return!0;if(C)return!1;if(x!==null)switch(x.type){case 3:return!h;case 4:return h===!1;case 5:return isNaN(h);case 6:return isNaN(h)||1>h}return!1}function b(u,h,x,C,$,E,F){this.acceptsBooleans=h===2||h===3||h===4,this.attributeName=C,this.attributeNamespace=$,this.mustUseProperty=x,this.propertyName=u,this.type=h,this.sanitizeURL=E,this.removeEmptyString=F}var w={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(u){w[u]=new b(u,0,!1,u,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(u){var h=u[0];w[h]=new b(h,1,!1,u[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(u){w[u]=new b(u,2,!1,u.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(u){w[u]=new b(u,2,!1,u,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(u){w[u]=new b(u,3,!1,u.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(u){w[u]=new b(u,3,!0,u,null,!1,!1)}),["capture","download"].forEach(function(u){w[u]=new b(u,4,!1,u,null,!1,!1)}),["cols","rows","size","span"].forEach(function(u){w[u]=new b(u,6,!1,u,null,!1,!1)}),["rowSpan","start"].forEach(function(u){w[u]=new b(u,5,!1,u.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function I(u){return u[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(u){var h=u.replace(k,I);w[h]=new b(h,1,!1,u,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(u){var h=u.replace(k,I);w[h]=new b(h,1,!1,u,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(u){var h=u.replace(k,I);w[h]=new b(h,1,!1,u,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(u){w[u]=new b(u,1,!1,u.toLowerCase(),null,!1,!1)}),w.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(u){w[u]=new b(u,1,!1,u.toLowerCase(),null,!0,!0)});function N(u,h,x,C){var $=w.hasOwnProperty(h)?w[h]:null;($!==null?$.type!==0:C||!(2<h.length)||h[0]!=="o"&&h[0]!=="O"||h[1]!=="n"&&h[1]!=="N")&&(v(h,x,$,C)&&(x=null),C||$===null?m(h)&&(x===null?u.removeAttribute(h):u.setAttribute(h,""+x)):$.mustUseProperty?u[$.propertyName]=x===null?$.type===3?!1:"":x:(h=$.attributeName,C=$.attributeNamespace,x===null?u.removeAttribute(h):($=$.type,x=$===3||$===4&&x===!0?"":""+x,C?u.setAttributeNS(C,h,x):u.setAttribute(h,x))))}var T=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,A=Symbol.for("react.element"),O=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),L=Symbol.for("react.provider"),_=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),Y=Symbol.for("react.suspense"),re=Symbol.for("react.suspense_list"),te=Symbol.for("react.memo"),le=Symbol.for("react.lazy"),de=Symbol.for("react.offscreen"),j=Symbol.iterator;function ie(u){return u===null||typeof u!="object"?null:(u=j&&u[j]||u["@@iterator"],typeof u=="function"?u:null)}var se=Object.assign,V;function X(u){if(V===void 0)try{throw Error()}catch(x){var h=x.stack.trim().match(/\n( *(at )?)/);V=h&&h[1]||""}return`
`+V+u}var xe=!1;function Ie(u,h){if(!u||xe)return"";xe=!0;var x=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(h)if(h=function(){throw Error()},Object.defineProperty(h.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(h,[])}catch(we){var C=we}Reflect.construct(u,[],h)}else{try{h.call()}catch(we){C=we}u.call(h.prototype)}else{try{throw Error()}catch(we){C=we}u()}}catch(we){if(we&&C&&typeof we.stack=="string"){for(var $=we.stack.split(`
`),E=C.stack.split(`
`),F=$.length-1,G=E.length-1;1<=F&&0<=G&&$[F]!==E[G];)G--;for(;1<=F&&0<=G;F--,G--)if($[F]!==E[G]){if(F!==1||G!==1)do if(F--,G--,0>G||$[F]!==E[G]){var Q=`
`+$[F].replace(" at new "," at ");return u.displayName&&Q.includes("<anonymous>")&&(Q=Q.replace("<anonymous>",u.displayName)),Q}while(1<=F&&0<=G);break}}}finally{xe=!1,Error.prepareStackTrace=x}return(u=u?u.displayName||u.name:"")?X(u):""}function ke(u){switch(u.tag){case 5:return X(u.type);case 16:return X("Lazy");case 13:return X("Suspense");case 19:return X("SuspenseList");case 0:case 2:case 15:return u=Ie(u.type,!1),u;case 11:return u=Ie(u.type.render,!1),u;case 1:return u=Ie(u.type,!0),u;default:return""}}function Ee(u){if(u==null)return null;if(typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u;switch(u){case P:return"Fragment";case O:return"Portal";case z:return"Profiler";case B:return"StrictMode";case Y:return"Suspense";case re:return"SuspenseList"}if(typeof u=="object")switch(u.$$typeof){case _:return(u.displayName||"Context")+".Consumer";case L:return(u._context.displayName||"Context")+".Provider";case H:var h=u.render;return u=u.displayName,u||(u=h.displayName||h.name||"",u=u!==""?"ForwardRef("+u+")":"ForwardRef"),u;case te:return h=u.displayName||null,h!==null?h:Ee(u.type)||"Memo";case le:h=u._payload,u=u._init;try{return Ee(u(h))}catch{}}return null}function Me(u){var h=u.type;switch(u.tag){case 24:return"Cache";case 9:return(h.displayName||"Context")+".Consumer";case 10:return(h._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return u=h.render,u=u.displayName||u.name||"",h.displayName||(u!==""?"ForwardRef("+u+")":"ForwardRef");case 7:return"Fragment";case 5:return h;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ee(h);case 8:return h===B?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof h=="function")return h.displayName||h.name||null;if(typeof h=="string")return h}return null}function ze(u){switch(typeof u){case"boolean":case"number":case"string":case"undefined":return u;case"object":return u;default:return""}}function Be(u){var h=u.type;return(u=u.nodeName)&&u.toLowerCase()==="input"&&(h==="checkbox"||h==="radio")}function Je(u){var h=Be(u)?"checked":"value",x=Object.getOwnPropertyDescriptor(u.constructor.prototype,h),C=""+u[h];if(!u.hasOwnProperty(h)&&typeof x<"u"&&typeof x.get=="function"&&typeof x.set=="function"){var $=x.get,E=x.set;return Object.defineProperty(u,h,{configurable:!0,get:function(){return $.call(this)},set:function(F){C=""+F,E.call(this,F)}}),Object.defineProperty(u,h,{enumerable:x.enumerable}),{getValue:function(){return C},setValue:function(F){C=""+F},stopTracking:function(){u._valueTracker=null,delete u[h]}}}}function lt(u){u._valueTracker||(u._valueTracker=Je(u))}function pt(u){if(!u)return!1;var h=u._valueTracker;if(!h)return!0;var x=h.getValue(),C="";return u&&(C=Be(u)?u.checked?"true":"false":u.value),u=C,u!==x?(h.setValue(u),!0):!1}function bt(u){if(u=u||(typeof document<"u"?document:void 0),typeof u>"u")return null;try{return u.activeElement||u.body}catch{return u.body}}function Rt(u,h){var x=h.checked;return se({},h,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:x??u._wrapperState.initialChecked})}function Ot(u,h){var x=h.defaultValue==null?"":h.defaultValue,C=h.checked!=null?h.checked:h.defaultChecked;x=ze(h.value!=null?h.value:x),u._wrapperState={initialChecked:C,initialValue:x,controlled:h.type==="checkbox"||h.type==="radio"?h.checked!=null:h.value!=null}}function Bt(u,h){h=h.checked,h!=null&&N(u,"checked",h,!1)}function At(u,h){Bt(u,h);var x=ze(h.value),C=h.type;if(x!=null)C==="number"?(x===0&&u.value===""||u.value!=x)&&(u.value=""+x):u.value!==""+x&&(u.value=""+x);else if(C==="submit"||C==="reset"){u.removeAttribute("value");return}h.hasOwnProperty("value")?ds(u,h.type,x):h.hasOwnProperty("defaultValue")&&ds(u,h.type,ze(h.defaultValue)),h.checked==null&&h.defaultChecked!=null&&(u.defaultChecked=!!h.defaultChecked)}function Yt(u,h,x){if(h.hasOwnProperty("value")||h.hasOwnProperty("defaultValue")){var C=h.type;if(!(C!=="submit"&&C!=="reset"||h.value!==void 0&&h.value!==null))return;h=""+u._wrapperState.initialValue,x||h===u.value||(u.value=h),u.defaultValue=h}x=u.name,x!==""&&(u.name=""),u.defaultChecked=!!u._wrapperState.initialChecked,x!==""&&(u.name=x)}function ds(u,h,x){(h!=="number"||bt(u.ownerDocument)!==u)&&(x==null?u.defaultValue=""+u._wrapperState.initialValue:u.defaultValue!==""+x&&(u.defaultValue=""+x))}var Jt=Array.isArray;function cn(u,h,x,C){if(u=u.options,h){h={};for(var $=0;$<x.length;$++)h["$"+x[$]]=!0;for(x=0;x<u.length;x++)$=h.hasOwnProperty("$"+u[x].value),u[x].selected!==$&&(u[x].selected=$),$&&C&&(u[x].defaultSelected=!0)}else{for(x=""+ze(x),h=null,$=0;$<u.length;$++){if(u[$].value===x){u[$].selected=!0,C&&(u[$].defaultSelected=!0);return}h!==null||u[$].disabled||(h=u[$])}h!==null&&(h.selected=!0)}}function Rn(u,h){if(h.dangerouslySetInnerHTML!=null)throw Error(t(91));return se({},h,{value:void 0,defaultValue:void 0,children:""+u._wrapperState.initialValue})}function fs(u,h){var x=h.value;if(x==null){if(x=h.children,h=h.defaultValue,x!=null){if(h!=null)throw Error(t(92));if(Jt(x)){if(1<x.length)throw Error(t(93));x=x[0]}h=x}h==null&&(h=""),x=h}u._wrapperState={initialValue:ze(x)}}function Xr(u,h){var x=ze(h.value),C=ze(h.defaultValue);x!=null&&(x=""+x,x!==u.value&&(u.value=x),h.defaultValue==null&&u.defaultValue!==x&&(u.defaultValue=x)),C!=null&&(u.defaultValue=""+C)}function vr(u){var h=u.textContent;h===u._wrapperState.initialValue&&h!==""&&h!==null&&(u.value=h)}function Zs(u){switch(u){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function wr(u,h){return u==null||u==="http://www.w3.org/1999/xhtml"?Zs(h):u==="http://www.w3.org/2000/svg"&&h==="foreignObject"?"http://www.w3.org/1999/xhtml":u}var Qn,So=(function(u){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(h,x,C,$){MSApp.execUnsafeLocalFunction(function(){return u(h,x,C,$)})}:u})(function(u,h){if(u.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in u)u.innerHTML=h;else{for(Qn=Qn||document.createElement("div"),Qn.innerHTML="<svg>"+h.valueOf().toString()+"</svg>",h=Qn.firstChild;u.firstChild;)u.removeChild(u.firstChild);for(;h.firstChild;)u.appendChild(h.firstChild)}});function eo(u,h){if(h){var x=u.firstChild;if(x&&x===u.lastChild&&x.nodeType===3){x.nodeValue=h;return}}u.textContent=h}var to={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Iu=["Webkit","ms","Moz","O"];Object.keys(to).forEach(function(u){Iu.forEach(function(h){h=h+u.charAt(0).toUpperCase()+u.substring(1),to[h]=to[u]})});function Jo(u,h,x){return h==null||typeof h=="boolean"||h===""?"":x||typeof h!="number"||h===0||to.hasOwnProperty(u)&&to[u]?(""+h).trim():h+"px"}function hl(u,h){u=u.style;for(var x in h)if(h.hasOwnProperty(x)){var C=x.indexOf("--")===0,$=Jo(x,h[x],C);x==="float"&&(x="cssFloat"),C?u.setProperty(x,$):u[x]=$}}var $u=se({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Nu(u,h){if(h){if($u[u]&&(h.children!=null||h.dangerouslySetInnerHTML!=null))throw Error(t(137,u));if(h.dangerouslySetInnerHTML!=null){if(h.children!=null)throw Error(t(60));if(typeof h.dangerouslySetInnerHTML!="object"||!("__html"in h.dangerouslySetInnerHTML))throw Error(t(61))}if(h.style!=null&&typeof h.style!="object")throw Error(t(62))}}function Tu(u,h){if(u.indexOf("-")===-1)return typeof h.is=="string";switch(u){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Mf=null;function zf(u){return u=u.target||u.srcElement||window,u.correspondingUseElement&&(u=u.correspondingUseElement),u.nodeType===3?u.parentNode:u}var Bf=null,Ca=null,Sa=null;function bx(u){if(u=Sr(u)){if(typeof Bf!="function")throw Error(t(280));var h=u.stateNode;h&&(h=qh(h),Bf(u.stateNode,u.type,h))}}function Cx(u){Ca?Sa?Sa.push(u):Sa=[u]:Ca=u}function Sx(){if(Ca){var u=Ca,h=Sa;if(Sa=Ca=null,bx(u),h)for(u=0;u<h.length;u++)bx(h[u])}}function kx(u,h){return u(h)}function Uf(){}var Wf=!1;function Ix(u,h,x){if(Wf)return u(h,x);Wf=!0;try{return kx(u,h,x)}finally{Wf=!1,(Ca!==null||Sa!==null)&&(Uf(),Sx())}}function Eu(u,h){var x=u.stateNode;if(x===null)return null;var C=qh(x);if(C===null)return null;x=C[h];e:switch(h){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(C=!C.disabled)||(u=u.type,C=!(u==="button"||u==="input"||u==="select"||u==="textarea")),u=!C;break e;default:u=!1}if(u)return null;if(x&&typeof x!="function")throw Error(t(231,h,typeof x));return x}var Ru=!1;if(a)try{var Au={};Object.defineProperty(Au,"passive",{get:function(){Ru=!0}}),window.addEventListener("test",Au,Au),window.removeEventListener("test",Au,Au)}catch{Ru=!1}function Vf(u,h,x,C,$,E,F,G,Q){var we=Array.prototype.slice.call(arguments,3);try{h.apply(x,we)}catch(De){this.onError(De)}}var _u=!1,xh=null,yh=!1,Gf=null,qv={onError:function(u){_u=!0,xh=u}};function Kv(u,h,x,C,$,E,F,G,Q){_u=!1,xh=null,Vf.apply(qv,arguments)}function Xv(u,h,x,C,$,E,F,G,Q){if(Kv.apply(this,arguments),_u){if(_u){var we=xh;_u=!1,xh=null}else throw Error(t(198));yh||(yh=!0,Gf=we)}}function ka(u){var h=u,x=u;if(u.alternate)for(;h.return;)h=h.return;else{u=h;do h=u,(h.flags&4098)!==0&&(x=h.return),u=h.return;while(u)}return h.tag===3?x:null}function jf(u){if(u.tag===13){var h=u.memoizedState;if(h===null&&(u=u.alternate,u!==null&&(h=u.memoizedState)),h!==null)return h.dehydrated}return null}function $x(u){if(ka(u)!==u)throw Error(t(188))}function Yv(u){var h=u.alternate;if(!h){if(h=ka(u),h===null)throw Error(t(188));return h!==u?null:u}for(var x=u,C=h;;){var $=x.return;if($===null)break;var E=$.alternate;if(E===null){if(C=$.return,C!==null){x=C;continue}break}if($.child===E.child){for(E=$.child;E;){if(E===x)return $x($),u;if(E===C)return $x($),h;E=E.sibling}throw Error(t(188))}if(x.return!==C.return)x=$,C=E;else{for(var F=!1,G=$.child;G;){if(G===x){F=!0,x=$,C=E;break}if(G===C){F=!0,C=$,x=E;break}G=G.sibling}if(!F){for(G=E.child;G;){if(G===x){F=!0,x=E,C=$;break}if(G===C){F=!0,C=E,x=$;break}G=G.sibling}if(!F)throw Error(t(189))}}if(x.alternate!==C)throw Error(t(190))}if(x.tag!==3)throw Error(t(188));return x.stateNode.current===x?u:h}function Nx(u){return u=Yv(u),u!==null?Tx(u):null}function Tx(u){if(u.tag===5||u.tag===6)return u;for(u=u.child;u!==null;){var h=Tx(u);if(h!==null)return h;u=u.sibling}return null}var Ex=e.unstable_scheduleCallback,Rx=e.unstable_cancelCallback,vh=e.unstable_shouldYield,Qv=e.unstable_requestPaint,xn=e.unstable_now,Jv=e.unstable_getCurrentPriorityLevel,Hf=e.unstable_ImmediatePriority,Ax=e.unstable_UserBlockingPriority,Du=e.unstable_NormalPriority,_x=e.unstable_LowPriority,qf=e.unstable_IdlePriority,wh=null,ko=null;function Zv(u){if(ko&&typeof ko.onCommitFiberRoot=="function")try{ko.onCommitFiberRoot(wh,u,void 0,(u.current.flags&128)===128)}catch{}}var no=Math.clz32?Math.clz32:Fx,Dx=Math.log,Ox=Math.LN2;function Fx(u){return u>>>=0,u===0?32:31-(Dx(u)/Ox|0)|0}var dl=64,bh=4194304;function fl(u){switch(u&-u){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return u&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return u&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return u}}function Ia(u,h){var x=u.pendingLanes;if(x===0)return 0;var C=0,$=u.suspendedLanes,E=u.pingedLanes,F=x&268435455;if(F!==0){var G=F&~$;G!==0?C=fl(G):(E&=F,E!==0&&(C=fl(E)))}else F=x&~$,F!==0?C=fl(F):E!==0&&(C=fl(E));if(C===0)return 0;if(h!==0&&h!==C&&(h&$)===0&&($=C&-C,E=h&-h,$>=E||$===16&&(E&4194240)!==0))return h;if((C&4)!==0&&(C|=x&16),h=u.entangledLanes,h!==0)for(u=u.entanglements,h&=C;0<h;)x=31-no(h),$=1<<x,C|=u[x],h&=~$;return C}function Px(u,h){switch(u){case 1:case 2:case 4:return h+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return h+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ew(u,h){for(var x=u.suspendedLanes,C=u.pingedLanes,$=u.expirationTimes,E=u.pendingLanes;0<E;){var F=31-no(E),G=1<<F,Q=$[F];Q===-1?((G&x)===0||(G&C)!==0)&&($[F]=Px(G,h)):Q<=h&&(u.expiredLanes|=G),E&=~G}}function Ch(u){return u=u.pendingLanes&-1073741825,u!==0?u:u&1073741824?1073741824:0}function Kf(){var u=dl;return dl<<=1,(dl&4194240)===0&&(dl=64),u}function Ou(u){for(var h=[],x=0;31>x;x++)h.push(u);return h}function Fu(u,h,x){u.pendingLanes|=h,h!==536870912&&(u.suspendedLanes=0,u.pingedLanes=0),u=u.eventTimes,h=31-no(h),u[h]=x}function Lx(u,h){var x=u.pendingLanes&~h;u.pendingLanes=h,u.suspendedLanes=0,u.pingedLanes=0,u.expiredLanes&=h,u.mutableReadLanes&=h,u.entangledLanes&=h,h=u.entanglements;var C=u.eventTimes;for(u=u.expirationTimes;0<x;){var $=31-no(x),E=1<<$;h[$]=0,C[$]=-1,u[$]=-1,x&=~E}}function Pu(u,h){var x=u.entangledLanes|=h;for(u=u.entanglements;x;){var C=31-no(x),$=1<<C;$&h|u[C]&h&&(u[C]|=h),x&=~$}}var jt=0;function $a(u){return u&=-u,1<u?4<u?(u&268435455)!==0?16:536870912:4:1}var Xf,Sh,Mx,Yf,Qf,kh=!1,Lu=[],Ri=null,Ai=null,_i=null,pl=new Map,Mu=new Map,Di=[],tw="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function zx(u,h){switch(u){case"focusin":case"focusout":Ri=null;break;case"dragenter":case"dragleave":Ai=null;break;case"mouseover":case"mouseout":_i=null;break;case"pointerover":case"pointerout":pl.delete(h.pointerId);break;case"gotpointercapture":case"lostpointercapture":Mu.delete(h.pointerId)}}function Na(u,h,x,C,$,E){return u===null||u.nativeEvent!==E?(u={blockedOn:h,domEventName:x,eventSystemFlags:C,nativeEvent:E,targetContainers:[$]},h!==null&&(h=Sr(h),h!==null&&Sh(h)),u):(u.eventSystemFlags|=C,h=u.targetContainers,$!==null&&h.indexOf($)===-1&&h.push($),u)}function nw(u,h,x,C,$){switch(h){case"focusin":return Ri=Na(Ri,u,h,x,C,$),!0;case"dragenter":return Ai=Na(Ai,u,h,x,C,$),!0;case"mouseover":return _i=Na(_i,u,h,x,C,$),!0;case"pointerover":var E=$.pointerId;return pl.set(E,Na(pl.get(E)||null,u,h,x,C,$)),!0;case"gotpointercapture":return E=$.pointerId,Mu.set(E,Na(Mu.get(E)||null,u,h,x,C,$)),!0}return!1}function Bx(u){var h=To(u.target);if(h!==null){var x=ka(h);if(x!==null){if(h=x.tag,h===13){if(h=jf(x),h!==null){u.blockedOn=h,Qf(u.priority,function(){Mx(x)});return}}else if(h===3&&x.stateNode.current.memoizedState.isDehydrated){u.blockedOn=x.tag===3?x.stateNode.containerInfo:null;return}}}u.blockedOn=null}function Ih(u){if(u.blockedOn!==null)return!1;for(var h=u.targetContainers;0<h.length;){var x=Th(u.domEventName,u.eventSystemFlags,h[0],u.nativeEvent);if(x===null){x=u.nativeEvent;var C=new x.constructor(x.type,x);Mf=C,x.target.dispatchEvent(C),Mf=null}else return h=Sr(x),h!==null&&Sh(h),u.blockedOn=x,!1;h.shift()}return!0}function Ux(u,h,x){Ih(u)&&x.delete(h)}function rw(){kh=!1,Ri!==null&&Ih(Ri)&&(Ri=null),Ai!==null&&Ih(Ai)&&(Ai=null),_i!==null&&Ih(_i)&&(_i=null),pl.forEach(Ux),Mu.forEach(Ux)}function Qt(u,h){u.blockedOn===h&&(u.blockedOn=null,kh||(kh=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,rw)))}function Ht(u){function h($){return Qt($,u)}if(0<Lu.length){Qt(Lu[0],u);for(var x=1;x<Lu.length;x++){var C=Lu[x];C.blockedOn===u&&(C.blockedOn=null)}}for(Ri!==null&&Qt(Ri,u),Ai!==null&&Qt(Ai,u),_i!==null&&Qt(_i,u),pl.forEach(h),Mu.forEach(h),x=0;x<Di.length;x++)C=Di[x],C.blockedOn===u&&(C.blockedOn=null);for(;0<Di.length&&(x=Di[0],x.blockedOn===null);)Bx(x),x.blockedOn===null&&Di.shift()}var ml=T.ReactCurrentBatchConfig,$h=!0;function sw(u,h,x,C){var $=jt,E=ml.transition;ml.transition=null;try{jt=1,Jf(u,h,x,C)}finally{jt=$,ml.transition=E}}function ow(u,h,x,C){var $=jt,E=ml.transition;ml.transition=null;try{jt=4,Jf(u,h,x,C)}finally{jt=$,ml.transition=E}}function Jf(u,h,x,C){if($h){var $=Th(u,h,x,C);if($===null)mp(u,h,C,Nh,x),zx(u,C);else if(nw($,u,h,x,C))C.stopPropagation();else if(zx(u,C),h&4&&-1<tw.indexOf(u)){for(;$!==null;){var E=Sr($);if(E!==null&&Xf(E),E=Th(u,h,x,C),E===null&&mp(u,h,C,Nh,x),E===$)break;$=E}$!==null&&C.stopPropagation()}else mp(u,h,C,null,x)}}var Nh=null;function Th(u,h,x,C){if(Nh=null,u=zf(C),u=To(u),u!==null)if(h=ka(u),h===null)u=null;else if(x=h.tag,x===13){if(u=jf(h),u!==null)return u;u=null}else if(x===3){if(h.stateNode.current.memoizedState.isDehydrated)return h.tag===3?h.stateNode.containerInfo:null;u=null}else h!==u&&(u=null);return Nh=u,null}function Wx(u){switch(u){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Jv()){case Hf:return 1;case Ax:return 4;case Du:case _x:return 16;case qf:return 536870912;default:return 16}default:return 16}}var yn=null,zu=null,Io=null;function Zf(){if(Io)return Io;var u,h=zu,x=h.length,C,$="value"in yn?yn.value:yn.textContent,E=$.length;for(u=0;u<x&&h[u]===$[u];u++);var F=x-u;for(C=1;C<=F&&h[x-C]===$[E-C];C++);return Io=$.slice(u,1<C?1-C:void 0)}function gl(u){var h=u.keyCode;return"charCode"in u?(u=u.charCode,u===0&&h===13&&(u=13)):u=h,u===10&&(u=13),32<=u||u===13?u:0}function Fr(){return!0}function ep(){return!1}function Yr(u){function h(x,C,$,E,F){this._reactName=x,this._targetInst=$,this.type=C,this.nativeEvent=E,this.target=F,this.currentTarget=null;for(var G in u)u.hasOwnProperty(G)&&(x=u[G],this[G]=x?x(E):E[G]);return this.isDefaultPrevented=(E.defaultPrevented!=null?E.defaultPrevented:E.returnValue===!1)?Fr:ep,this.isPropagationStopped=ep,this}return se(h.prototype,{preventDefault:function(){this.defaultPrevented=!0;var x=this.nativeEvent;x&&(x.preventDefault?x.preventDefault():typeof x.returnValue!="unknown"&&(x.returnValue=!1),this.isDefaultPrevented=Fr)},stopPropagation:function(){var x=this.nativeEvent;x&&(x.stopPropagation?x.stopPropagation():typeof x.cancelBubble!="unknown"&&(x.cancelBubble=!0),this.isPropagationStopped=Fr)},persist:function(){},isPersistent:Fr}),h}var Ta={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(u){return u.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Eh=Yr(Ta),xl=se({},Ta,{view:0,detail:0}),Vx=Yr(xl),Pr,tp,br,Rh=se({},xl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ip,button:0,buttons:0,relatedTarget:function(u){return u.relatedTarget===void 0?u.fromElement===u.srcElement?u.toElement:u.fromElement:u.relatedTarget},movementX:function(u){return"movementX"in u?u.movementX:(u!==br&&(br&&u.type==="mousemove"?(Pr=u.screenX-br.screenX,tp=u.screenY-br.screenY):tp=Pr=0,br=u),Pr)},movementY:function(u){return"movementY"in u?u.movementY:tp}}),np=Yr(Rh),Oi=se({},Rh,{dataTransfer:0}),Ah=Yr(Oi),rp=se({},xl,{relatedTarget:0}),an=Yr(rp),Fi=se({},Ta,{animationName:0,elapsedTime:0,pseudoElement:0}),sp=Yr(Fi),iw=se({},Ta,{clipboardData:function(u){return"clipboardData"in u?u.clipboardData:window.clipboardData}}),op=Yr(iw),aw=se({},Ta,{data:0}),Gx=Yr(aw),lw={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},jx={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},_h={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function yl(u){var h=this.nativeEvent;return h.getModifierState?h.getModifierState(u):(u=_h[u])?!!h[u]:!1}function ip(){return yl}var Hx=se({},xl,{key:function(u){if(u.key){var h=lw[u.key]||u.key;if(h!=="Unidentified")return h}return u.type==="keypress"?(u=gl(u),u===13?"Enter":String.fromCharCode(u)):u.type==="keydown"||u.type==="keyup"?jx[u.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ip,charCode:function(u){return u.type==="keypress"?gl(u):0},keyCode:function(u){return u.type==="keydown"||u.type==="keyup"?u.keyCode:0},which:function(u){return u.type==="keypress"?gl(u):u.type==="keydown"||u.type==="keyup"?u.keyCode:0}}),qx=Yr(Hx),ap=se({},Rh,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Dh=Yr(ap),Kx=se({},xl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ip}),uw=Yr(Kx),lp=se({},Ta,{propertyName:0,elapsedTime:0,pseudoElement:0}),up=Yr(lp),cw=se({},Rh,{deltaX:function(u){return"deltaX"in u?u.deltaX:"wheelDeltaX"in u?-u.wheelDeltaX:0},deltaY:function(u){return"deltaY"in u?u.deltaY:"wheelDeltaY"in u?-u.wheelDeltaY:"wheelDelta"in u?-u.wheelDelta:0},deltaZ:0,deltaMode:0}),Xx=Yr(cw),ps=[9,13,27,32],Bu=a&&"CompositionEvent"in window,Zo=null;a&&"documentMode"in document&&(Zo=document.documentMode);var Yx=a&&"TextEvent"in window&&!Zo,cp=a&&(!Bu||Zo&&8<Zo&&11>=Zo),Qx=" ",Jx=!1;function Zx(u,h){switch(u){case"keyup":return ps.indexOf(h.keyCode)!==-1;case"keydown":return h.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function e0(u){return u=u.detail,typeof u=="object"&&"data"in u?u.data:null}var vl=!1;function wl(u,h){switch(u){case"compositionend":return e0(h);case"keypress":return h.which!==32?null:(Jx=!0,Qx);case"textInput":return u=h.data,u===Qx&&Jx?null:u;default:return null}}function hw(u,h){if(vl)return u==="compositionend"||!Bu&&Zx(u,h)?(u=Zf(),Io=zu=yn=null,vl=!1,u):null;switch(u){case"paste":return null;case"keypress":if(!(h.ctrlKey||h.altKey||h.metaKey)||h.ctrlKey&&h.altKey){if(h.char&&1<h.char.length)return h.char;if(h.which)return String.fromCharCode(h.which)}return null;case"compositionend":return cp&&h.locale!=="ko"?null:h.data;default:return null}}var dw={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Oh(u){var h=u&&u.nodeName&&u.nodeName.toLowerCase();return h==="input"?!!dw[u.type]:h==="textarea"}function hp(u,h,x,C){Cx(C),h=Vh(h,"onChange"),0<h.length&&(x=new Eh("onChange","change",null,x,C),u.push({event:x,listeners:h}))}var Es=null,Pi=null;function fw(u){a0(u,0)}function Fh(u){var h=xt(u);if(pt(h))return u}function pw(u,h){if(u==="change")return h}var Ea=!1;if(a){var ms;if(a){var Ph="oninput"in document;if(!Ph){var t0=document.createElement("div");t0.setAttribute("oninput","return;"),Ph=typeof t0.oninput=="function"}ms=Ph}else ms=!1;Ea=ms&&(!document.documentMode||9<document.documentMode)}function n0(){Es&&(Es.detachEvent("onpropertychange",r0),Pi=Es=null)}function r0(u){if(u.propertyName==="value"&&Fh(Pi)){var h=[];hp(h,Pi,u,zf(u)),Ix(fw,h)}}function mw(u,h,x){u==="focusin"?(n0(),Es=h,Pi=x,Es.attachEvent("onpropertychange",r0)):u==="focusout"&&n0()}function gw(u){if(u==="selectionchange"||u==="keyup"||u==="keydown")return Fh(Pi)}function bl(u,h){if(u==="click")return Fh(h)}function ue(u,h){if(u==="input"||u==="change")return Fh(h)}function $e(u,h){return u===h&&(u!==0||1/u===1/h)||u!==u&&h!==h}var ve=typeof Object.is=="function"?Object.is:$e;function je(u,h){if(ve(u,h))return!0;if(typeof u!="object"||u===null||typeof h!="object"||h===null)return!1;var x=Object.keys(u),C=Object.keys(h);if(x.length!==C.length)return!1;for(C=0;C<x.length;C++){var $=x[C];if(!l.call(h,$)||!ve(u[$],h[$]))return!1}return!0}function mt(u){for(;u&&u.firstChild;)u=u.firstChild;return u}function Ut(u,h){var x=mt(u);u=0;for(var C;x;){if(x.nodeType===3){if(C=u+x.textContent.length,u<=h&&C>=h)return{node:x,offset:h-u};u=C}e:{for(;x;){if(x.nextSibling){x=x.nextSibling;break e}x=x.parentNode}x=void 0}x=mt(x)}}function On(u,h){return u&&h?u===h?!0:u&&u.nodeType===3?!1:h&&h.nodeType===3?On(u,h.parentNode):"contains"in u?u.contains(h):u.compareDocumentPosition?!!(u.compareDocumentPosition(h)&16):!1:!1}function Zt(){for(var u=window,h=bt();h instanceof u.HTMLIFrameElement;){try{var x=typeof h.contentWindow.location.href=="string"}catch{x=!1}if(x)u=h.contentWindow;else break;h=bt(u.document)}return h}function Uu(u){var h=u&&u.nodeName&&u.nodeName.toLowerCase();return h&&(h==="input"&&(u.type==="text"||u.type==="search"||u.type==="tel"||u.type==="url"||u.type==="password")||h==="textarea"||u.contentEditable==="true")}function xw(u){var h=Zt(),x=u.focusedElem,C=u.selectionRange;if(h!==x&&x&&x.ownerDocument&&On(x.ownerDocument.documentElement,x)){if(C!==null&&Uu(x)){if(h=C.start,u=C.end,u===void 0&&(u=h),"selectionStart"in x)x.selectionStart=h,x.selectionEnd=Math.min(u,x.value.length);else if(u=(h=x.ownerDocument||document)&&h.defaultView||window,u.getSelection){u=u.getSelection();var $=x.textContent.length,E=Math.min(C.start,$);C=C.end===void 0?E:Math.min(C.end,$),!u.extend&&E>C&&($=C,C=E,E=$),$=Ut(x,E);var F=Ut(x,C);$&&F&&(u.rangeCount!==1||u.anchorNode!==$.node||u.anchorOffset!==$.offset||u.focusNode!==F.node||u.focusOffset!==F.offset)&&(h=h.createRange(),h.setStart($.node,$.offset),u.removeAllRanges(),E>C?(u.addRange(h),u.extend(F.node,F.offset)):(h.setEnd(F.node,F.offset),u.addRange(h)))}}for(h=[],u=x;u=u.parentNode;)u.nodeType===1&&h.push({element:u,left:u.scrollLeft,top:u.scrollTop});for(typeof x.focus=="function"&&x.focus(),x=0;x<h.length;x++)u=h[x],u.element.scrollLeft=u.left,u.element.scrollTop=u.top}}var Rs=a&&"documentMode"in document&&11>=document.documentMode,ei=null,dp=null,$o=null,Cl=!1;function Wu(u,h,x){var C=x.window===x?x.document:x.nodeType===9?x:x.ownerDocument;Cl||ei==null||ei!==bt(C)||(C=ei,"selectionStart"in C&&Uu(C)?C={start:C.selectionStart,end:C.selectionEnd}:(C=(C.ownerDocument&&C.ownerDocument.defaultView||window).getSelection(),C={anchorNode:C.anchorNode,anchorOffset:C.anchorOffset,focusNode:C.focusNode,focusOffset:C.focusOffset}),$o&&je($o,C)||($o=C,C=Vh(dp,"onSelect"),0<C.length&&(h=new Eh("onSelect","select",null,h,x),u.push({event:h,listeners:C}),h.target=ei)))}function Wt(u,h){var x={};return x[u.toLowerCase()]=h.toLowerCase(),x["Webkit"+u]="webkit"+h,x["Moz"+u]="moz"+h,x}var Sl={animationend:Wt("Animation","AnimationEnd"),animationiteration:Wt("Animation","AnimationIteration"),animationstart:Wt("Animation","AnimationStart"),transitionend:Wt("Transition","TransitionEnd")},Lh={},Vu={};a&&(Vu=document.createElement("div").style,"AnimationEvent"in window||(delete Sl.animationend.animation,delete Sl.animationiteration.animation,delete Sl.animationstart.animation),"TransitionEvent"in window||delete Sl.transitionend.transition);function Mh(u){if(Lh[u])return Lh[u];if(!Sl[u])return u;var h=Sl[u],x;for(x in h)if(h.hasOwnProperty(x)&&x in Vu)return Lh[u]=h[x];return u}var s0=Mh("animationend"),o0=Mh("animationiteration"),Gu=Mh("animationstart"),ti=Mh("transitionend"),ju=new Map,fp="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function ro(u,h){ju.set(u,h),o(h,[u])}for(var zh=0;zh<fp.length;zh++){var Bh=fp[zh],Uh=Bh.toLowerCase(),i0=Bh[0].toUpperCase()+Bh.slice(1);ro(Uh,"on"+i0)}ro(s0,"onAnimationEnd"),ro(o0,"onAnimationIteration"),ro(Gu,"onAnimationStart"),ro("dblclick","onDoubleClick"),ro("focusin","onFocus"),ro("focusout","onBlur"),ro(ti,"onTransitionEnd"),i("onMouseEnter",["mouseout","mouseover"]),i("onMouseLeave",["mouseout","mouseover"]),i("onPointerEnter",["pointerout","pointerover"]),i("onPointerLeave",["pointerout","pointerover"]),o("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),o("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),o("onBeforeInput",["compositionend","keypress","textInput","paste"]),o("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ni="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Ra=new Set("cancel close invalid load scroll toggle".split(" ").concat(ni));function Hu(u,h,x){var C=u.type||"unknown-event";u.currentTarget=x,Xv(C,h,void 0,u),u.currentTarget=null}function a0(u,h){h=(h&4)!==0;for(var x=0;x<u.length;x++){var C=u[x],$=C.event;C=C.listeners;e:{var E=void 0;if(h)for(var F=C.length-1;0<=F;F--){var G=C[F],Q=G.instance,we=G.currentTarget;if(G=G.listener,Q!==E&&$.isPropagationStopped())break e;Hu($,G,we),E=Q}else for(F=0;F<C.length;F++){if(G=C[F],Q=G.instance,we=G.currentTarget,G=G.listener,Q!==E&&$.isPropagationStopped())break e;Hu($,G,we),E=Q}}}if(yh)throw u=Gf,yh=!1,Gf=null,u}function hn(u,h){var x=h[Hh];x===void 0&&(x=h[Hh]=new Set);var C=u+"__bubble";x.has(C)||(Wh(h,u,2,!1),x.add(C))}function pp(u,h,x){var C=0;h&&(C|=4),Wh(x,u,C,h)}var Aa="_reactListening"+Math.random().toString(36).slice(2);function Li(u){if(!u[Aa]){u[Aa]=!0,r.forEach(function(x){x!=="selectionchange"&&(Ra.has(x)||pp(x,!1,u),pp(x,!0,u))});var h=u.nodeType===9?u:u.ownerDocument;h===null||h[Aa]||(h[Aa]=!0,pp("selectionchange",!1,h))}}function Wh(u,h,x,C){switch(Wx(h)){case 1:var $=sw;break;case 4:$=ow;break;default:$=Jf}x=$.bind(null,h,x,u),$=void 0,!Ru||h!=="touchstart"&&h!=="touchmove"&&h!=="wheel"||($=!0),C?$!==void 0?u.addEventListener(h,x,{capture:!0,passive:$}):u.addEventListener(h,x,!0):$!==void 0?u.addEventListener(h,x,{passive:$}):u.addEventListener(h,x,!1)}function mp(u,h,x,C,$){var E=C;if((h&1)===0&&(h&2)===0&&C!==null)e:for(;;){if(C===null)return;var F=C.tag;if(F===3||F===4){var G=C.stateNode.containerInfo;if(G===$||G.nodeType===8&&G.parentNode===$)break;if(F===4)for(F=C.return;F!==null;){var Q=F.tag;if((Q===3||Q===4)&&(Q=F.stateNode.containerInfo,Q===$||Q.nodeType===8&&Q.parentNode===$))return;F=F.return}for(;G!==null;){if(F=To(G),F===null)return;if(Q=F.tag,Q===5||Q===6){C=E=F;continue e}G=G.parentNode}}C=C.return}Ix(function(){var we=E,De=zf(x),Fe=[];e:{var Ae=ju.get(u);if(Ae!==void 0){var He=Eh,Ke=u;switch(u){case"keypress":if(gl(x)===0)break e;case"keydown":case"keyup":He=qx;break;case"focusin":Ke="focus",He=an;break;case"focusout":Ke="blur",He=an;break;case"beforeblur":case"afterblur":He=an;break;case"click":if(x.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":He=np;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":He=Ah;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":He=uw;break;case s0:case o0:case Gu:He=sp;break;case ti:He=up;break;case"scroll":He=Vx;break;case"wheel":He=Xx;break;case"copy":case"cut":case"paste":He=op;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":He=Dh}var Xe=(h&4)!==0,_n=!Xe&&u==="scroll",pe=Xe?Ae!==null?Ae+"Capture":null:Ae;Xe=[];for(var oe=we,ge;oe!==null;){ge=oe;var Le=ge.stateNode;if(ge.tag===5&&Le!==null&&(ge=Le,pe!==null&&(Le=Eu(oe,pe),Le!=null&&Xe.push(kl(oe,Le,ge)))),_n)break;oe=oe.return}0<Xe.length&&(Ae=new He(Ae,Ke,null,x,De),Fe.push({event:Ae,listeners:Xe}))}}if((h&7)===0){e:{if(Ae=u==="mouseover"||u==="pointerover",He=u==="mouseout"||u==="pointerout",Ae&&x!==Mf&&(Ke=x.relatedTarget||x.fromElement)&&(To(Ke)||Ke[gs]))break e;if((He||Ae)&&(Ae=De.window===De?De:(Ae=De.ownerDocument)?Ae.defaultView||Ae.parentWindow:window,He?(Ke=x.relatedTarget||x.toElement,He=we,Ke=Ke?To(Ke):null,Ke!==null&&(_n=ka(Ke),Ke!==_n||Ke.tag!==5&&Ke.tag!==6)&&(Ke=null)):(He=null,Ke=we),He!==Ke)){if(Xe=np,Le="onMouseLeave",pe="onMouseEnter",oe="mouse",(u==="pointerout"||u==="pointerover")&&(Xe=Dh,Le="onPointerLeave",pe="onPointerEnter",oe="pointer"),_n=He==null?Ae:xt(He),ge=Ke==null?Ae:xt(Ke),Ae=new Xe(Le,oe+"leave",He,x,De),Ae.target=_n,Ae.relatedTarget=ge,Le=null,To(De)===we&&(Xe=new Xe(pe,oe+"enter",Ke,x,De),Xe.target=ge,Xe.relatedTarget=_n,Le=Xe),_n=Le,He&&Ke)t:{for(Xe=He,pe=Ke,oe=0,ge=Xe;ge;ge=Il(ge))oe++;for(ge=0,Le=pe;Le;Le=Il(Le))ge++;for(;0<oe-ge;)Xe=Il(Xe),oe--;for(;0<ge-oe;)pe=Il(pe),ge--;for(;oe--;){if(Xe===pe||pe!==null&&Xe===pe.alternate)break t;Xe=Il(Xe),pe=Il(pe)}Xe=null}else Xe=null;He!==null&&Fn(Fe,Ae,He,Xe,!1),Ke!==null&&_n!==null&&Fn(Fe,_n,Ke,Xe,!0)}}e:{if(Ae=we?xt(we):window,He=Ae.nodeName&&Ae.nodeName.toLowerCase(),He==="select"||He==="input"&&Ae.type==="file")var Ze=pw;else if(Oh(Ae))if(Ea)Ze=ue;else{Ze=gw;var ot=mw}else(He=Ae.nodeName)&&He.toLowerCase()==="input"&&(Ae.type==="checkbox"||Ae.type==="radio")&&(Ze=bl);if(Ze&&(Ze=Ze(u,we))){hp(Fe,Ze,x,De);break e}ot&&ot(u,Ae,we),u==="focusout"&&(ot=Ae._wrapperState)&&ot.controlled&&Ae.type==="number"&&ds(Ae,"number",Ae.value)}switch(ot=we?xt(we):window,u){case"focusin":(Oh(ot)||ot.contentEditable==="true")&&(ei=ot,dp=we,$o=null);break;case"focusout":$o=dp=ei=null;break;case"mousedown":Cl=!0;break;case"contextmenu":case"mouseup":case"dragend":Cl=!1,Wu(Fe,x,De);break;case"selectionchange":if(Rs)break;case"keydown":case"keyup":Wu(Fe,x,De)}var nt;if(Bu)e:{switch(u){case"compositionstart":var ct="onCompositionStart";break e;case"compositionend":ct="onCompositionEnd";break e;case"compositionupdate":ct="onCompositionUpdate";break e}ct=void 0}else vl?Zx(u,x)&&(ct="onCompositionEnd"):u==="keydown"&&x.keyCode===229&&(ct="onCompositionStart");ct&&(cp&&x.locale!=="ko"&&(vl||ct!=="onCompositionStart"?ct==="onCompositionEnd"&&vl&&(nt=Zf()):(yn=De,zu="value"in yn?yn.value:yn.textContent,vl=!0)),ot=Vh(we,ct),0<ot.length&&(ct=new Gx(ct,u,null,x,De),Fe.push({event:ct,listeners:ot}),nt?ct.data=nt:(nt=e0(x),nt!==null&&(ct.data=nt)))),(nt=Yx?wl(u,x):hw(u,x))&&(we=Vh(we,"onBeforeInput"),0<we.length&&(De=new Gx("onBeforeInput","beforeinput",null,x,De),Fe.push({event:De,listeners:we}),De.data=nt))}a0(Fe,h)})}function kl(u,h,x){return{instance:u,listener:h,currentTarget:x}}function Vh(u,h){for(var x=h+"Capture",C=[];u!==null;){var $=u,E=$.stateNode;$.tag===5&&E!==null&&($=E,E=Eu(u,x),E!=null&&C.unshift(kl(u,E,$)),E=Eu(u,h),E!=null&&C.push(kl(u,E,$))),u=u.return}return C}function Il(u){if(u===null)return null;do u=u.return;while(u&&u.tag!==5);return u||null}function Fn(u,h,x,C,$){for(var E=h._reactName,F=[];x!==null&&x!==C;){var G=x,Q=G.alternate,we=G.stateNode;if(Q!==null&&Q===C)break;G.tag===5&&we!==null&&(G=we,$?(Q=Eu(x,E),Q!=null&&F.unshift(kl(x,Q,G))):$||(Q=Eu(x,E),Q!=null&&F.push(kl(x,Q,G)))),x=x.return}F.length!==0&&u.push({event:h,listeners:F})}var Cr=/\r\n?/g,yw=/\u0000|\uFFFD/g;function l0(u){return(typeof u=="string"?u:""+u).replace(Cr,`
`).replace(yw,"")}function qu(u,h,x){if(h=l0(h),l0(u)!==h&&x)throw Error(t(425))}function Gh(){}var Ku=null,_a=null;function Xu(u,h){return u==="textarea"||u==="noscript"||typeof h.children=="string"||typeof h.children=="number"||typeof h.dangerouslySetInnerHTML=="object"&&h.dangerouslySetInnerHTML!==null&&h.dangerouslySetInnerHTML.__html!=null}var Mi=typeof setTimeout=="function"?setTimeout:void 0,Yu=typeof clearTimeout=="function"?clearTimeout:void 0,$l=typeof Promise=="function"?Promise:void 0,jh=typeof queueMicrotask=="function"?queueMicrotask:typeof $l<"u"?function(u){return $l.resolve(null).then(u).catch(Nl)}:Mi;function Nl(u){setTimeout(function(){throw u})}function gp(u,h){var x=h,C=0;do{var $=x.nextSibling;if(u.removeChild(x),$&&$.nodeType===8)if(x=$.data,x==="/$"){if(C===0){u.removeChild($),Ht(h);return}C--}else x!=="$"&&x!=="$?"&&x!=="$!"||C++;x=$}while(x);Ht(h)}function zi(u){for(;u!=null;u=u.nextSibling){var h=u.nodeType;if(h===1||h===3)break;if(h===8){if(h=u.data,h==="$"||h==="$!"||h==="$?")break;if(h==="/$")return null}}return u}function u0(u){u=u.previousSibling;for(var h=0;u;){if(u.nodeType===8){var x=u.data;if(x==="$"||x==="$!"||x==="$?"){if(h===0)return u;h--}else x==="/$"&&h++}u=u.previousSibling}return null}var Tl=Math.random().toString(36).slice(2),No="__reactFiber$"+Tl,Bi="__reactProps$"+Tl,gs="__reactContainer$"+Tl,Hh="__reactEvents$"+Tl,M="__reactListeners$"+Tl,El="__reactHandles$"+Tl;function To(u){var h=u[No];if(h)return h;for(var x=u.parentNode;x;){if(h=x[gs]||x[No]){if(x=h.alternate,h.child!==null||x!==null&&x.child!==null)for(u=u0(u);u!==null;){if(x=u[No])return x;u=u0(u)}return h}u=x,x=u.parentNode}return null}function Sr(u){return u=u[No]||u[gs],!u||u.tag!==5&&u.tag!==6&&u.tag!==13&&u.tag!==3?null:u}function xt(u){if(u.tag===5||u.tag===6)return u.stateNode;throw Error(t(33))}function qh(u){return u[Bi]||null}var xp=[],Rl=-1;function Qr(u){return{current:u}}function dn(u){0>Rl||(u.current=xp[Rl],xp[Rl]=null,Rl--)}function ln(u,h){Rl++,xp[Rl]=u.current,u.current=h}var Ui={},kr=Qr(Ui),Jr=Qr(!1),Lr=Ui;function Al(u,h){var x=u.type.contextTypes;if(!x)return Ui;var C=u.stateNode;if(C&&C.__reactInternalMemoizedUnmaskedChildContext===h)return C.__reactInternalMemoizedMaskedChildContext;var $={},E;for(E in x)$[E]=h[E];return C&&(u=u.stateNode,u.__reactInternalMemoizedUnmaskedChildContext=h,u.__reactInternalMemoizedMaskedChildContext=$),$}function Zr(u){return u=u.childContextTypes,u!=null}function Kh(){dn(Jr),dn(kr)}function c0(u,h,x){if(kr.current!==Ui)throw Error(t(168));ln(kr,h),ln(Jr,x)}function h0(u,h,x){var C=u.stateNode;if(h=h.childContextTypes,typeof C.getChildContext!="function")return x;C=C.getChildContext();for(var $ in C)if(!($ in h))throw Error(t(108,Me(u)||"Unknown",$));return se({},x,C)}function As(u){return u=(u=u.stateNode)&&u.__reactInternalMemoizedMergedChildContext||Ui,Lr=kr.current,ln(kr,u),ln(Jr,Jr.current),!0}function d0(u,h,x){var C=u.stateNode;if(!C)throw Error(t(169));x?(u=h0(u,h,Lr),C.__reactInternalMemoizedMergedChildContext=u,dn(Jr),dn(kr),ln(kr,u)):dn(Jr),ln(Jr,x)}var ri=null,Xh=!1,yp=!1;function f0(u){ri===null?ri=[u]:ri.push(u)}function Da(u){Xh=!0,f0(u)}function Wi(){if(!yp&&ri!==null){yp=!0;var u=0,h=jt;try{var x=ri;for(jt=1;u<x.length;u++){var C=x[u];do C=C(!0);while(C!==null)}ri=null,Xh=!1}catch($){throw ri!==null&&(ri=ri.slice(u+1)),Ex(Hf,Wi),$}finally{jt=h,yp=!1}}return null}var _l=[],Ir=0,Yh=null,Qh=0,_s=[],Ds=0,Oa=null,Eo=1,Ro="";function Fa(u,h){_l[Ir++]=Qh,_l[Ir++]=Yh,Yh=u,Qh=h}function p0(u,h,x){_s[Ds++]=Eo,_s[Ds++]=Ro,_s[Ds++]=Oa,Oa=u;var C=Eo;u=Ro;var $=32-no(C)-1;C&=~(1<<$),x+=1;var E=32-no(h)+$;if(30<E){var F=$-$%5;E=(C&(1<<F)-1).toString(32),C>>=F,$-=F,Eo=1<<32-no(h)+$|x<<$|C,Ro=E+u}else Eo=1<<E|x<<$|C,Ro=u}function Qu(u){u.return!==null&&(Fa(u,1),p0(u,1,0))}function Pa(u){for(;u===Yh;)Yh=_l[--Ir],_l[Ir]=null,Qh=_l[--Ir],_l[Ir]=null;for(;u===Oa;)Oa=_s[--Ds],_s[Ds]=null,Ro=_s[--Ds],_s[Ds]=null,Eo=_s[--Ds],_s[Ds]=null}var $r=null,xs=null,fn=!1,so=null;function Ao(u,h){var x=Bs(5,null,null,0);x.elementType="DELETED",x.stateNode=h,x.return=u,h=u.deletions,h===null?(u.deletions=[x],u.flags|=16):h.push(x)}function Jh(u,h){switch(u.tag){case 5:var x=u.type;return h=h.nodeType!==1||x.toLowerCase()!==h.nodeName.toLowerCase()?null:h,h!==null?(u.stateNode=h,$r=u,xs=zi(h.firstChild),!0):!1;case 6:return h=u.pendingProps===""||h.nodeType!==3?null:h,h!==null?(u.stateNode=h,$r=u,xs=null,!0):!1;case 13:return h=h.nodeType!==8?null:h,h!==null?(x=Oa!==null?{id:Eo,overflow:Ro}:null,u.memoizedState={dehydrated:h,treeContext:x,retryLane:1073741824},x=Bs(18,null,null,0),x.stateNode=h,x.return=u,u.child=x,$r=u,xs=null,!0):!1;default:return!1}}function si(u){return(u.mode&1)!==0&&(u.flags&128)===0}function es(u){if(fn){var h=xs;if(h){var x=h;if(!Jh(u,h)){if(si(u))throw Error(t(418));h=zi(x.nextSibling);var C=$r;h&&Jh(u,h)?Ao(C,x):(u.flags=u.flags&-4097|2,fn=!1,$r=u)}}else{if(si(u))throw Error(t(418));u.flags=u.flags&-4097|2,fn=!1,$r=u}}}function m0(u){for(u=u.return;u!==null&&u.tag!==5&&u.tag!==3&&u.tag!==13;)u=u.return;$r=u}function Ju(u){if(u!==$r)return!1;if(!fn)return m0(u),fn=!0,!1;var h;if((h=u.tag!==3)&&!(h=u.tag!==5)&&(h=u.type,h=h!=="head"&&h!=="body"&&!Xu(u.type,u.memoizedProps)),h&&(h=xs)){if(si(u))throw vp(),Error(t(418));for(;h;)Ao(u,h),h=zi(h.nextSibling)}if(m0(u),u.tag===13){if(u=u.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(t(317));e:{for(u=u.nextSibling,h=0;u;){if(u.nodeType===8){var x=u.data;if(x==="/$"){if(h===0){xs=zi(u.nextSibling);break e}h--}else x!=="$"&&x!=="$!"&&x!=="$?"||h++}u=u.nextSibling}xs=null}}else xs=$r?zi(u.stateNode.nextSibling):null;return!0}function vp(){for(var u=xs;u;)u=zi(u.nextSibling)}function _o(){xs=$r=null,fn=!1}function Do(u){so===null?so=[u]:so.push(u)}var g0=T.ReactCurrentBatchConfig;function Zu(u,h,x){if(u=x.ref,u!==null&&typeof u!="function"&&typeof u!="object"){if(x._owner){if(x=x._owner,x){if(x.tag!==1)throw Error(t(309));var C=x.stateNode}if(!C)throw Error(t(147,u));var $=C,E=""+u;return h!==null&&h.ref!==null&&typeof h.ref=="function"&&h.ref._stringRef===E?h.ref:(h=function(F){var G=$.refs;F===null?delete G[E]:G[E]=F},h._stringRef=E,h)}if(typeof u!="string")throw Error(t(284));if(!x._owner)throw Error(t(290,u))}return u}function La(u,h){throw u=Object.prototype.toString.call(h),Error(t(31,u==="[object Object]"?"object with keys {"+Object.keys(h).join(", ")+"}":u))}function x0(u){var h=u._init;return h(u._payload)}function wp(u){function h(pe,oe){if(u){var ge=pe.deletions;ge===null?(pe.deletions=[oe],pe.flags|=16):ge.push(oe)}}function x(pe,oe){if(!u)return null;for(;oe!==null;)h(pe,oe),oe=oe.sibling;return null}function C(pe,oe){for(pe=new Map;oe!==null;)oe.key!==null?pe.set(oe.key,oe):pe.set(oe.index,oe),oe=oe.sibling;return pe}function $(pe,oe){return pe=ho(pe,oe),pe.index=0,pe.sibling=null,pe}function E(pe,oe,ge){return pe.index=ge,u?(ge=pe.alternate,ge!==null?(ge=ge.index,ge<oe?(pe.flags|=2,oe):ge):(pe.flags|=2,oe)):(pe.flags|=1048576,oe)}function F(pe){return u&&pe.alternate===null&&(pe.flags|=2),pe}function G(pe,oe,ge,Le){return oe===null||oe.tag!==6?(oe=im(ge,pe.mode,Le),oe.return=pe,oe):(oe=$(oe,ge),oe.return=pe,oe)}function Q(pe,oe,ge,Le){var Ze=ge.type;return Ze===P?De(pe,oe,ge.props.children,Le,ge.key):oe!==null&&(oe.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===le&&x0(Ze)===oe.type)?(Le=$(oe,ge.props),Le.ref=Zu(pe,oe,ge),Le.return=pe,Le):(Le=Dd(ge.type,ge.key,ge.props,null,pe.mode,Le),Le.ref=Zu(pe,oe,ge),Le.return=pe,Le)}function we(pe,oe,ge,Le){return oe===null||oe.tag!==4||oe.stateNode.containerInfo!==ge.containerInfo||oe.stateNode.implementation!==ge.implementation?(oe=am(ge,pe.mode,Le),oe.return=pe,oe):(oe=$(oe,ge.children||[]),oe.return=pe,oe)}function De(pe,oe,ge,Le,Ze){return oe===null||oe.tag!==7?(oe=Ka(ge,pe.mode,Le,Ze),oe.return=pe,oe):(oe=$(oe,ge),oe.return=pe,oe)}function Fe(pe,oe,ge){if(typeof oe=="string"&&oe!==""||typeof oe=="number")return oe=im(""+oe,pe.mode,ge),oe.return=pe,oe;if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case A:return ge=Dd(oe.type,oe.key,oe.props,null,pe.mode,ge),ge.ref=Zu(pe,null,oe),ge.return=pe,ge;case O:return oe=am(oe,pe.mode,ge),oe.return=pe,oe;case le:var Le=oe._init;return Fe(pe,Le(oe._payload),ge)}if(Jt(oe)||ie(oe))return oe=Ka(oe,pe.mode,ge,null),oe.return=pe,oe;La(pe,oe)}return null}function Ae(pe,oe,ge,Le){var Ze=oe!==null?oe.key:null;if(typeof ge=="string"&&ge!==""||typeof ge=="number")return Ze!==null?null:G(pe,oe,""+ge,Le);if(typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case A:return ge.key===Ze?Q(pe,oe,ge,Le):null;case O:return ge.key===Ze?we(pe,oe,ge,Le):null;case le:return Ze=ge._init,Ae(pe,oe,Ze(ge._payload),Le)}if(Jt(ge)||ie(ge))return Ze!==null?null:De(pe,oe,ge,Le,null);La(pe,ge)}return null}function He(pe,oe,ge,Le,Ze){if(typeof Le=="string"&&Le!==""||typeof Le=="number")return pe=pe.get(ge)||null,G(oe,pe,""+Le,Ze);if(typeof Le=="object"&&Le!==null){switch(Le.$$typeof){case A:return pe=pe.get(Le.key===null?ge:Le.key)||null,Q(oe,pe,Le,Ze);case O:return pe=pe.get(Le.key===null?ge:Le.key)||null,we(oe,pe,Le,Ze);case le:var ot=Le._init;return He(pe,oe,ge,ot(Le._payload),Ze)}if(Jt(Le)||ie(Le))return pe=pe.get(ge)||null,De(oe,pe,Le,Ze,null);La(oe,Le)}return null}function Ke(pe,oe,ge,Le){for(var Ze=null,ot=null,nt=oe,ct=oe=0,er=null;nt!==null&&ct<ge.length;ct++){nt.index>ct?(er=nt,nt=null):er=nt.sibling;var Vt=Ae(pe,nt,ge[ct],Le);if(Vt===null){nt===null&&(nt=er);break}u&&nt&&Vt.alternate===null&&h(pe,nt),oe=E(Vt,oe,ct),ot===null?Ze=Vt:ot.sibling=Vt,ot=Vt,nt=er}if(ct===ge.length)return x(pe,nt),fn&&Fa(pe,ct),Ze;if(nt===null){for(;ct<ge.length;ct++)nt=Fe(pe,ge[ct],Le),nt!==null&&(oe=E(nt,oe,ct),ot===null?Ze=nt:ot.sibling=nt,ot=nt);return fn&&Fa(pe,ct),Ze}for(nt=C(pe,nt);ct<ge.length;ct++)er=He(nt,pe,ct,ge[ct],Le),er!==null&&(u&&er.alternate!==null&&nt.delete(er.key===null?ct:er.key),oe=E(er,oe,ct),ot===null?Ze=er:ot.sibling=er,ot=er);return u&&nt.forEach(function(ea){return h(pe,ea)}),fn&&Fa(pe,ct),Ze}function Xe(pe,oe,ge,Le){var Ze=ie(ge);if(typeof Ze!="function")throw Error(t(150));if(ge=Ze.call(ge),ge==null)throw Error(t(151));for(var ot=Ze=null,nt=oe,ct=oe=0,er=null,Vt=ge.next();nt!==null&&!Vt.done;ct++,Vt=ge.next()){nt.index>ct?(er=nt,nt=null):er=nt.sibling;var ea=Ae(pe,nt,Vt.value,Le);if(ea===null){nt===null&&(nt=er);break}u&&nt&&ea.alternate===null&&h(pe,nt),oe=E(ea,oe,ct),ot===null?Ze=ea:ot.sibling=ea,ot=ea,nt=er}if(Vt.done)return x(pe,nt),fn&&Fa(pe,ct),Ze;if(nt===null){for(;!Vt.done;ct++,Vt=ge.next())Vt=Fe(pe,Vt.value,Le),Vt!==null&&(oe=E(Vt,oe,ct),ot===null?Ze=Vt:ot.sibling=Vt,ot=Vt);return fn&&Fa(pe,ct),Ze}for(nt=C(pe,nt);!Vt.done;ct++,Vt=ge.next())Vt=He(nt,pe,ct,Vt.value,Le),Vt!==null&&(u&&Vt.alternate!==null&&nt.delete(Vt.key===null?ct:Vt.key),oe=E(Vt,oe,ct),ot===null?Ze=Vt:ot.sibling=Vt,ot=Vt);return u&&nt.forEach(function(zw){return h(pe,zw)}),fn&&Fa(pe,ct),Ze}function _n(pe,oe,ge,Le){if(typeof ge=="object"&&ge!==null&&ge.type===P&&ge.key===null&&(ge=ge.props.children),typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case A:e:{for(var Ze=ge.key,ot=oe;ot!==null;){if(ot.key===Ze){if(Ze=ge.type,Ze===P){if(ot.tag===7){x(pe,ot.sibling),oe=$(ot,ge.props.children),oe.return=pe,pe=oe;break e}}else if(ot.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===le&&x0(Ze)===ot.type){x(pe,ot.sibling),oe=$(ot,ge.props),oe.ref=Zu(pe,ot,ge),oe.return=pe,pe=oe;break e}x(pe,ot);break}else h(pe,ot);ot=ot.sibling}ge.type===P?(oe=Ka(ge.props.children,pe.mode,Le,ge.key),oe.return=pe,pe=oe):(Le=Dd(ge.type,ge.key,ge.props,null,pe.mode,Le),Le.ref=Zu(pe,oe,ge),Le.return=pe,pe=Le)}return F(pe);case O:e:{for(ot=ge.key;oe!==null;){if(oe.key===ot)if(oe.tag===4&&oe.stateNode.containerInfo===ge.containerInfo&&oe.stateNode.implementation===ge.implementation){x(pe,oe.sibling),oe=$(oe,ge.children||[]),oe.return=pe,pe=oe;break e}else{x(pe,oe);break}else h(pe,oe);oe=oe.sibling}oe=am(ge,pe.mode,Le),oe.return=pe,pe=oe}return F(pe);case le:return ot=ge._init,_n(pe,oe,ot(ge._payload),Le)}if(Jt(ge))return Ke(pe,oe,ge,Le);if(ie(ge))return Xe(pe,oe,ge,Le);La(pe,ge)}return typeof ge=="string"&&ge!==""||typeof ge=="number"?(ge=""+ge,oe!==null&&oe.tag===6?(x(pe,oe.sibling),oe=$(oe,ge),oe.return=pe,pe=oe):(x(pe,oe),oe=im(ge,pe.mode,Le),oe.return=pe,pe=oe),F(pe)):x(pe,oe)}return _n}var $n=wp(!0),Zh=wp(!1),ec=Qr(null),ys=null,Vi=null,Dl=null;function oi(){Dl=Vi=ys=null}function ed(u){var h=ec.current;dn(ec),u._currentValue=h}function ur(u,h,x){for(;u!==null;){var C=u.alternate;if((u.childLanes&h)!==h?(u.childLanes|=h,C!==null&&(C.childLanes|=h)):C!==null&&(C.childLanes&h)!==h&&(C.childLanes|=h),u===x)break;u=u.return}}function Gi(u,h){ys=u,Dl=Vi=null,u=u.dependencies,u!==null&&u.firstContext!==null&&((u.lanes&h)!==0&&(zr=!0),u.firstContext=null)}function Os(u){var h=u._currentValue;if(Dl!==u)if(u={context:u,memoizedValue:h,next:null},Vi===null){if(ys===null)throw Error(t(308));Vi=u,ys.dependencies={lanes:0,firstContext:u}}else Vi=Vi.next=u;return h}var Ma=null;function bp(u){Ma===null?Ma=[u]:Ma.push(u)}function td(u,h,x,C){var $=h.interleaved;return $===null?(x.next=x,bp(h)):(x.next=$.next,$.next=x),h.interleaved=x,ii(u,C)}function ii(u,h){u.lanes|=h;var x=u.alternate;for(x!==null&&(x.lanes|=h),x=u,u=u.return;u!==null;)u.childLanes|=h,x=u.alternate,x!==null&&(x.childLanes|=h),x=u,u=u.return;return x.tag===3?x.stateNode:null}var Fs=!1;function nd(u){u.updateQueue={baseState:u.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function y0(u,h){u=u.updateQueue,h.updateQueue===u&&(h.updateQueue={baseState:u.baseState,firstBaseUpdate:u.firstBaseUpdate,lastBaseUpdate:u.lastBaseUpdate,shared:u.shared,effects:u.effects})}function ai(u,h){return{eventTime:u,lane:h,tag:0,payload:null,callback:null,next:null}}function Ps(u,h,x){var C=u.updateQueue;if(C===null)return null;if(C=C.shared,(Ft&2)!==0){var $=C.pending;return $===null?h.next=h:(h.next=$.next,$.next=h),C.pending=h,ii(u,x)}return $=C.interleaved,$===null?(h.next=h,bp(C)):(h.next=$.next,$.next=h),C.interleaved=h,ii(u,x)}function rd(u,h,x){if(h=h.updateQueue,h!==null&&(h=h.shared,(x&4194240)!==0)){var C=h.lanes;C&=u.pendingLanes,x|=C,h.lanes=x,Pu(u,x)}}function v0(u,h){var x=u.updateQueue,C=u.alternate;if(C!==null&&(C=C.updateQueue,x===C)){var $=null,E=null;if(x=x.firstBaseUpdate,x!==null){do{var F={eventTime:x.eventTime,lane:x.lane,tag:x.tag,payload:x.payload,callback:x.callback,next:null};E===null?$=E=F:E=E.next=F,x=x.next}while(x!==null);E===null?$=E=h:E=E.next=h}else $=E=h;x={baseState:C.baseState,firstBaseUpdate:$,lastBaseUpdate:E,shared:C.shared,effects:C.effects},u.updateQueue=x;return}u=x.lastBaseUpdate,u===null?x.firstBaseUpdate=h:u.next=h,x.lastBaseUpdate=h}function Ol(u,h,x,C){var $=u.updateQueue;Fs=!1;var E=$.firstBaseUpdate,F=$.lastBaseUpdate,G=$.shared.pending;if(G!==null){$.shared.pending=null;var Q=G,we=Q.next;Q.next=null,F===null?E=we:F.next=we,F=Q;var De=u.alternate;De!==null&&(De=De.updateQueue,G=De.lastBaseUpdate,G!==F&&(G===null?De.firstBaseUpdate=we:G.next=we,De.lastBaseUpdate=Q))}if(E!==null){var Fe=$.baseState;F=0,De=we=Q=null,G=E;do{var Ae=G.lane,He=G.eventTime;if((C&Ae)===Ae){De!==null&&(De=De.next={eventTime:He,lane:0,tag:G.tag,payload:G.payload,callback:G.callback,next:null});e:{var Ke=u,Xe=G;switch(Ae=h,He=x,Xe.tag){case 1:if(Ke=Xe.payload,typeof Ke=="function"){Fe=Ke.call(He,Fe,Ae);break e}Fe=Ke;break e;case 3:Ke.flags=Ke.flags&-65537|128;case 0:if(Ke=Xe.payload,Ae=typeof Ke=="function"?Ke.call(He,Fe,Ae):Ke,Ae==null)break e;Fe=se({},Fe,Ae);break e;case 2:Fs=!0}}G.callback!==null&&G.lane!==0&&(u.flags|=64,Ae=$.effects,Ae===null?$.effects=[G]:Ae.push(G))}else He={eventTime:He,lane:Ae,tag:G.tag,payload:G.payload,callback:G.callback,next:null},De===null?(we=De=He,Q=Fe):De=De.next=He,F|=Ae;if(G=G.next,G===null){if(G=$.shared.pending,G===null)break;Ae=G,G=Ae.next,Ae.next=null,$.lastBaseUpdate=Ae,$.shared.pending=null}}while(!0);if(De===null&&(Q=Fe),$.baseState=Q,$.firstBaseUpdate=we,$.lastBaseUpdate=De,h=$.shared.interleaved,h!==null){$=h;do F|=$.lane,$=$.next;while($!==h)}else E===null&&($.shared.lanes=0);Xi|=F,u.lanes=F,u.memoizedState=Fe}}function Cp(u,h,x){if(u=h.effects,h.effects=null,u!==null)for(h=0;h<u.length;h++){var C=u[h],$=C.callback;if($!==null){if(C.callback=null,C=x,typeof $!="function")throw Error(t(191,$));$.call(C)}}}var tc={},Oo=Qr(tc),nc=Qr(tc),Fl=Qr(tc);function li(u){if(u===tc)throw Error(t(174));return u}function Sp(u,h){switch(ln(Fl,h),ln(nc,u),ln(Oo,tc),u=h.nodeType,u){case 9:case 11:h=(h=h.documentElement)?h.namespaceURI:wr(null,"");break;default:u=u===8?h.parentNode:h,h=u.namespaceURI||null,u=u.tagName,h=wr(h,u)}dn(Oo),ln(Oo,h)}function ji(){dn(Oo),dn(nc),dn(Fl)}function kp(u){li(Fl.current);var h=li(Oo.current),x=wr(h,u.type);h!==x&&(ln(nc,u),ln(Oo,x))}function sd(u){nc.current===u&&(dn(Oo),dn(nc))}var vn=Qr(0);function za(u){for(var h=u;h!==null;){if(h.tag===13){var x=h.memoizedState;if(x!==null&&(x=x.dehydrated,x===null||x.data==="$?"||x.data==="$!"))return h}else if(h.tag===19&&h.memoizedProps.revealOrder!==void 0){if((h.flags&128)!==0)return h}else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===u)break;for(;h.sibling===null;){if(h.return===null||h.return===u)return null;h=h.return}h.sibling.return=h.return,h=h.sibling}return null}var Ip=[];function od(){for(var u=0;u<Ip.length;u++)Ip[u]._workInProgressVersionPrimary=null;Ip.length=0}var rc=T.ReactCurrentDispatcher,$p=T.ReactCurrentBatchConfig,Hi=0,Cn=null,An=null,jn=null,Pl=!1,sc=!1,Ba=0,Ct=0;function Nr(){throw Error(t(321))}function Np(u,h){if(h===null)return!1;for(var x=0;x<h.length&&x<u.length;x++)if(!ve(u[x],h[x]))return!1;return!0}function Ua(u,h,x,C,$,E){if(Hi=E,Cn=h,h.memoizedState=null,h.updateQueue=null,h.lanes=0,rc.current=u===null||u.memoizedState===null?ww:dd,u=x(C,$),sc){E=0;do{if(sc=!1,Ba=0,25<=E)throw Error(t(301));E+=1,jn=An=null,h.updateQueue=null,rc.current=Bl,u=x(C,$)}while(sc)}if(rc.current=hd,h=An!==null&&An.next!==null,Hi=0,jn=An=Cn=null,Pl=!1,h)throw Error(t(300));return u}function id(){var u=Ba!==0;return Ba=0,u}function Fo(){var u={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return jn===null?Cn.memoizedState=jn=u:jn=jn.next=u,jn}function Ls(){if(An===null){var u=Cn.alternate;u=u!==null?u.memoizedState:null}else u=An.next;var h=jn===null?Cn.memoizedState:jn.next;if(h!==null)jn=h,An=u;else{if(u===null)throw Error(t(310));An=u,u={memoizedState:An.memoizedState,baseState:An.baseState,baseQueue:An.baseQueue,queue:An.queue,next:null},jn===null?Cn.memoizedState=jn=u:jn=jn.next=u}return jn}function Tr(u,h){return typeof h=="function"?h(u):h}function Tp(u){var h=Ls(),x=h.queue;if(x===null)throw Error(t(311));x.lastRenderedReducer=u;var C=An,$=C.baseQueue,E=x.pending;if(E!==null){if($!==null){var F=$.next;$.next=E.next,E.next=F}C.baseQueue=$=E,x.pending=null}if($!==null){E=$.next,C=C.baseState;var G=F=null,Q=null,we=E;do{var De=we.lane;if((Hi&De)===De)Q!==null&&(Q=Q.next={lane:0,action:we.action,hasEagerState:we.hasEagerState,eagerState:we.eagerState,next:null}),C=we.hasEagerState?we.eagerState:u(C,we.action);else{var Fe={lane:De,action:we.action,hasEagerState:we.hasEagerState,eagerState:we.eagerState,next:null};Q===null?(G=Q=Fe,F=C):Q=Q.next=Fe,Cn.lanes|=De,Xi|=De}we=we.next}while(we!==null&&we!==E);Q===null?F=C:Q.next=G,ve(C,h.memoizedState)||(zr=!0),h.memoizedState=C,h.baseState=F,h.baseQueue=Q,x.lastRenderedState=C}if(u=x.interleaved,u!==null){$=u;do E=$.lane,Cn.lanes|=E,Xi|=E,$=$.next;while($!==u)}else $===null&&(x.lanes=0);return[h.memoizedState,x.dispatch]}function Ll(u){var h=Ls(),x=h.queue;if(x===null)throw Error(t(311));x.lastRenderedReducer=u;var C=x.dispatch,$=x.pending,E=h.memoizedState;if($!==null){x.pending=null;var F=$=$.next;do E=u(E,F.action),F=F.next;while(F!==$);ve(E,h.memoizedState)||(zr=!0),h.memoizedState=E,h.baseQueue===null&&(h.baseState=E),x.lastRenderedState=E}return[E,C]}function ad(){}function Ep(u,h){var x=Cn,C=Ls(),$=h(),E=!ve(C.memoizedState,$);if(E&&(C.memoizedState=$,zr=!0),C=C.queue,Po(ui.bind(null,x,C,u),[u]),C.getSnapshot!==h||E||jn!==null&&jn.memoizedState.tag&1){if(x.flags|=2048,Ml(9,ts.bind(null,x,C,$,h),void 0,null),Zn===null)throw Error(t(349));(Hi&30)!==0||Rp(x,h,$)}return $}function Rp(u,h,x){u.flags|=16384,u={getSnapshot:h,value:x},h=Cn.updateQueue,h===null?(h={lastEffect:null,stores:null},Cn.updateQueue=h,h.stores=[u]):(x=h.stores,x===null?h.stores=[u]:x.push(u))}function ts(u,h,x,C){h.value=x,h.getSnapshot=C,ld(h)&&Ap(u)}function ui(u,h,x){return x(function(){ld(h)&&Ap(u)})}function ld(u){var h=u.getSnapshot;u=u.value;try{var x=h();return!ve(u,x)}catch{return!0}}function Ap(u){var h=ii(u,1);h!==null&&co(h,u,1,-1)}function oc(u){var h=Fo();return typeof u=="function"&&(u=u()),h.memoizedState=h.baseState=u,u={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Tr,lastRenderedState:u},h.queue=u,u=u.dispatch=I0.bind(null,Cn,u),[h.memoizedState,u]}function Ml(u,h,x,C){return u={tag:u,create:h,destroy:x,deps:C,next:null},h=Cn.updateQueue,h===null?(h={lastEffect:null,stores:null},Cn.updateQueue=h,h.lastEffect=u.next=u):(x=h.lastEffect,x===null?h.lastEffect=u.next=u:(C=x.next,x.next=u,u.next=C,h.lastEffect=u)),u}function ud(){return Ls().memoizedState}function ic(u,h,x,C){var $=Fo();Cn.flags|=u,$.memoizedState=Ml(1|h,x,void 0,C===void 0?null:C)}function zl(u,h,x,C){var $=Ls();C=C===void 0?null:C;var E=void 0;if(An!==null){var F=An.memoizedState;if(E=F.destroy,C!==null&&Np(C,F.deps)){$.memoizedState=Ml(h,x,E,C);return}}Cn.flags|=u,$.memoizedState=Ml(1|h,x,E,C)}function cd(u,h){return ic(8390656,8,u,h)}function Po(u,h){return zl(2048,8,u,h)}function w0(u,h){return zl(4,2,u,h)}function ci(u,h){return zl(4,4,u,h)}function _p(u,h){if(typeof h=="function")return u=u(),h(u),function(){h(null)};if(h!=null)return u=u(),h.current=u,function(){h.current=null}}function Dp(u,h,x){return x=x!=null?x.concat([u]):null,zl(4,4,_p.bind(null,h,u),x)}function ac(){}function b0(u,h){var x=Ls();h=h===void 0?null:h;var C=x.memoizedState;return C!==null&&h!==null&&Np(h,C[1])?C[0]:(x.memoizedState=[u,h],u)}function C0(u,h){var x=Ls();h=h===void 0?null:h;var C=x.memoizedState;return C!==null&&h!==null&&Np(h,C[1])?C[0]:(u=u(),x.memoizedState=[u,h],u)}function S0(u,h,x){return(Hi&21)===0?(u.baseState&&(u.baseState=!1,zr=!0),u.memoizedState=x):(ve(x,h)||(x=Kf(),Cn.lanes|=x,Xi|=x,u.baseState=!0),h)}function k0(u,h){var x=jt;jt=x!==0&&4>x?x:4,u(!0);var C=$p.transition;$p.transition={};try{u(!1),h()}finally{jt=x,$p.transition=C}}function Op(){return Ls().memoizedState}function vw(u,h,x){var C=Ji(u);if(x={lane:C,action:x,hasEagerState:!1,eagerState:null,next:null},Fp(u))Mr(h,x);else if(x=td(u,h,x,C),x!==null){var $=Wr();co(x,u,C,$),oo(x,h,C)}}function I0(u,h,x){var C=Ji(u),$={lane:C,action:x,hasEagerState:!1,eagerState:null,next:null};if(Fp(u))Mr(h,$);else{var E=u.alternate;if(u.lanes===0&&(E===null||E.lanes===0)&&(E=h.lastRenderedReducer,E!==null))try{var F=h.lastRenderedState,G=E(F,x);if($.hasEagerState=!0,$.eagerState=G,ve(G,F)){var Q=h.interleaved;Q===null?($.next=$,bp(h)):($.next=Q.next,Q.next=$),h.interleaved=$;return}}catch{}finally{}x=td(u,h,$,C),x!==null&&($=Wr(),co(x,u,C,$),oo(x,h,C))}}function Fp(u){var h=u.alternate;return u===Cn||h!==null&&h===Cn}function Mr(u,h){sc=Pl=!0;var x=u.pending;x===null?h.next=h:(h.next=x.next,x.next=h),u.pending=h}function oo(u,h,x){if((x&4194240)!==0){var C=h.lanes;C&=u.pendingLanes,x|=C,h.lanes=x,Pu(u,x)}}var hd={readContext:Os,useCallback:Nr,useContext:Nr,useEffect:Nr,useImperativeHandle:Nr,useInsertionEffect:Nr,useLayoutEffect:Nr,useMemo:Nr,useReducer:Nr,useRef:Nr,useState:Nr,useDebugValue:Nr,useDeferredValue:Nr,useTransition:Nr,useMutableSource:Nr,useSyncExternalStore:Nr,useId:Nr,unstable_isNewReconciler:!1},ww={readContext:Os,useCallback:function(u,h){return Fo().memoizedState=[u,h===void 0?null:h],u},useContext:Os,useEffect:cd,useImperativeHandle:function(u,h,x){return x=x!=null?x.concat([u]):null,ic(4194308,4,_p.bind(null,h,u),x)},useLayoutEffect:function(u,h){return ic(4194308,4,u,h)},useInsertionEffect:function(u,h){return ic(4,2,u,h)},useMemo:function(u,h){var x=Fo();return h=h===void 0?null:h,u=u(),x.memoizedState=[u,h],u},useReducer:function(u,h,x){var C=Fo();return h=x!==void 0?x(h):h,C.memoizedState=C.baseState=h,u={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:u,lastRenderedState:h},C.queue=u,u=u.dispatch=vw.bind(null,Cn,u),[C.memoizedState,u]},useRef:function(u){var h=Fo();return u={current:u},h.memoizedState=u},useState:oc,useDebugValue:ac,useDeferredValue:function(u){return Fo().memoizedState=u},useTransition:function(){var u=oc(!1),h=u[0];return u=k0.bind(null,u[1]),Fo().memoizedState=u,[h,u]},useMutableSource:function(){},useSyncExternalStore:function(u,h,x){var C=Cn,$=Fo();if(fn){if(x===void 0)throw Error(t(407));x=x()}else{if(x=h(),Zn===null)throw Error(t(349));(Hi&30)!==0||Rp(C,h,x)}$.memoizedState=x;var E={value:x,getSnapshot:h};return $.queue=E,cd(ui.bind(null,C,E,u),[u]),C.flags|=2048,Ml(9,ts.bind(null,C,E,x,h),void 0,null),x},useId:function(){var u=Fo(),h=Zn.identifierPrefix;if(fn){var x=Ro,C=Eo;x=(C&~(1<<32-no(C)-1)).toString(32)+x,h=":"+h+"R"+x,x=Ba++,0<x&&(h+="H"+x.toString(32)),h+=":"}else x=Ct++,h=":"+h+"r"+x.toString(32)+":";return u.memoizedState=h},unstable_isNewReconciler:!1},dd={readContext:Os,useCallback:b0,useContext:Os,useEffect:Po,useImperativeHandle:Dp,useInsertionEffect:w0,useLayoutEffect:ci,useMemo:C0,useReducer:Tp,useRef:ud,useState:function(){return Tp(Tr)},useDebugValue:ac,useDeferredValue:function(u){var h=Ls();return S0(h,An.memoizedState,u)},useTransition:function(){var u=Tp(Tr)[0],h=Ls().memoizedState;return[u,h]},useMutableSource:ad,useSyncExternalStore:Ep,useId:Op,unstable_isNewReconciler:!1},Bl={readContext:Os,useCallback:b0,useContext:Os,useEffect:Po,useImperativeHandle:Dp,useInsertionEffect:w0,useLayoutEffect:ci,useMemo:C0,useReducer:Ll,useRef:ud,useState:function(){return Ll(Tr)},useDebugValue:ac,useDeferredValue:function(u){var h=Ls();return An===null?h.memoizedState=u:S0(h,An.memoizedState,u)},useTransition:function(){var u=Ll(Tr)[0],h=Ls().memoizedState;return[u,h]},useMutableSource:ad,useSyncExternalStore:Ep,useId:Op,unstable_isNewReconciler:!1};function Ms(u,h){if(u&&u.defaultProps){h=se({},h),u=u.defaultProps;for(var x in u)h[x]===void 0&&(h[x]=u[x]);return h}return h}function fd(u,h,x,C){h=u.memoizedState,x=x(C,h),x=x==null?h:se({},h,x),u.memoizedState=x,u.lanes===0&&(u.updateQueue.baseState=x)}var pd={isMounted:function(u){return(u=u._reactInternals)?ka(u)===u:!1},enqueueSetState:function(u,h,x){u=u._reactInternals;var C=Wr(),$=Ji(u),E=ai(C,$);E.payload=h,x!=null&&(E.callback=x),h=Ps(u,E,$),h!==null&&(co(h,u,$,C),rd(h,u,$))},enqueueReplaceState:function(u,h,x){u=u._reactInternals;var C=Wr(),$=Ji(u),E=ai(C,$);E.tag=1,E.payload=h,x!=null&&(E.callback=x),h=Ps(u,E,$),h!==null&&(co(h,u,$,C),rd(h,u,$))},enqueueForceUpdate:function(u,h){u=u._reactInternals;var x=Wr(),C=Ji(u),$=ai(x,C);$.tag=2,h!=null&&($.callback=h),h=Ps(u,$,C),h!==null&&(co(h,u,C,x),rd(h,u,C))}};function Pp(u,h,x,C,$,E,F){return u=u.stateNode,typeof u.shouldComponentUpdate=="function"?u.shouldComponentUpdate(C,E,F):h.prototype&&h.prototype.isPureReactComponent?!je(x,C)||!je($,E):!0}function Wa(u,h,x){var C=!1,$=Ui,E=h.contextType;return typeof E=="object"&&E!==null?E=Os(E):($=Zr(h)?Lr:kr.current,C=h.contextTypes,E=(C=C!=null)?Al(u,$):Ui),h=new h(x,E),u.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,h.updater=pd,u.stateNode=h,h._reactInternals=u,C&&(u=u.stateNode,u.__reactInternalMemoizedUnmaskedChildContext=$,u.__reactInternalMemoizedMaskedChildContext=E),h}function Ul(u,h,x,C){u=h.state,typeof h.componentWillReceiveProps=="function"&&h.componentWillReceiveProps(x,C),typeof h.UNSAFE_componentWillReceiveProps=="function"&&h.UNSAFE_componentWillReceiveProps(x,C),h.state!==u&&pd.enqueueReplaceState(h,h.state,null)}function Lp(u,h,x,C){var $=u.stateNode;$.props=x,$.state=u.memoizedState,$.refs={},nd(u);var E=h.contextType;typeof E=="object"&&E!==null?$.context=Os(E):(E=Zr(h)?Lr:kr.current,$.context=Al(u,E)),$.state=u.memoizedState,E=h.getDerivedStateFromProps,typeof E=="function"&&(fd(u,h,E,x),$.state=u.memoizedState),typeof h.getDerivedStateFromProps=="function"||typeof $.getSnapshotBeforeUpdate=="function"||typeof $.UNSAFE_componentWillMount!="function"&&typeof $.componentWillMount!="function"||(h=$.state,typeof $.componentWillMount=="function"&&$.componentWillMount(),typeof $.UNSAFE_componentWillMount=="function"&&$.UNSAFE_componentWillMount(),h!==$.state&&pd.enqueueReplaceState($,$.state,null),Ol(u,x,$,C),$.state=u.memoizedState),typeof $.componentDidMount=="function"&&(u.flags|=4194308)}function Va(u,h){try{var x="",C=h;do x+=ke(C),C=C.return;while(C);var $=x}catch(E){$=`
Error generating stack: `+E.message+`
`+E.stack}return{value:u,source:h,stack:$,digest:null}}function md(u,h,x){return{value:u,source:null,stack:x??null,digest:h??null}}function Wl(u,h){try{console.error(h.value)}catch(x){setTimeout(function(){throw x})}}var $0=typeof WeakMap=="function"?WeakMap:Map;function lc(u,h,x){x=ai(-1,x),x.tag=3,x.payload={element:null};var C=h.value;return x.callback=function(){$d||($d=!0,Zp=C),Wl(u,h)},x}function gd(u,h,x){x=ai(-1,x),x.tag=3;var C=u.type.getDerivedStateFromError;if(typeof C=="function"){var $=h.value;x.payload=function(){return C($)},x.callback=function(){Wl(u,h)}}var E=u.stateNode;return E!==null&&typeof E.componentDidCatch=="function"&&(x.callback=function(){Wl(u,h),typeof C!="function"&&(Yi===null?Yi=new Set([this]):Yi.add(this));var F=h.stack;this.componentDidCatch(h.value,{componentStack:F!==null?F:""})}),x}function uc(u,h,x){var C=u.pingCache;if(C===null){C=u.pingCache=new $0;var $=new Set;C.set(h,$)}else $=C.get(h),$===void 0&&($=new Set,C.set(h,$));$.has(x)||($.add(x),u=Tw.bind(null,u,h,x),h.then(u,u))}function N0(u){do{var h;if((h=u.tag===13)&&(h=u.memoizedState,h=h!==null?h.dehydrated!==null:!0),h)return u;u=u.return}while(u!==null);return null}function Mp(u,h,x,C,$){return(u.mode&1)===0?(u===h?u.flags|=65536:(u.flags|=128,x.flags|=131072,x.flags&=-52805,x.tag===1&&(x.alternate===null?x.tag=17:(h=ai(-1,1),h.tag=2,Ps(x,h,1))),x.lanes|=1),u):(u.flags|=65536,u.lanes=$,u)}var xd=T.ReactCurrentOwner,zr=!1;function cr(u,h,x,C){h.child=u===null?Zh(h,null,x,C):$n(h,u.child,x,C)}function T0(u,h,x,C,$){x=x.render;var E=h.ref;return Gi(h,$),C=Ua(u,h,x,C,E,$),x=id(),u!==null&&!zr?(h.updateQueue=u.updateQueue,h.flags&=-2053,u.lanes&=~$,io(u,h,$)):(fn&&x&&Qu(h),h.flags|=1,cr(u,h,C,$),h.child)}function zp(u,h,x,C,$){if(u===null){var E=x.type;return typeof E=="function"&&!_d(E)&&E.defaultProps===void 0&&x.compare===null&&x.defaultProps===void 0?(h.tag=15,h.type=E,Lo(u,h,E,C,$)):(u=Dd(x.type,null,C,h,h.mode,$),u.ref=h.ref,u.return=h,h.child=u)}if(E=u.child,(u.lanes&$)===0){var F=E.memoizedProps;if(x=x.compare,x=x!==null?x:je,x(F,C)&&u.ref===h.ref)return io(u,h,$)}return h.flags|=1,u=ho(E,C),u.ref=h.ref,u.return=h,h.child=u}function Lo(u,h,x,C,$){if(u!==null){var E=u.memoizedProps;if(je(E,C)&&u.ref===h.ref)if(zr=!1,h.pendingProps=C=E,(u.lanes&$)!==0)(u.flags&131072)!==0&&(zr=!0);else return h.lanes=u.lanes,io(u,h,$)}return Wp(u,h,x,C,$)}function Bp(u,h,x){var C=h.pendingProps,$=C.children,E=u!==null?u.memoizedState:null;if(C.mode==="hidden")if((h.mode&1)===0)h.memoizedState={baseLanes:0,cachePool:null,transitions:null},ln(Hl,ws),ws|=x;else{if((x&1073741824)===0)return u=E!==null?E.baseLanes|x:x,h.lanes=h.childLanes=1073741824,h.memoizedState={baseLanes:u,cachePool:null,transitions:null},h.updateQueue=null,ln(Hl,ws),ws|=u,null;h.memoizedState={baseLanes:0,cachePool:null,transitions:null},C=E!==null?E.baseLanes:x,ln(Hl,ws),ws|=C}else E!==null?(C=E.baseLanes|x,h.memoizedState=null):C=x,ln(Hl,ws),ws|=C;return cr(u,h,$,x),h.child}function Up(u,h){var x=h.ref;(u===null&&x!==null||u!==null&&u.ref!==x)&&(h.flags|=512,h.flags|=2097152)}function Wp(u,h,x,C,$){var E=Zr(x)?Lr:kr.current;return E=Al(h,E),Gi(h,$),x=Ua(u,h,x,C,E,$),C=id(),u!==null&&!zr?(h.updateQueue=u.updateQueue,h.flags&=-2053,u.lanes&=~$,io(u,h,$)):(fn&&C&&Qu(h),h.flags|=1,cr(u,h,x,$),h.child)}function Vp(u,h,x,C,$){if(Zr(x)){var E=!0;As(h)}else E=!1;if(Gi(h,$),h.stateNode===null)vd(u,h),Wa(h,x,C),Lp(h,x,C,$),C=!0;else if(u===null){var F=h.stateNode,G=h.memoizedProps;F.props=G;var Q=F.context,we=x.contextType;typeof we=="object"&&we!==null?we=Os(we):(we=Zr(x)?Lr:kr.current,we=Al(h,we));var De=x.getDerivedStateFromProps,Fe=typeof De=="function"||typeof F.getSnapshotBeforeUpdate=="function";Fe||typeof F.UNSAFE_componentWillReceiveProps!="function"&&typeof F.componentWillReceiveProps!="function"||(G!==C||Q!==we)&&Ul(h,F,C,we),Fs=!1;var Ae=h.memoizedState;F.state=Ae,Ol(h,C,F,$),Q=h.memoizedState,G!==C||Ae!==Q||Jr.current||Fs?(typeof De=="function"&&(fd(h,x,De,C),Q=h.memoizedState),(G=Fs||Pp(h,x,G,C,Ae,Q,we))?(Fe||typeof F.UNSAFE_componentWillMount!="function"&&typeof F.componentWillMount!="function"||(typeof F.componentWillMount=="function"&&F.componentWillMount(),typeof F.UNSAFE_componentWillMount=="function"&&F.UNSAFE_componentWillMount()),typeof F.componentDidMount=="function"&&(h.flags|=4194308)):(typeof F.componentDidMount=="function"&&(h.flags|=4194308),h.memoizedProps=C,h.memoizedState=Q),F.props=C,F.state=Q,F.context=we,C=G):(typeof F.componentDidMount=="function"&&(h.flags|=4194308),C=!1)}else{F=h.stateNode,y0(u,h),G=h.memoizedProps,we=h.type===h.elementType?G:Ms(h.type,G),F.props=we,Fe=h.pendingProps,Ae=F.context,Q=x.contextType,typeof Q=="object"&&Q!==null?Q=Os(Q):(Q=Zr(x)?Lr:kr.current,Q=Al(h,Q));var He=x.getDerivedStateFromProps;(De=typeof He=="function"||typeof F.getSnapshotBeforeUpdate=="function")||typeof F.UNSAFE_componentWillReceiveProps!="function"&&typeof F.componentWillReceiveProps!="function"||(G!==Fe||Ae!==Q)&&Ul(h,F,C,Q),Fs=!1,Ae=h.memoizedState,F.state=Ae,Ol(h,C,F,$);var Ke=h.memoizedState;G!==Fe||Ae!==Ke||Jr.current||Fs?(typeof He=="function"&&(fd(h,x,He,C),Ke=h.memoizedState),(we=Fs||Pp(h,x,we,C,Ae,Ke,Q)||!1)?(De||typeof F.UNSAFE_componentWillUpdate!="function"&&typeof F.componentWillUpdate!="function"||(typeof F.componentWillUpdate=="function"&&F.componentWillUpdate(C,Ke,Q),typeof F.UNSAFE_componentWillUpdate=="function"&&F.UNSAFE_componentWillUpdate(C,Ke,Q)),typeof F.componentDidUpdate=="function"&&(h.flags|=4),typeof F.getSnapshotBeforeUpdate=="function"&&(h.flags|=1024)):(typeof F.componentDidUpdate!="function"||G===u.memoizedProps&&Ae===u.memoizedState||(h.flags|=4),typeof F.getSnapshotBeforeUpdate!="function"||G===u.memoizedProps&&Ae===u.memoizedState||(h.flags|=1024),h.memoizedProps=C,h.memoizedState=Ke),F.props=C,F.state=Ke,F.context=Q,C=we):(typeof F.componentDidUpdate!="function"||G===u.memoizedProps&&Ae===u.memoizedState||(h.flags|=4),typeof F.getSnapshotBeforeUpdate!="function"||G===u.memoizedProps&&Ae===u.memoizedState||(h.flags|=1024),C=!1)}return Gp(u,h,x,C,E,$)}function Gp(u,h,x,C,$,E){Up(u,h);var F=(h.flags&128)!==0;if(!C&&!F)return $&&d0(h,x,!1),io(u,h,E);C=h.stateNode,xd.current=h;var G=F&&typeof x.getDerivedStateFromError!="function"?null:C.render();return h.flags|=1,u!==null&&F?(h.child=$n(h,u.child,null,E),h.child=$n(h,null,G,E)):cr(u,h,G,E),h.memoizedState=C.state,$&&d0(h,x,!0),h.child}function E0(u){var h=u.stateNode;h.pendingContext?c0(u,h.pendingContext,h.pendingContext!==h.context):h.context&&c0(u,h.context,!1),Sp(u,h.containerInfo)}function Mo(u,h,x,C,$){return _o(),Do($),h.flags|=256,cr(u,h,x,C),h.child}var cc={dehydrated:null,treeContext:null,retryLane:0};function hc(u){return{baseLanes:u,cachePool:null,transitions:null}}function yd(u,h,x){var C=h.pendingProps,$=vn.current,E=!1,F=(h.flags&128)!==0,G;if((G=F)||(G=u!==null&&u.memoizedState===null?!1:($&2)!==0),G?(E=!0,h.flags&=-129):(u===null||u.memoizedState!==null)&&($|=1),ln(vn,$&1),u===null)return es(h),u=h.memoizedState,u!==null&&(u=u.dehydrated,u!==null)?((h.mode&1)===0?h.lanes=1:u.data==="$!"?h.lanes=8:h.lanes=1073741824,null):(F=C.children,u=C.fallback,E?(C=h.mode,E=h.child,F={mode:"hidden",children:F},(C&1)===0&&E!==null?(E.childLanes=0,E.pendingProps=F):E=Od(F,C,0,null),u=Ka(u,C,x,null),E.return=h,u.return=h,E.sibling=u,h.child=E,h.child.memoizedState=hc(x),h.memoizedState=cc,u):Vl(h,F));if($=u.memoizedState,$!==null&&(G=$.dehydrated,G!==null))return at(u,h,F,C,G,$,x);if(E){E=C.fallback,F=h.mode,$=u.child,G=$.sibling;var Q={mode:"hidden",children:C.children};return(F&1)===0&&h.child!==$?(C=h.child,C.childLanes=0,C.pendingProps=Q,h.deletions=null):(C=ho($,Q),C.subtreeFlags=$.subtreeFlags&14680064),G!==null?E=ho(G,E):(E=Ka(E,F,x,null),E.flags|=2),E.return=h,C.return=h,C.sibling=E,h.child=C,C=E,E=h.child,F=u.child.memoizedState,F=F===null?hc(x):{baseLanes:F.baseLanes|x,cachePool:null,transitions:F.transitions},E.memoizedState=F,E.childLanes=u.childLanes&~x,h.memoizedState=cc,C}return E=u.child,u=E.sibling,C=ho(E,{mode:"visible",children:C.children}),(h.mode&1)===0&&(C.lanes=x),C.return=h,C.sibling=null,u!==null&&(x=h.deletions,x===null?(h.deletions=[u],h.flags|=16):x.push(u)),h.child=C,h.memoizedState=null,C}function Vl(u,h){return h=Od({mode:"visible",children:h},u.mode,0,null),h.return=u,u.child=h}function hi(u,h,x,C){return C!==null&&Do(C),$n(h,u.child,null,x),u=Vl(h,h.pendingProps.children),u.flags|=2,h.memoizedState=null,u}function at(u,h,x,C,$,E,F){if(x)return h.flags&256?(h.flags&=-257,C=md(Error(t(422))),hi(u,h,F,C)):h.memoizedState!==null?(h.child=u.child,h.flags|=128,null):(E=C.fallback,$=h.mode,C=Od({mode:"visible",children:C.children},$,0,null),E=Ka(E,$,F,null),E.flags|=2,C.return=h,E.return=h,C.sibling=E,h.child=C,(h.mode&1)!==0&&$n(h,u.child,null,F),h.child.memoizedState=hc(F),h.memoizedState=cc,E);if((h.mode&1)===0)return hi(u,h,F,null);if($.data==="$!"){if(C=$.nextSibling&&$.nextSibling.dataset,C)var G=C.dgst;return C=G,E=Error(t(419)),C=md(E,C,void 0),hi(u,h,F,C)}if(G=(F&u.childLanes)!==0,zr||G){if(C=Zn,C!==null){switch(F&-F){case 4:$=2;break;case 16:$=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:$=32;break;case 536870912:$=268435456;break;default:$=0}$=($&(C.suspendedLanes|F))!==0?0:$,$!==0&&$!==E.retryLane&&(E.retryLane=$,ii(u,$),co(C,u,$,-1))}return om(),C=md(Error(t(421))),hi(u,h,F,C)}return $.data==="$?"?(h.flags|=128,h.child=u.child,h=Ew.bind(null,u),$._reactRetry=h,null):(u=E.treeContext,xs=zi($.nextSibling),$r=h,fn=!0,so=null,u!==null&&(_s[Ds++]=Eo,_s[Ds++]=Ro,_s[Ds++]=Oa,Eo=u.id,Ro=u.overflow,Oa=h),h=Vl(h,C.children),h.flags|=4096,h)}function dc(u,h,x){u.lanes|=h;var C=u.alternate;C!==null&&(C.lanes|=h),ur(u.return,h,x)}function fc(u,h,x,C,$){var E=u.memoizedState;E===null?u.memoizedState={isBackwards:h,rendering:null,renderingStartTime:0,last:C,tail:x,tailMode:$}:(E.isBackwards=h,E.rendering=null,E.renderingStartTime=0,E.last=C,E.tail=x,E.tailMode=$)}function qi(u,h,x){var C=h.pendingProps,$=C.revealOrder,E=C.tail;if(cr(u,h,C.children,x),C=vn.current,(C&2)!==0)C=C&1|2,h.flags|=128;else{if(u!==null&&(u.flags&128)!==0)e:for(u=h.child;u!==null;){if(u.tag===13)u.memoizedState!==null&&dc(u,x,h);else if(u.tag===19)dc(u,x,h);else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===h)break e;for(;u.sibling===null;){if(u.return===null||u.return===h)break e;u=u.return}u.sibling.return=u.return,u=u.sibling}C&=1}if(ln(vn,C),(h.mode&1)===0)h.memoizedState=null;else switch($){case"forwards":for(x=h.child,$=null;x!==null;)u=x.alternate,u!==null&&za(u)===null&&($=x),x=x.sibling;x=$,x===null?($=h.child,h.child=null):($=x.sibling,x.sibling=null),fc(h,!1,$,x,E);break;case"backwards":for(x=null,$=h.child,h.child=null;$!==null;){if(u=$.alternate,u!==null&&za(u)===null){h.child=$;break}u=$.sibling,$.sibling=x,x=$,$=u}fc(h,!0,x,null,E);break;case"together":fc(h,!1,null,null,void 0);break;default:h.memoizedState=null}return h.child}function vd(u,h){(h.mode&1)===0&&u!==null&&(u.alternate=null,h.alternate=null,h.flags|=2)}function io(u,h,x){if(u!==null&&(h.dependencies=u.dependencies),Xi|=h.lanes,(x&h.childLanes)===0)return null;if(u!==null&&h.child!==u.child)throw Error(t(153));if(h.child!==null){for(u=h.child,x=ho(u,u.pendingProps),h.child=x,x.return=h;u.sibling!==null;)u=u.sibling,x=x.sibling=ho(u,u.pendingProps),x.return=h;x.sibling=null}return h.child}function R0(u,h,x){switch(h.tag){case 3:E0(h),_o();break;case 5:kp(h);break;case 1:Zr(h.type)&&As(h);break;case 4:Sp(h,h.stateNode.containerInfo);break;case 10:var C=h.type._context,$=h.memoizedProps.value;ln(ec,C._currentValue),C._currentValue=$;break;case 13:if(C=h.memoizedState,C!==null)return C.dehydrated!==null?(ln(vn,vn.current&1),h.flags|=128,null):(x&h.child.childLanes)!==0?yd(u,h,x):(ln(vn,vn.current&1),u=io(u,h,x),u!==null?u.sibling:null);ln(vn,vn.current&1);break;case 19:if(C=(x&h.childLanes)!==0,(u.flags&128)!==0){if(C)return qi(u,h,x);h.flags|=128}if($=h.memoizedState,$!==null&&($.rendering=null,$.tail=null,$.lastEffect=null),ln(vn,vn.current),C)break;return null;case 22:case 23:return h.lanes=0,Bp(u,h,x)}return io(u,h,x)}var hr,jp,A0,Hp;hr=function(u,h){for(var x=h.child;x!==null;){if(x.tag===5||x.tag===6)u.appendChild(x.stateNode);else if(x.tag!==4&&x.child!==null){x.child.return=x,x=x.child;continue}if(x===h)break;for(;x.sibling===null;){if(x.return===null||x.return===h)return;x=x.return}x.sibling.return=x.return,x=x.sibling}},jp=function(){},A0=function(u,h,x,C){var $=u.memoizedProps;if($!==C){u=h.stateNode,li(Oo.current);var E=null;switch(x){case"input":$=Rt(u,$),C=Rt(u,C),E=[];break;case"select":$=se({},$,{value:void 0}),C=se({},C,{value:void 0}),E=[];break;case"textarea":$=Rn(u,$),C=Rn(u,C),E=[];break;default:typeof $.onClick!="function"&&typeof C.onClick=="function"&&(u.onclick=Gh)}Nu(x,C);var F;x=null;for(we in $)if(!C.hasOwnProperty(we)&&$.hasOwnProperty(we)&&$[we]!=null)if(we==="style"){var G=$[we];for(F in G)G.hasOwnProperty(F)&&(x||(x={}),x[F]="")}else we!=="dangerouslySetInnerHTML"&&we!=="children"&&we!=="suppressContentEditableWarning"&&we!=="suppressHydrationWarning"&&we!=="autoFocus"&&(s.hasOwnProperty(we)?E||(E=[]):(E=E||[]).push(we,null));for(we in C){var Q=C[we];if(G=$?.[we],C.hasOwnProperty(we)&&Q!==G&&(Q!=null||G!=null))if(we==="style")if(G){for(F in G)!G.hasOwnProperty(F)||Q&&Q.hasOwnProperty(F)||(x||(x={}),x[F]="");for(F in Q)Q.hasOwnProperty(F)&&G[F]!==Q[F]&&(x||(x={}),x[F]=Q[F])}else x||(E||(E=[]),E.push(we,x)),x=Q;else we==="dangerouslySetInnerHTML"?(Q=Q?Q.__html:void 0,G=G?G.__html:void 0,Q!=null&&G!==Q&&(E=E||[]).push(we,Q)):we==="children"?typeof Q!="string"&&typeof Q!="number"||(E=E||[]).push(we,""+Q):we!=="suppressContentEditableWarning"&&we!=="suppressHydrationWarning"&&(s.hasOwnProperty(we)?(Q!=null&&we==="onScroll"&&hn("scroll",u),E||G===Q||(E=[])):(E=E||[]).push(we,Q))}x&&(E=E||[]).push("style",x);var we=E;(h.updateQueue=we)&&(h.flags|=4)}},Hp=function(u,h,x,C){x!==C&&(h.flags|=4)};function pc(u,h){if(!fn)switch(u.tailMode){case"hidden":h=u.tail;for(var x=null;h!==null;)h.alternate!==null&&(x=h),h=h.sibling;x===null?u.tail=null:x.sibling=null;break;case"collapsed":x=u.tail;for(var C=null;x!==null;)x.alternate!==null&&(C=x),x=x.sibling;C===null?h||u.tail===null?u.tail=null:u.tail.sibling=null:C.sibling=null}}function dr(u){var h=u.alternate!==null&&u.alternate.child===u.child,x=0,C=0;if(h)for(var $=u.child;$!==null;)x|=$.lanes|$.childLanes,C|=$.subtreeFlags&14680064,C|=$.flags&14680064,$.return=u,$=$.sibling;else for($=u.child;$!==null;)x|=$.lanes|$.childLanes,C|=$.subtreeFlags,C|=$.flags,$.return=u,$=$.sibling;return u.subtreeFlags|=C,u.childLanes=x,h}function bw(u,h,x){var C=h.pendingProps;switch(Pa(h),h.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return dr(h),null;case 1:return Zr(h.type)&&Kh(),dr(h),null;case 3:return C=h.stateNode,ji(),dn(Jr),dn(kr),od(),C.pendingContext&&(C.context=C.pendingContext,C.pendingContext=null),(u===null||u.child===null)&&(Ju(h)?h.flags|=4:u===null||u.memoizedState.isDehydrated&&(h.flags&256)===0||(h.flags|=1024,so!==null&&(nm(so),so=null))),jp(u,h),dr(h),null;case 5:sd(h);var $=li(Fl.current);if(x=h.type,u!==null&&h.stateNode!=null)A0(u,h,x,C,$),u.ref!==h.ref&&(h.flags|=512,h.flags|=2097152);else{if(!C){if(h.stateNode===null)throw Error(t(166));return dr(h),null}if(u=li(Oo.current),Ju(h)){C=h.stateNode,x=h.type;var E=h.memoizedProps;switch(C[No]=h,C[Bi]=E,u=(h.mode&1)!==0,x){case"dialog":hn("cancel",C),hn("close",C);break;case"iframe":case"object":case"embed":hn("load",C);break;case"video":case"audio":for($=0;$<ni.length;$++)hn(ni[$],C);break;case"source":hn("error",C);break;case"img":case"image":case"link":hn("error",C),hn("load",C);break;case"details":hn("toggle",C);break;case"input":Ot(C,E),hn("invalid",C);break;case"select":C._wrapperState={wasMultiple:!!E.multiple},hn("invalid",C);break;case"textarea":fs(C,E),hn("invalid",C)}Nu(x,E),$=null;for(var F in E)if(E.hasOwnProperty(F)){var G=E[F];F==="children"?typeof G=="string"?C.textContent!==G&&(E.suppressHydrationWarning!==!0&&qu(C.textContent,G,u),$=["children",G]):typeof G=="number"&&C.textContent!==""+G&&(E.suppressHydrationWarning!==!0&&qu(C.textContent,G,u),$=["children",""+G]):s.hasOwnProperty(F)&&G!=null&&F==="onScroll"&&hn("scroll",C)}switch(x){case"input":lt(C),Yt(C,E,!0);break;case"textarea":lt(C),vr(C);break;case"select":case"option":break;default:typeof E.onClick=="function"&&(C.onclick=Gh)}C=$,h.updateQueue=C,C!==null&&(h.flags|=4)}else{F=$.nodeType===9?$:$.ownerDocument,u==="http://www.w3.org/1999/xhtml"&&(u=Zs(x)),u==="http://www.w3.org/1999/xhtml"?x==="script"?(u=F.createElement("div"),u.innerHTML="<script><\/script>",u=u.removeChild(u.firstChild)):typeof C.is=="string"?u=F.createElement(x,{is:C.is}):(u=F.createElement(x),x==="select"&&(F=u,C.multiple?F.multiple=!0:C.size&&(F.size=C.size))):u=F.createElementNS(u,x),u[No]=h,u[Bi]=C,hr(u,h,!1,!1),h.stateNode=u;e:{switch(F=Tu(x,C),x){case"dialog":hn("cancel",u),hn("close",u),$=C;break;case"iframe":case"object":case"embed":hn("load",u),$=C;break;case"video":case"audio":for($=0;$<ni.length;$++)hn(ni[$],u);$=C;break;case"source":hn("error",u),$=C;break;case"img":case"image":case"link":hn("error",u),hn("load",u),$=C;break;case"details":hn("toggle",u),$=C;break;case"input":Ot(u,C),$=Rt(u,C),hn("invalid",u);break;case"option":$=C;break;case"select":u._wrapperState={wasMultiple:!!C.multiple},$=se({},C,{value:void 0}),hn("invalid",u);break;case"textarea":fs(u,C),$=Rn(u,C),hn("invalid",u);break;default:$=C}Nu(x,$),G=$;for(E in G)if(G.hasOwnProperty(E)){var Q=G[E];E==="style"?hl(u,Q):E==="dangerouslySetInnerHTML"?(Q=Q?Q.__html:void 0,Q!=null&&So(u,Q)):E==="children"?typeof Q=="string"?(x!=="textarea"||Q!=="")&&eo(u,Q):typeof Q=="number"&&eo(u,""+Q):E!=="suppressContentEditableWarning"&&E!=="suppressHydrationWarning"&&E!=="autoFocus"&&(s.hasOwnProperty(E)?Q!=null&&E==="onScroll"&&hn("scroll",u):Q!=null&&N(u,E,Q,F))}switch(x){case"input":lt(u),Yt(u,C,!1);break;case"textarea":lt(u),vr(u);break;case"option":C.value!=null&&u.setAttribute("value",""+ze(C.value));break;case"select":u.multiple=!!C.multiple,E=C.value,E!=null?cn(u,!!C.multiple,E,!1):C.defaultValue!=null&&cn(u,!!C.multiple,C.defaultValue,!0);break;default:typeof $.onClick=="function"&&(u.onclick=Gh)}switch(x){case"button":case"input":case"select":case"textarea":C=!!C.autoFocus;break e;case"img":C=!0;break e;default:C=!1}}C&&(h.flags|=4)}h.ref!==null&&(h.flags|=512,h.flags|=2097152)}return dr(h),null;case 6:if(u&&h.stateNode!=null)Hp(u,h,u.memoizedProps,C);else{if(typeof C!="string"&&h.stateNode===null)throw Error(t(166));if(x=li(Fl.current),li(Oo.current),Ju(h)){if(C=h.stateNode,x=h.memoizedProps,C[No]=h,(E=C.nodeValue!==x)&&(u=$r,u!==null))switch(u.tag){case 3:qu(C.nodeValue,x,(u.mode&1)!==0);break;case 5:u.memoizedProps.suppressHydrationWarning!==!0&&qu(C.nodeValue,x,(u.mode&1)!==0)}E&&(h.flags|=4)}else C=(x.nodeType===9?x:x.ownerDocument).createTextNode(C),C[No]=h,h.stateNode=C}return dr(h),null;case 13:if(dn(vn),C=h.memoizedState,u===null||u.memoizedState!==null&&u.memoizedState.dehydrated!==null){if(fn&&xs!==null&&(h.mode&1)!==0&&(h.flags&128)===0)vp(),_o(),h.flags|=98560,E=!1;else if(E=Ju(h),C!==null&&C.dehydrated!==null){if(u===null){if(!E)throw Error(t(318));if(E=h.memoizedState,E=E!==null?E.dehydrated:null,!E)throw Error(t(317));E[No]=h}else _o(),(h.flags&128)===0&&(h.memoizedState=null),h.flags|=4;dr(h),E=!1}else so!==null&&(nm(so),so=null),E=!0;if(!E)return h.flags&65536?h:null}return(h.flags&128)!==0?(h.lanes=x,h):(C=C!==null,C!==(u!==null&&u.memoizedState!==null)&&C&&(h.child.flags|=8192,(h.mode&1)!==0&&(u===null||(vn.current&1)!==0?Hn===0&&(Hn=3):om())),h.updateQueue!==null&&(h.flags|=4),dr(h),null);case 4:return ji(),jp(u,h),u===null&&Li(h.stateNode.containerInfo),dr(h),null;case 10:return ed(h.type._context),dr(h),null;case 17:return Zr(h.type)&&Kh(),dr(h),null;case 19:if(dn(vn),E=h.memoizedState,E===null)return dr(h),null;if(C=(h.flags&128)!==0,F=E.rendering,F===null)if(C)pc(E,!1);else{if(Hn!==0||u!==null&&(u.flags&128)!==0)for(u=h.child;u!==null;){if(F=za(u),F!==null){for(h.flags|=128,pc(E,!1),C=F.updateQueue,C!==null&&(h.updateQueue=C,h.flags|=4),h.subtreeFlags=0,C=x,x=h.child;x!==null;)E=x,u=C,E.flags&=14680066,F=E.alternate,F===null?(E.childLanes=0,E.lanes=u,E.child=null,E.subtreeFlags=0,E.memoizedProps=null,E.memoizedState=null,E.updateQueue=null,E.dependencies=null,E.stateNode=null):(E.childLanes=F.childLanes,E.lanes=F.lanes,E.child=F.child,E.subtreeFlags=0,E.deletions=null,E.memoizedProps=F.memoizedProps,E.memoizedState=F.memoizedState,E.updateQueue=F.updateQueue,E.type=F.type,u=F.dependencies,E.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext}),x=x.sibling;return ln(vn,vn.current&1|2),h.child}u=u.sibling}E.tail!==null&&xn()>Ga&&(h.flags|=128,C=!0,pc(E,!1),h.lanes=4194304)}else{if(!C)if(u=za(F),u!==null){if(h.flags|=128,C=!0,x=u.updateQueue,x!==null&&(h.updateQueue=x,h.flags|=4),pc(E,!0),E.tail===null&&E.tailMode==="hidden"&&!F.alternate&&!fn)return dr(h),null}else 2*xn()-E.renderingStartTime>Ga&&x!==1073741824&&(h.flags|=128,C=!0,pc(E,!1),h.lanes=4194304);E.isBackwards?(F.sibling=h.child,h.child=F):(x=E.last,x!==null?x.sibling=F:h.child=F,E.last=F)}return E.tail!==null?(h=E.tail,E.rendering=h,E.tail=h.sibling,E.renderingStartTime=xn(),h.sibling=null,x=vn.current,ln(vn,C?x&1|2:x&1),h):(dr(h),null);case 22:case 23:return sm(),C=h.memoizedState!==null,u!==null&&u.memoizedState!==null!==C&&(h.flags|=8192),C&&(h.mode&1)!==0?(ws&1073741824)!==0&&(dr(h),h.subtreeFlags&6&&(h.flags|=8192)):dr(h),null;case 24:return null;case 25:return null}throw Error(t(156,h.tag))}function Cw(u,h){switch(Pa(h),h.tag){case 1:return Zr(h.type)&&Kh(),u=h.flags,u&65536?(h.flags=u&-65537|128,h):null;case 3:return ji(),dn(Jr),dn(kr),od(),u=h.flags,(u&65536)!==0&&(u&128)===0?(h.flags=u&-65537|128,h):null;case 5:return sd(h),null;case 13:if(dn(vn),u=h.memoizedState,u!==null&&u.dehydrated!==null){if(h.alternate===null)throw Error(t(340));_o()}return u=h.flags,u&65536?(h.flags=u&-65537|128,h):null;case 19:return dn(vn),null;case 4:return ji(),null;case 10:return ed(h.type._context),null;case 22:case 23:return sm(),null;case 24:return null;default:return null}}var wd=!1,wn=!1,Br=typeof WeakSet=="function"?WeakSet:Set,qe=null;function Gl(u,h){var x=u.ref;if(x!==null)if(typeof x=="function")try{x(null)}catch(C){Sn(u,h,C)}else x.current=null}function mc(u,h,x){try{x()}catch(C){Sn(u,h,C)}}var _0=!1;function Sw(u,h){if(Ku=$h,u=Zt(),Uu(u)){if("selectionStart"in u)var x={start:u.selectionStart,end:u.selectionEnd};else e:{x=(x=u.ownerDocument)&&x.defaultView||window;var C=x.getSelection&&x.getSelection();if(C&&C.rangeCount!==0){x=C.anchorNode;var $=C.anchorOffset,E=C.focusNode;C=C.focusOffset;try{x.nodeType,E.nodeType}catch{x=null;break e}var F=0,G=-1,Q=-1,we=0,De=0,Fe=u,Ae=null;t:for(;;){for(var He;Fe!==x||$!==0&&Fe.nodeType!==3||(G=F+$),Fe!==E||C!==0&&Fe.nodeType!==3||(Q=F+C),Fe.nodeType===3&&(F+=Fe.nodeValue.length),(He=Fe.firstChild)!==null;)Ae=Fe,Fe=He;for(;;){if(Fe===u)break t;if(Ae===x&&++we===$&&(G=F),Ae===E&&++De===C&&(Q=F),(He=Fe.nextSibling)!==null)break;Fe=Ae,Ae=Fe.parentNode}Fe=He}x=G===-1||Q===-1?null:{start:G,end:Q}}else x=null}x=x||{start:0,end:0}}else x=null;for(_a={focusedElem:u,selectionRange:x},$h=!1,qe=h;qe!==null;)if(h=qe,u=h.child,(h.subtreeFlags&1028)!==0&&u!==null)u.return=h,qe=u;else for(;qe!==null;){h=qe;try{var Ke=h.alternate;if((h.flags&1024)!==0)switch(h.tag){case 0:case 11:case 15:break;case 1:if(Ke!==null){var Xe=Ke.memoizedProps,_n=Ke.memoizedState,pe=h.stateNode,oe=pe.getSnapshotBeforeUpdate(h.elementType===h.type?Xe:Ms(h.type,Xe),_n);pe.__reactInternalSnapshotBeforeUpdate=oe}break;case 3:var ge=h.stateNode.containerInfo;ge.nodeType===1?ge.textContent="":ge.nodeType===9&&ge.documentElement&&ge.removeChild(ge.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(Le){Sn(h,h.return,Le)}if(u=h.sibling,u!==null){u.return=h.return,qe=u;break}qe=h.return}return Ke=_0,_0=!1,Ke}function di(u,h,x){var C=h.updateQueue;if(C=C!==null?C.lastEffect:null,C!==null){var $=C=C.next;do{if(($.tag&u)===u){var E=$.destroy;$.destroy=void 0,E!==void 0&&mc(h,x,E)}$=$.next}while($!==C)}}function gc(u,h){if(h=h.updateQueue,h=h!==null?h.lastEffect:null,h!==null){var x=h=h.next;do{if((x.tag&u)===u){var C=x.create;x.destroy=C()}x=x.next}while(x!==h)}}function bd(u){var h=u.ref;if(h!==null){var x=u.stateNode;switch(u.tag){case 5:u=x;break;default:u=x}typeof h=="function"?h(u):h.current=u}}function D0(u){var h=u.alternate;h!==null&&(u.alternate=null,D0(h)),u.child=null,u.deletions=null,u.sibling=null,u.tag===5&&(h=u.stateNode,h!==null&&(delete h[No],delete h[Bi],delete h[Hh],delete h[M],delete h[El])),u.stateNode=null,u.return=null,u.dependencies=null,u.memoizedProps=null,u.memoizedState=null,u.pendingProps=null,u.stateNode=null,u.updateQueue=null}function O0(u){return u.tag===5||u.tag===3||u.tag===4}function F0(u){e:for(;;){for(;u.sibling===null;){if(u.return===null||O0(u.return))return null;u=u.return}for(u.sibling.return=u.return,u=u.sibling;u.tag!==5&&u.tag!==6&&u.tag!==18;){if(u.flags&2||u.child===null||u.tag===4)continue e;u.child.return=u,u=u.child}if(!(u.flags&2))return u.stateNode}}function qp(u,h,x){var C=u.tag;if(C===5||C===6)u=u.stateNode,h?x.nodeType===8?x.parentNode.insertBefore(u,h):x.insertBefore(u,h):(x.nodeType===8?(h=x.parentNode,h.insertBefore(u,x)):(h=x,h.appendChild(u)),x=x._reactRootContainer,x!=null||h.onclick!==null||(h.onclick=Gh));else if(C!==4&&(u=u.child,u!==null))for(qp(u,h,x),u=u.sibling;u!==null;)qp(u,h,x),u=u.sibling}function Cd(u,h,x){var C=u.tag;if(C===5||C===6)u=u.stateNode,h?x.insertBefore(u,h):x.appendChild(u);else if(C!==4&&(u=u.child,u!==null))for(Cd(u,h,x),u=u.sibling;u!==null;)Cd(u,h,x),u=u.sibling}var Jn=null,ao=!1;function zo(u,h,x){for(x=x.child;x!==null;)Kp(u,h,x),x=x.sibling}function Kp(u,h,x){if(ko&&typeof ko.onCommitFiberUnmount=="function")try{ko.onCommitFiberUnmount(wh,x)}catch{}switch(x.tag){case 5:wn||Gl(x,h);case 6:var C=Jn,$=ao;Jn=null,zo(u,h,x),Jn=C,ao=$,Jn!==null&&(ao?(u=Jn,x=x.stateNode,u.nodeType===8?u.parentNode.removeChild(x):u.removeChild(x)):Jn.removeChild(x.stateNode));break;case 18:Jn!==null&&(ao?(u=Jn,x=x.stateNode,u.nodeType===8?gp(u.parentNode,x):u.nodeType===1&&gp(u,x),Ht(u)):gp(Jn,x.stateNode));break;case 4:C=Jn,$=ao,Jn=x.stateNode.containerInfo,ao=!0,zo(u,h,x),Jn=C,ao=$;break;case 0:case 11:case 14:case 15:if(!wn&&(C=x.updateQueue,C!==null&&(C=C.lastEffect,C!==null))){$=C=C.next;do{var E=$,F=E.destroy;E=E.tag,F!==void 0&&((E&2)!==0||(E&4)!==0)&&mc(x,h,F),$=$.next}while($!==C)}zo(u,h,x);break;case 1:if(!wn&&(Gl(x,h),C=x.stateNode,typeof C.componentWillUnmount=="function"))try{C.props=x.memoizedProps,C.state=x.memoizedState,C.componentWillUnmount()}catch(G){Sn(x,h,G)}zo(u,h,x);break;case 21:zo(u,h,x);break;case 22:x.mode&1?(wn=(C=wn)||x.memoizedState!==null,zo(u,h,x),wn=C):zo(u,h,x);break;default:zo(u,h,x)}}function jl(u){var h=u.updateQueue;if(h!==null){u.updateQueue=null;var x=u.stateNode;x===null&&(x=u.stateNode=new Br),h.forEach(function(C){var $=Rw.bind(null,u,C);x.has(C)||(x.add(C),C.then($,$))})}}function vs(u,h){var x=h.deletions;if(x!==null)for(var C=0;C<x.length;C++){var $=x[C];try{var E=u,F=h,G=F;e:for(;G!==null;){switch(G.tag){case 5:Jn=G.stateNode,ao=!1;break e;case 3:Jn=G.stateNode.containerInfo,ao=!0;break e;case 4:Jn=G.stateNode.containerInfo,ao=!0;break e}G=G.return}if(Jn===null)throw Error(t(160));Kp(E,F,$),Jn=null,ao=!1;var Q=$.alternate;Q!==null&&(Q.return=null),$.return=null}catch(we){Sn($,h,we)}}if(h.subtreeFlags&12854)for(h=h.child;h!==null;)Xp(h,u),h=h.sibling}function Xp(u,h){var x=u.alternate,C=u.flags;switch(u.tag){case 0:case 11:case 14:case 15:if(vs(h,u),lo(u),C&4){try{di(3,u,u.return),gc(3,u)}catch(Xe){Sn(u,u.return,Xe)}try{di(5,u,u.return)}catch(Xe){Sn(u,u.return,Xe)}}break;case 1:vs(h,u),lo(u),C&512&&x!==null&&Gl(x,x.return);break;case 5:if(vs(h,u),lo(u),C&512&&x!==null&&Gl(x,x.return),u.flags&32){var $=u.stateNode;try{eo($,"")}catch(Xe){Sn(u,u.return,Xe)}}if(C&4&&($=u.stateNode,$!=null)){var E=u.memoizedProps,F=x!==null?x.memoizedProps:E,G=u.type,Q=u.updateQueue;if(u.updateQueue=null,Q!==null)try{G==="input"&&E.type==="radio"&&E.name!=null&&Bt($,E),Tu(G,F);var we=Tu(G,E);for(F=0;F<Q.length;F+=2){var De=Q[F],Fe=Q[F+1];De==="style"?hl($,Fe):De==="dangerouslySetInnerHTML"?So($,Fe):De==="children"?eo($,Fe):N($,De,Fe,we)}switch(G){case"input":At($,E);break;case"textarea":Xr($,E);break;case"select":var Ae=$._wrapperState.wasMultiple;$._wrapperState.wasMultiple=!!E.multiple;var He=E.value;He!=null?cn($,!!E.multiple,He,!1):Ae!==!!E.multiple&&(E.defaultValue!=null?cn($,!!E.multiple,E.defaultValue,!0):cn($,!!E.multiple,E.multiple?[]:"",!1))}$[Bi]=E}catch(Xe){Sn(u,u.return,Xe)}}break;case 6:if(vs(h,u),lo(u),C&4){if(u.stateNode===null)throw Error(t(162));$=u.stateNode,E=u.memoizedProps;try{$.nodeValue=E}catch(Xe){Sn(u,u.return,Xe)}}break;case 3:if(vs(h,u),lo(u),C&4&&x!==null&&x.memoizedState.isDehydrated)try{Ht(h.containerInfo)}catch(Xe){Sn(u,u.return,Xe)}break;case 4:vs(h,u),lo(u);break;case 13:vs(h,u),lo(u),$=u.child,$.flags&8192&&(E=$.memoizedState!==null,$.stateNode.isHidden=E,!E||$.alternate!==null&&$.alternate.memoizedState!==null||(Jp=xn())),C&4&&jl(u);break;case 22:if(De=x!==null&&x.memoizedState!==null,u.mode&1?(wn=(we=wn)||De,vs(h,u),wn=we):vs(h,u),lo(u),C&8192){if(we=u.memoizedState!==null,(u.stateNode.isHidden=we)&&!De&&(u.mode&1)!==0)for(qe=u,De=u.child;De!==null;){for(Fe=qe=De;qe!==null;){switch(Ae=qe,He=Ae.child,Ae.tag){case 0:case 11:case 14:case 15:di(4,Ae,Ae.return);break;case 1:Gl(Ae,Ae.return);var Ke=Ae.stateNode;if(typeof Ke.componentWillUnmount=="function"){C=Ae,x=Ae.return;try{h=C,Ke.props=h.memoizedProps,Ke.state=h.memoizedState,Ke.componentWillUnmount()}catch(Xe){Sn(C,x,Xe)}}break;case 5:Gl(Ae,Ae.return);break;case 22:if(Ae.memoizedState!==null){Ki(Fe);continue}}He!==null?(He.return=Ae,qe=He):Ki(Fe)}De=De.sibling}e:for(De=null,Fe=u;;){if(Fe.tag===5){if(De===null){De=Fe;try{$=Fe.stateNode,we?(E=$.style,typeof E.setProperty=="function"?E.setProperty("display","none","important"):E.display="none"):(G=Fe.stateNode,Q=Fe.memoizedProps.style,F=Q!=null&&Q.hasOwnProperty("display")?Q.display:null,G.style.display=Jo("display",F))}catch(Xe){Sn(u,u.return,Xe)}}}else if(Fe.tag===6){if(De===null)try{Fe.stateNode.nodeValue=we?"":Fe.memoizedProps}catch(Xe){Sn(u,u.return,Xe)}}else if((Fe.tag!==22&&Fe.tag!==23||Fe.memoizedState===null||Fe===u)&&Fe.child!==null){Fe.child.return=Fe,Fe=Fe.child;continue}if(Fe===u)break e;for(;Fe.sibling===null;){if(Fe.return===null||Fe.return===u)break e;De===Fe&&(De=null),Fe=Fe.return}De===Fe&&(De=null),Fe.sibling.return=Fe.return,Fe=Fe.sibling}}break;case 19:vs(h,u),lo(u),C&4&&jl(u);break;case 21:break;default:vs(h,u),lo(u)}}function lo(u){var h=u.flags;if(h&2){try{e:{for(var x=u.return;x!==null;){if(O0(x)){var C=x;break e}x=x.return}throw Error(t(160))}switch(C.tag){case 5:var $=C.stateNode;C.flags&32&&(eo($,""),C.flags&=-33);var E=F0(u);Cd(u,E,$);break;case 3:case 4:var F=C.stateNode.containerInfo,G=F0(u);qp(u,G,F);break;default:throw Error(t(161))}}catch(Q){Sn(u,u.return,Q)}u.flags&=-3}h&4096&&(u.flags&=-4097)}function Sd(u,h,x){qe=u,Yp(u)}function Yp(u,h,x){for(var C=(u.mode&1)!==0;qe!==null;){var $=qe,E=$.child;if($.tag===22&&C){var F=$.memoizedState!==null||wd;if(!F){var G=$.alternate,Q=G!==null&&G.memoizedState!==null||wn;G=wd;var we=wn;if(wd=F,(wn=Q)&&!we)for(qe=$;qe!==null;)F=qe,Q=F.child,F.tag===22&&F.memoizedState!==null?P0($):Q!==null?(Q.return=F,qe=Q):P0($);for(;E!==null;)qe=E,Yp(E),E=E.sibling;qe=$,wd=G,wn=we}uo(u)}else($.subtreeFlags&8772)!==0&&E!==null?(E.return=$,qe=E):uo(u)}}function uo(u){for(;qe!==null;){var h=qe;if((h.flags&8772)!==0){var x=h.alternate;try{if((h.flags&8772)!==0)switch(h.tag){case 0:case 11:case 15:wn||gc(5,h);break;case 1:var C=h.stateNode;if(h.flags&4&&!wn)if(x===null)C.componentDidMount();else{var $=h.elementType===h.type?x.memoizedProps:Ms(h.type,x.memoizedProps);C.componentDidUpdate($,x.memoizedState,C.__reactInternalSnapshotBeforeUpdate)}var E=h.updateQueue;E!==null&&Cp(h,E,C);break;case 3:var F=h.updateQueue;if(F!==null){if(x=null,h.child!==null)switch(h.child.tag){case 5:x=h.child.stateNode;break;case 1:x=h.child.stateNode}Cp(h,F,x)}break;case 5:var G=h.stateNode;if(x===null&&h.flags&4){x=G;var Q=h.memoizedProps;switch(h.type){case"button":case"input":case"select":case"textarea":Q.autoFocus&&x.focus();break;case"img":Q.src&&(x.src=Q.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(h.memoizedState===null){var we=h.alternate;if(we!==null){var De=we.memoizedState;if(De!==null){var Fe=De.dehydrated;Fe!==null&&Ht(Fe)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(t(163))}wn||h.flags&512&&bd(h)}catch(Ae){Sn(h,h.return,Ae)}}if(h===u){qe=null;break}if(x=h.sibling,x!==null){x.return=h.return,qe=x;break}qe=h.return}}function Ki(u){for(;qe!==null;){var h=qe;if(h===u){qe=null;break}var x=h.sibling;if(x!==null){x.return=h.return,qe=x;break}qe=h.return}}function P0(u){for(;qe!==null;){var h=qe;try{switch(h.tag){case 0:case 11:case 15:var x=h.return;try{gc(4,h)}catch(Q){Sn(h,x,Q)}break;case 1:var C=h.stateNode;if(typeof C.componentDidMount=="function"){var $=h.return;try{C.componentDidMount()}catch(Q){Sn(h,$,Q)}}var E=h.return;try{bd(h)}catch(Q){Sn(h,E,Q)}break;case 5:var F=h.return;try{bd(h)}catch(Q){Sn(h,F,Q)}}}catch(Q){Sn(h,h.return,Q)}if(h===u){qe=null;break}var G=h.sibling;if(G!==null){G.return=h.return,qe=G;break}qe=h.return}}var L0=Math.ceil,kd=T.ReactCurrentDispatcher,Qp=T.ReactCurrentOwner,zs=T.ReactCurrentBatchConfig,Ft=0,Zn=null,Pn=null,fr=0,ws=0,Hl=Qr(0),Hn=0,xc=null,Xi=0,yc=0,Id=0,vc=null,ns=null,Jp=0,Ga=1/0,fi=null,$d=!1,Zp=null,Yi=null,Nd=!1,Qi=null,Ur=0,wc=0,em=null,Td=-1,bc=0;function Wr(){return(Ft&6)!==0?xn():Td!==-1?Td:Td=xn()}function Ji(u){return(u.mode&1)===0?1:(Ft&2)!==0&&fr!==0?fr&-fr:g0.transition!==null?(bc===0&&(bc=Kf()),bc):(u=jt,u!==0||(u=window.event,u=u===void 0?16:Wx(u.type)),u)}function co(u,h,x,C){if(50<wc)throw wc=0,em=null,Error(t(185));Fu(u,x,C),((Ft&2)===0||u!==Zn)&&(u===Zn&&((Ft&2)===0&&(yc|=x),Hn===4&&Zi(u,fr)),rs(u,C),x===1&&Ft===0&&(h.mode&1)===0&&(Ga=xn()+500,Xh&&Wi()))}function rs(u,h){var x=u.callbackNode;ew(u,h);var C=Ia(u,u===Zn?fr:0);if(C===0)x!==null&&Rx(x),u.callbackNode=null,u.callbackPriority=0;else if(h=C&-C,u.callbackPriority!==h){if(x!=null&&Rx(x),h===1)u.tag===0?Da(M0.bind(null,u)):f0(M0.bind(null,u)),jh(function(){(Ft&6)===0&&Wi()}),x=null;else{switch($a(C)){case 1:x=Hf;break;case 4:x=Ax;break;case 16:x=Du;break;case 536870912:x=qf;break;default:x=Du}x=j0(x,Ed.bind(null,u))}u.callbackPriority=h,u.callbackNode=x}}function Ed(u,h){if(Td=-1,bc=0,(Ft&6)!==0)throw Error(t(327));var x=u.callbackNode;if(ql()&&u.callbackNode!==x)return null;var C=Ia(u,u===Zn?fr:0);if(C===0)return null;if((C&30)!==0||(C&u.expiredLanes)!==0||h)h=Rd(u,C);else{h=C;var $=Ft;Ft|=2;var E=B0();(Zn!==u||fr!==h)&&(fi=null,Ga=xn()+500,Ha(u,h));do try{$w();break}catch(G){z0(u,G)}while(!0);oi(),kd.current=E,Ft=$,Pn!==null?h=0:(Zn=null,fr=0,h=Hn)}if(h!==0){if(h===2&&($=Ch(u),$!==0&&(C=$,h=tm(u,$))),h===1)throw x=xc,Ha(u,0),Zi(u,C),rs(u,xn()),x;if(h===6)Zi(u,C);else{if($=u.current.alternate,(C&30)===0&&!kw($)&&(h=Rd(u,C),h===2&&(E=Ch(u),E!==0&&(C=E,h=tm(u,E))),h===1))throw x=xc,Ha(u,0),Zi(u,C),rs(u,xn()),x;switch(u.finishedWork=$,u.finishedLanes=C,h){case 0:case 1:throw Error(t(345));case 2:qa(u,ns,fi);break;case 3:if(Zi(u,C),(C&130023424)===C&&(h=Jp+500-xn(),10<h)){if(Ia(u,0)!==0)break;if($=u.suspendedLanes,($&C)!==C){Wr(),u.pingedLanes|=u.suspendedLanes&$;break}u.timeoutHandle=Mi(qa.bind(null,u,ns,fi),h);break}qa(u,ns,fi);break;case 4:if(Zi(u,C),(C&4194240)===C)break;for(h=u.eventTimes,$=-1;0<C;){var F=31-no(C);E=1<<F,F=h[F],F>$&&($=F),C&=~E}if(C=$,C=xn()-C,C=(120>C?120:480>C?480:1080>C?1080:1920>C?1920:3e3>C?3e3:4320>C?4320:1960*L0(C/1960))-C,10<C){u.timeoutHandle=Mi(qa.bind(null,u,ns,fi),C);break}qa(u,ns,fi);break;case 5:qa(u,ns,fi);break;default:throw Error(t(329))}}}return rs(u,xn()),u.callbackNode===x?Ed.bind(null,u):null}function tm(u,h){var x=vc;return u.current.memoizedState.isDehydrated&&(Ha(u,h).flags|=256),u=Rd(u,h),u!==2&&(h=ns,ns=x,h!==null&&nm(h)),u}function nm(u){ns===null?ns=u:ns.push.apply(ns,u)}function kw(u){for(var h=u;;){if(h.flags&16384){var x=h.updateQueue;if(x!==null&&(x=x.stores,x!==null))for(var C=0;C<x.length;C++){var $=x[C],E=$.getSnapshot;$=$.value;try{if(!ve(E(),$))return!1}catch{return!1}}}if(x=h.child,h.subtreeFlags&16384&&x!==null)x.return=h,h=x;else{if(h===u)break;for(;h.sibling===null;){if(h.return===null||h.return===u)return!0;h=h.return}h.sibling.return=h.return,h=h.sibling}}return!0}function Zi(u,h){for(h&=~Id,h&=~yc,u.suspendedLanes|=h,u.pingedLanes&=~h,u=u.expirationTimes;0<h;){var x=31-no(h),C=1<<x;u[x]=-1,h&=~C}}function M0(u){if((Ft&6)!==0)throw Error(t(327));ql();var h=Ia(u,0);if((h&1)===0)return rs(u,xn()),null;var x=Rd(u,h);if(u.tag!==0&&x===2){var C=Ch(u);C!==0&&(h=C,x=tm(u,C))}if(x===1)throw x=xc,Ha(u,0),Zi(u,h),rs(u,xn()),x;if(x===6)throw Error(t(345));return u.finishedWork=u.current.alternate,u.finishedLanes=h,qa(u,ns,fi),rs(u,xn()),null}function rm(u,h){var x=Ft;Ft|=1;try{return u(h)}finally{Ft=x,Ft===0&&(Ga=xn()+500,Xh&&Wi())}}function ja(u){Qi!==null&&Qi.tag===0&&(Ft&6)===0&&ql();var h=Ft;Ft|=1;var x=zs.transition,C=jt;try{if(zs.transition=null,jt=1,u)return u()}finally{jt=C,zs.transition=x,Ft=h,(Ft&6)===0&&Wi()}}function sm(){ws=Hl.current,dn(Hl)}function Ha(u,h){u.finishedWork=null,u.finishedLanes=0;var x=u.timeoutHandle;if(x!==-1&&(u.timeoutHandle=-1,Yu(x)),Pn!==null)for(x=Pn.return;x!==null;){var C=x;switch(Pa(C),C.tag){case 1:C=C.type.childContextTypes,C!=null&&Kh();break;case 3:ji(),dn(Jr),dn(kr),od();break;case 5:sd(C);break;case 4:ji();break;case 13:dn(vn);break;case 19:dn(vn);break;case 10:ed(C.type._context);break;case 22:case 23:sm()}x=x.return}if(Zn=u,Pn=u=ho(u.current,null),fr=ws=h,Hn=0,xc=null,Id=yc=Xi=0,ns=vc=null,Ma!==null){for(h=0;h<Ma.length;h++)if(x=Ma[h],C=x.interleaved,C!==null){x.interleaved=null;var $=C.next,E=x.pending;if(E!==null){var F=E.next;E.next=$,C.next=F}x.pending=C}Ma=null}return u}function z0(u,h){do{var x=Pn;try{if(oi(),rc.current=hd,Pl){for(var C=Cn.memoizedState;C!==null;){var $=C.queue;$!==null&&($.pending=null),C=C.next}Pl=!1}if(Hi=0,jn=An=Cn=null,sc=!1,Ba=0,Qp.current=null,x===null||x.return===null){Hn=1,xc=h,Pn=null;break}e:{var E=u,F=x.return,G=x,Q=h;if(h=fr,G.flags|=32768,Q!==null&&typeof Q=="object"&&typeof Q.then=="function"){var we=Q,De=G,Fe=De.tag;if((De.mode&1)===0&&(Fe===0||Fe===11||Fe===15)){var Ae=De.alternate;Ae?(De.updateQueue=Ae.updateQueue,De.memoizedState=Ae.memoizedState,De.lanes=Ae.lanes):(De.updateQueue=null,De.memoizedState=null)}var He=N0(F);if(He!==null){He.flags&=-257,Mp(He,F,G,E,h),He.mode&1&&uc(E,we,h),h=He,Q=we;var Ke=h.updateQueue;if(Ke===null){var Xe=new Set;Xe.add(Q),h.updateQueue=Xe}else Ke.add(Q);break e}else{if((h&1)===0){uc(E,we,h),om();break e}Q=Error(t(426))}}else if(fn&&G.mode&1){var _n=N0(F);if(_n!==null){(_n.flags&65536)===0&&(_n.flags|=256),Mp(_n,F,G,E,h),Do(Va(Q,G));break e}}E=Q=Va(Q,G),Hn!==4&&(Hn=2),vc===null?vc=[E]:vc.push(E),E=F;do{switch(E.tag){case 3:E.flags|=65536,h&=-h,E.lanes|=h;var pe=lc(E,Q,h);v0(E,pe);break e;case 1:G=Q;var oe=E.type,ge=E.stateNode;if((E.flags&128)===0&&(typeof oe.getDerivedStateFromError=="function"||ge!==null&&typeof ge.componentDidCatch=="function"&&(Yi===null||!Yi.has(ge)))){E.flags|=65536,h&=-h,E.lanes|=h;var Le=gd(E,G,h);v0(E,Le);break e}}E=E.return}while(E!==null)}W0(x)}catch(Ze){h=Ze,Pn===x&&x!==null&&(Pn=x=x.return);continue}break}while(!0)}function B0(){var u=kd.current;return kd.current=hd,u===null?hd:u}function om(){(Hn===0||Hn===3||Hn===2)&&(Hn=4),Zn===null||(Xi&268435455)===0&&(yc&268435455)===0||Zi(Zn,fr)}function Rd(u,h){var x=Ft;Ft|=2;var C=B0();(Zn!==u||fr!==h)&&(fi=null,Ha(u,h));do try{Iw();break}catch($){z0(u,$)}while(!0);if(oi(),Ft=x,kd.current=C,Pn!==null)throw Error(t(261));return Zn=null,fr=0,Hn}function Iw(){for(;Pn!==null;)U0(Pn)}function $w(){for(;Pn!==null&&!vh();)U0(Pn)}function U0(u){var h=G0(u.alternate,u,ws);u.memoizedProps=u.pendingProps,h===null?W0(u):Pn=h,Qp.current=null}function W0(u){var h=u;do{var x=h.alternate;if(u=h.return,(h.flags&32768)===0){if(x=bw(x,h,ws),x!==null){Pn=x;return}}else{if(x=Cw(x,h),x!==null){x.flags&=32767,Pn=x;return}if(u!==null)u.flags|=32768,u.subtreeFlags=0,u.deletions=null;else{Hn=6,Pn=null;return}}if(h=h.sibling,h!==null){Pn=h;return}Pn=h=u}while(h!==null);Hn===0&&(Hn=5)}function qa(u,h,x){var C=jt,$=zs.transition;try{zs.transition=null,jt=1,Nw(u,h,x,C)}finally{zs.transition=$,jt=C}return null}function Nw(u,h,x,C){do ql();while(Qi!==null);if((Ft&6)!==0)throw Error(t(327));x=u.finishedWork;var $=u.finishedLanes;if(x===null)return null;if(u.finishedWork=null,u.finishedLanes=0,x===u.current)throw Error(t(177));u.callbackNode=null,u.callbackPriority=0;var E=x.lanes|x.childLanes;if(Lx(u,E),u===Zn&&(Pn=Zn=null,fr=0),(x.subtreeFlags&2064)===0&&(x.flags&2064)===0||Nd||(Nd=!0,j0(Du,function(){return ql(),null})),E=(x.flags&15990)!==0,(x.subtreeFlags&15990)!==0||E){E=zs.transition,zs.transition=null;var F=jt;jt=1;var G=Ft;Ft|=4,Qp.current=null,Sw(u,x),Xp(x,u),xw(_a),$h=!!Ku,_a=Ku=null,u.current=x,Sd(x),Qv(),Ft=G,jt=F,zs.transition=E}else u.current=x;if(Nd&&(Nd=!1,Qi=u,Ur=$),E=u.pendingLanes,E===0&&(Yi=null),Zv(x.stateNode),rs(u,xn()),h!==null)for(C=u.onRecoverableError,x=0;x<h.length;x++)$=h[x],C($.value,{componentStack:$.stack,digest:$.digest});if($d)throw $d=!1,u=Zp,Zp=null,u;return(Ur&1)!==0&&u.tag!==0&&ql(),E=u.pendingLanes,(E&1)!==0?u===em?wc++:(wc=0,em=u):wc=0,Wi(),null}function ql(){if(Qi!==null){var u=$a(Ur),h=zs.transition,x=jt;try{if(zs.transition=null,jt=16>u?16:u,Qi===null)var C=!1;else{if(u=Qi,Qi=null,Ur=0,(Ft&6)!==0)throw Error(t(331));var $=Ft;for(Ft|=4,qe=u.current;qe!==null;){var E=qe,F=E.child;if((qe.flags&16)!==0){var G=E.deletions;if(G!==null){for(var Q=0;Q<G.length;Q++){var we=G[Q];for(qe=we;qe!==null;){var De=qe;switch(De.tag){case 0:case 11:case 15:di(8,De,E)}var Fe=De.child;if(Fe!==null)Fe.return=De,qe=Fe;else for(;qe!==null;){De=qe;var Ae=De.sibling,He=De.return;if(D0(De),De===we){qe=null;break}if(Ae!==null){Ae.return=He,qe=Ae;break}qe=He}}}var Ke=E.alternate;if(Ke!==null){var Xe=Ke.child;if(Xe!==null){Ke.child=null;do{var _n=Xe.sibling;Xe.sibling=null,Xe=_n}while(Xe!==null)}}qe=E}}if((E.subtreeFlags&2064)!==0&&F!==null)F.return=E,qe=F;else e:for(;qe!==null;){if(E=qe,(E.flags&2048)!==0)switch(E.tag){case 0:case 11:case 15:di(9,E,E.return)}var pe=E.sibling;if(pe!==null){pe.return=E.return,qe=pe;break e}qe=E.return}}var oe=u.current;for(qe=oe;qe!==null;){F=qe;var ge=F.child;if((F.subtreeFlags&2064)!==0&&ge!==null)ge.return=F,qe=ge;else e:for(F=oe;qe!==null;){if(G=qe,(G.flags&2048)!==0)try{switch(G.tag){case 0:case 11:case 15:gc(9,G)}}catch(Ze){Sn(G,G.return,Ze)}if(G===F){qe=null;break e}var Le=G.sibling;if(Le!==null){Le.return=G.return,qe=Le;break e}qe=G.return}}if(Ft=$,Wi(),ko&&typeof ko.onPostCommitFiberRoot=="function")try{ko.onPostCommitFiberRoot(wh,u)}catch{}C=!0}return C}finally{jt=x,zs.transition=h}}return!1}function Ad(u,h,x){h=Va(x,h),h=lc(u,h,1),u=Ps(u,h,1),h=Wr(),u!==null&&(Fu(u,1,h),rs(u,h))}function Sn(u,h,x){if(u.tag===3)Ad(u,u,x);else for(;h!==null;){if(h.tag===3){Ad(h,u,x);break}else if(h.tag===1){var C=h.stateNode;if(typeof h.type.getDerivedStateFromError=="function"||typeof C.componentDidCatch=="function"&&(Yi===null||!Yi.has(C))){u=Va(x,u),u=gd(h,u,1),h=Ps(h,u,1),u=Wr(),h!==null&&(Fu(h,1,u),rs(h,u));break}}h=h.return}}function Tw(u,h,x){var C=u.pingCache;C!==null&&C.delete(h),h=Wr(),u.pingedLanes|=u.suspendedLanes&x,Zn===u&&(fr&x)===x&&(Hn===4||Hn===3&&(fr&130023424)===fr&&500>xn()-Jp?Ha(u,0):Id|=x),rs(u,h)}function V0(u,h){h===0&&((u.mode&1)===0?h=1:(h=bh,bh<<=1,(bh&130023424)===0&&(bh=4194304)));var x=Wr();u=ii(u,h),u!==null&&(Fu(u,h,x),rs(u,x))}function Ew(u){var h=u.memoizedState,x=0;h!==null&&(x=h.retryLane),V0(u,x)}function Rw(u,h){var x=0;switch(u.tag){case 13:var C=u.stateNode,$=u.memoizedState;$!==null&&(x=$.retryLane);break;case 19:C=u.stateNode;break;default:throw Error(t(314))}C!==null&&C.delete(h),V0(u,x)}var G0;G0=function(u,h,x){if(u!==null)if(u.memoizedProps!==h.pendingProps||Jr.current)zr=!0;else{if((u.lanes&x)===0&&(h.flags&128)===0)return zr=!1,R0(u,h,x);zr=(u.flags&131072)!==0}else zr=!1,fn&&(h.flags&1048576)!==0&&p0(h,Qh,h.index);switch(h.lanes=0,h.tag){case 2:var C=h.type;vd(u,h),u=h.pendingProps;var $=Al(h,kr.current);Gi(h,x),$=Ua(null,h,C,u,$,x);var E=id();return h.flags|=1,typeof $=="object"&&$!==null&&typeof $.render=="function"&&$.$$typeof===void 0?(h.tag=1,h.memoizedState=null,h.updateQueue=null,Zr(C)?(E=!0,As(h)):E=!1,h.memoizedState=$.state!==null&&$.state!==void 0?$.state:null,nd(h),$.updater=pd,h.stateNode=$,$._reactInternals=h,Lp(h,C,u,x),h=Gp(null,h,C,!0,E,x)):(h.tag=0,fn&&E&&Qu(h),cr(null,h,$,x),h=h.child),h;case 16:C=h.elementType;e:{switch(vd(u,h),u=h.pendingProps,$=C._init,C=$(C._payload),h.type=C,$=h.tag=_w(C),u=Ms(C,u),$){case 0:h=Wp(null,h,C,u,x);break e;case 1:h=Vp(null,h,C,u,x);break e;case 11:h=T0(null,h,C,u,x);break e;case 14:h=zp(null,h,C,Ms(C.type,u),x);break e}throw Error(t(306,C,""))}return h;case 0:return C=h.type,$=h.pendingProps,$=h.elementType===C?$:Ms(C,$),Wp(u,h,C,$,x);case 1:return C=h.type,$=h.pendingProps,$=h.elementType===C?$:Ms(C,$),Vp(u,h,C,$,x);case 3:e:{if(E0(h),u===null)throw Error(t(387));C=h.pendingProps,E=h.memoizedState,$=E.element,y0(u,h),Ol(h,C,null,x);var F=h.memoizedState;if(C=F.element,E.isDehydrated)if(E={element:C,isDehydrated:!1,cache:F.cache,pendingSuspenseBoundaries:F.pendingSuspenseBoundaries,transitions:F.transitions},h.updateQueue.baseState=E,h.memoizedState=E,h.flags&256){$=Va(Error(t(423)),h),h=Mo(u,h,C,x,$);break e}else if(C!==$){$=Va(Error(t(424)),h),h=Mo(u,h,C,x,$);break e}else for(xs=zi(h.stateNode.containerInfo.firstChild),$r=h,fn=!0,so=null,x=Zh(h,null,C,x),h.child=x;x;)x.flags=x.flags&-3|4096,x=x.sibling;else{if(_o(),C===$){h=io(u,h,x);break e}cr(u,h,C,x)}h=h.child}return h;case 5:return kp(h),u===null&&es(h),C=h.type,$=h.pendingProps,E=u!==null?u.memoizedProps:null,F=$.children,Xu(C,$)?F=null:E!==null&&Xu(C,E)&&(h.flags|=32),Up(u,h),cr(u,h,F,x),h.child;case 6:return u===null&&es(h),null;case 13:return yd(u,h,x);case 4:return Sp(h,h.stateNode.containerInfo),C=h.pendingProps,u===null?h.child=$n(h,null,C,x):cr(u,h,C,x),h.child;case 11:return C=h.type,$=h.pendingProps,$=h.elementType===C?$:Ms(C,$),T0(u,h,C,$,x);case 7:return cr(u,h,h.pendingProps,x),h.child;case 8:return cr(u,h,h.pendingProps.children,x),h.child;case 12:return cr(u,h,h.pendingProps.children,x),h.child;case 10:e:{if(C=h.type._context,$=h.pendingProps,E=h.memoizedProps,F=$.value,ln(ec,C._currentValue),C._currentValue=F,E!==null)if(ve(E.value,F)){if(E.children===$.children&&!Jr.current){h=io(u,h,x);break e}}else for(E=h.child,E!==null&&(E.return=h);E!==null;){var G=E.dependencies;if(G!==null){F=E.child;for(var Q=G.firstContext;Q!==null;){if(Q.context===C){if(E.tag===1){Q=ai(-1,x&-x),Q.tag=2;var we=E.updateQueue;if(we!==null){we=we.shared;var De=we.pending;De===null?Q.next=Q:(Q.next=De.next,De.next=Q),we.pending=Q}}E.lanes|=x,Q=E.alternate,Q!==null&&(Q.lanes|=x),ur(E.return,x,h),G.lanes|=x;break}Q=Q.next}}else if(E.tag===10)F=E.type===h.type?null:E.child;else if(E.tag===18){if(F=E.return,F===null)throw Error(t(341));F.lanes|=x,G=F.alternate,G!==null&&(G.lanes|=x),ur(F,x,h),F=E.sibling}else F=E.child;if(F!==null)F.return=E;else for(F=E;F!==null;){if(F===h){F=null;break}if(E=F.sibling,E!==null){E.return=F.return,F=E;break}F=F.return}E=F}cr(u,h,$.children,x),h=h.child}return h;case 9:return $=h.type,C=h.pendingProps.children,Gi(h,x),$=Os($),C=C($),h.flags|=1,cr(u,h,C,x),h.child;case 14:return C=h.type,$=Ms(C,h.pendingProps),$=Ms(C.type,$),zp(u,h,C,$,x);case 15:return Lo(u,h,h.type,h.pendingProps,x);case 17:return C=h.type,$=h.pendingProps,$=h.elementType===C?$:Ms(C,$),vd(u,h),h.tag=1,Zr(C)?(u=!0,As(h)):u=!1,Gi(h,x),Wa(h,C,$),Lp(h,C,$,x),Gp(null,h,C,!0,u,x);case 19:return qi(u,h,x);case 22:return Bp(u,h,x)}throw Error(t(156,h.tag))};function j0(u,h){return Ex(u,h)}function Aw(u,h,x,C){this.tag=u,this.key=x,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=h,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=C,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Bs(u,h,x,C){return new Aw(u,h,x,C)}function _d(u){return u=u.prototype,!(!u||!u.isReactComponent)}function _w(u){if(typeof u=="function")return _d(u)?1:0;if(u!=null){if(u=u.$$typeof,u===H)return 11;if(u===te)return 14}return 2}function ho(u,h){var x=u.alternate;return x===null?(x=Bs(u.tag,h,u.key,u.mode),x.elementType=u.elementType,x.type=u.type,x.stateNode=u.stateNode,x.alternate=u,u.alternate=x):(x.pendingProps=h,x.type=u.type,x.flags=0,x.subtreeFlags=0,x.deletions=null),x.flags=u.flags&14680064,x.childLanes=u.childLanes,x.lanes=u.lanes,x.child=u.child,x.memoizedProps=u.memoizedProps,x.memoizedState=u.memoizedState,x.updateQueue=u.updateQueue,h=u.dependencies,x.dependencies=h===null?null:{lanes:h.lanes,firstContext:h.firstContext},x.sibling=u.sibling,x.index=u.index,x.ref=u.ref,x}function Dd(u,h,x,C,$,E){var F=2;if(C=u,typeof u=="function")_d(u)&&(F=1);else if(typeof u=="string")F=5;else e:switch(u){case P:return Ka(x.children,$,E,h);case B:F=8,$|=8;break;case z:return u=Bs(12,x,h,$|2),u.elementType=z,u.lanes=E,u;case Y:return u=Bs(13,x,h,$),u.elementType=Y,u.lanes=E,u;case re:return u=Bs(19,x,h,$),u.elementType=re,u.lanes=E,u;case de:return Od(x,$,E,h);default:if(typeof u=="object"&&u!==null)switch(u.$$typeof){case L:F=10;break e;case _:F=9;break e;case H:F=11;break e;case te:F=14;break e;case le:F=16,C=null;break e}throw Error(t(130,u==null?u:typeof u,""))}return h=Bs(F,x,h,$),h.elementType=u,h.type=C,h.lanes=E,h}function Ka(u,h,x,C){return u=Bs(7,u,C,h),u.lanes=x,u}function Od(u,h,x,C){return u=Bs(22,u,C,h),u.elementType=de,u.lanes=x,u.stateNode={isHidden:!1},u}function im(u,h,x){return u=Bs(6,u,null,h),u.lanes=x,u}function am(u,h,x){return h=Bs(4,u.children!==null?u.children:[],u.key,h),h.lanes=x,h.stateNode={containerInfo:u.containerInfo,pendingChildren:null,implementation:u.implementation},h}function Dw(u,h,x,C,$){this.tag=h,this.containerInfo=u,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ou(0),this.expirationTimes=Ou(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ou(0),this.identifierPrefix=C,this.onRecoverableError=$,this.mutableSourceEagerHydrationData=null}function lm(u,h,x,C,$,E,F,G,Q){return u=new Dw(u,h,x,G,Q),h===1?(h=1,E===!0&&(h|=8)):h=0,E=Bs(3,null,null,h),u.current=E,E.stateNode=u,E.memoizedState={element:C,isDehydrated:x,cache:null,transitions:null,pendingSuspenseBoundaries:null},nd(E),u}function Ow(u,h,x){var C=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:O,key:C==null?null:""+C,children:u,containerInfo:h,implementation:x}}function H0(u){if(!u)return Ui;u=u._reactInternals;e:{if(ka(u)!==u||u.tag!==1)throw Error(t(170));var h=u;do{switch(h.tag){case 3:h=h.stateNode.context;break e;case 1:if(Zr(h.type)){h=h.stateNode.__reactInternalMemoizedMergedChildContext;break e}}h=h.return}while(h!==null);throw Error(t(171))}if(u.tag===1){var x=u.type;if(Zr(x))return h0(u,x,h)}return h}function q0(u,h,x,C,$,E,F,G,Q){return u=lm(x,C,!0,u,$,E,F,G,Q),u.context=H0(null),x=u.current,C=Wr(),$=Ji(x),E=ai(C,$),E.callback=h??null,Ps(x,E,$),u.current.lanes=$,Fu(u,$,C),rs(u,C),u}function Fd(u,h,x,C){var $=h.current,E=Wr(),F=Ji($);return x=H0(x),h.context===null?h.context=x:h.pendingContext=x,h=ai(E,F),h.payload={element:u},C=C===void 0?null:C,C!==null&&(h.callback=C),u=Ps($,h,F),u!==null&&(co(u,$,F,E),rd(u,$,F)),F}function Pd(u){if(u=u.current,!u.child)return null;switch(u.child.tag){case 5:return u.child.stateNode;default:return u.child.stateNode}}function K0(u,h){if(u=u.memoizedState,u!==null&&u.dehydrated!==null){var x=u.retryLane;u.retryLane=x!==0&&x<h?x:h}}function um(u,h){K0(u,h),(u=u.alternate)&&K0(u,h)}function Fw(){return null}var X0=typeof reportError=="function"?reportError:function(u){console.error(u)};function Ld(u){this._internalRoot=u}Cc.prototype.render=Ld.prototype.render=function(u){var h=this._internalRoot;if(h===null)throw Error(t(409));Fd(u,h,null,null)},Cc.prototype.unmount=Ld.prototype.unmount=function(){var u=this._internalRoot;if(u!==null){this._internalRoot=null;var h=u.containerInfo;ja(function(){Fd(null,u,null,null)}),h[gs]=null}};function Cc(u){this._internalRoot=u}Cc.prototype.unstable_scheduleHydration=function(u){if(u){var h=Yf();u={blockedOn:null,target:u,priority:h};for(var x=0;x<Di.length&&h!==0&&h<Di[x].priority;x++);Di.splice(x,0,u),x===0&&Bx(u)}};function cm(u){return!(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)}function Md(u){return!(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11&&(u.nodeType!==8||u.nodeValue!==" react-mount-point-unstable "))}function Y0(){}function Pw(u,h,x,C,$){if($){if(typeof C=="function"){var E=C;C=function(){var we=Pd(F);E.call(we)}}var F=q0(h,C,u,0,null,!1,!1,"",Y0);return u._reactRootContainer=F,u[gs]=F.current,Li(u.nodeType===8?u.parentNode:u),ja(),F}for(;$=u.lastChild;)u.removeChild($);if(typeof C=="function"){var G=C;C=function(){var we=Pd(Q);G.call(we)}}var Q=lm(u,0,!1,null,null,!1,!1,"",Y0);return u._reactRootContainer=Q,u[gs]=Q.current,Li(u.nodeType===8?u.parentNode:u),ja(function(){Fd(h,Q,x,C)}),Q}function Xa(u,h,x,C,$){var E=x._reactRootContainer;if(E){var F=E;if(typeof $=="function"){var G=$;$=function(){var Q=Pd(F);G.call(Q)}}Fd(h,F,u,$)}else F=Pw(x,h,u,$,C);return Pd(F)}Xf=function(u){switch(u.tag){case 3:var h=u.stateNode;if(h.current.memoizedState.isDehydrated){var x=fl(h.pendingLanes);x!==0&&(Pu(h,x|1),rs(h,xn()),(Ft&6)===0&&(Ga=xn()+500,Wi()))}break;case 13:ja(function(){var C=ii(u,1);if(C!==null){var $=Wr();co(C,u,1,$)}}),um(u,1)}},Sh=function(u){if(u.tag===13){var h=ii(u,134217728);if(h!==null){var x=Wr();co(h,u,134217728,x)}um(u,134217728)}},Mx=function(u){if(u.tag===13){var h=Ji(u),x=ii(u,h);if(x!==null){var C=Wr();co(x,u,h,C)}um(u,h)}},Yf=function(){return jt},Qf=function(u,h){var x=jt;try{return jt=u,h()}finally{jt=x}},Bf=function(u,h,x){switch(h){case"input":if(At(u,x),h=x.name,x.type==="radio"&&h!=null){for(x=u;x.parentNode;)x=x.parentNode;for(x=x.querySelectorAll("input[name="+JSON.stringify(""+h)+'][type="radio"]'),h=0;h<x.length;h++){var C=x[h];if(C!==u&&C.form===u.form){var $=qh(C);if(!$)throw Error(t(90));pt(C),At(C,$)}}}break;case"textarea":Xr(u,x);break;case"select":h=x.value,h!=null&&cn(u,!!x.multiple,h,!1)}},kx=rm,Uf=ja;var Lw={usingClientEntryPoint:!1,Events:[Sr,xt,qh,Cx,Sx,rm]},Sc={findFiberByHostInstance:To,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Mw={bundleType:Sc.bundleType,version:Sc.version,rendererPackageName:Sc.rendererPackageName,rendererConfig:Sc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(u){return u=Nx(u),u===null?null:u.stateNode},findFiberByHostInstance:Sc.findFiberByHostInstance||Fw,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var zd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zd.isDisabled&&zd.supportsFiber)try{wh=zd.inject(Mw),ko=zd}catch{}}return Gs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Lw,Gs.createPortal=function(u,h){var x=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!cm(h))throw Error(t(200));return Ow(u,h,null,x)},Gs.createRoot=function(u,h){if(!cm(u))throw Error(t(299));var x=!1,C="",$=X0;return h!=null&&(h.unstable_strictMode===!0&&(x=!0),h.identifierPrefix!==void 0&&(C=h.identifierPrefix),h.onRecoverableError!==void 0&&($=h.onRecoverableError)),h=lm(u,1,!1,null,null,x,!1,C,$),u[gs]=h.current,Li(u.nodeType===8?u.parentNode:u),new Ld(h)},Gs.findDOMNode=function(u){if(u==null)return null;if(u.nodeType===1)return u;var h=u._reactInternals;if(h===void 0)throw typeof u.render=="function"?Error(t(188)):(u=Object.keys(u).join(","),Error(t(268,u)));return u=Nx(h),u=u===null?null:u.stateNode,u},Gs.flushSync=function(u){return ja(u)},Gs.hydrate=function(u,h,x){if(!Md(h))throw Error(t(200));return Xa(null,u,h,!0,x)},Gs.hydrateRoot=function(u,h,x){if(!cm(u))throw Error(t(405));var C=x!=null&&x.hydratedSources||null,$=!1,E="",F=X0;if(x!=null&&(x.unstable_strictMode===!0&&($=!0),x.identifierPrefix!==void 0&&(E=x.identifierPrefix),x.onRecoverableError!==void 0&&(F=x.onRecoverableError)),h=q0(h,null,u,1,x??null,$,!1,E,F),u[gs]=h.current,Li(u),C)for(u=0;u<C.length;u++)x=C[u],$=x._getVersion,$=$(x._source),h.mutableSourceEagerHydrationData==null?h.mutableSourceEagerHydrationData=[x,$]:h.mutableSourceEagerHydrationData.push(x,$);return new Cc(h)},Gs.render=function(u,h,x){if(!Md(h))throw Error(t(200));return Xa(null,u,h,!1,x)},Gs.unmountComponentAtNode=function(u){if(!Md(u))throw Error(t(40));return u._reactRootContainer?(ja(function(){Xa(null,null,u,!1,function(){u._reactRootContainer=null,u[gs]=null})}),!0):!1},Gs.unstable_batchedUpdates=rm,Gs.unstable_renderSubtreeIntoContainer=function(u,h,x,C){if(!Md(x))throw Error(t(200));if(u==null||u._reactInternals===void 0)throw Error(t(38));return Xa(u,h,x,!1,C)},Gs.version="18.3.1-next-f1338f8080-20240426",Gs}var C$;function yT(){if(C$)return Zw.exports;C$=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),Zw.exports=B3(),Zw.exports}var S$;function U3(){if(S$)return ty;S$=1;var n=yT();return ty.createRoot=n.createRoot,ty.hydrateRoot=n.hydrateRoot,ty}var W3=U3(),nb={exports:{}},rb={};var k$;function V3(){if(k$)return rb;k$=1;var n=Xm();function e(p,m){return p===m&&(p!==0||1/p===1/m)||p!==p&&m!==m}var t=typeof Object.is=="function"?Object.is:e,r=n.useState,s=n.useEffect,o=n.useLayoutEffect,i=n.useDebugValue;function a(p,m){var y=m(),v=r({inst:{value:y,getSnapshot:m}}),b=v[0].inst,w=v[1];return o(function(){b.value=y,b.getSnapshot=m,l(b)&&w({inst:b})},[p,y,m]),s(function(){return l(b)&&w({inst:b}),p(function(){l(b)&&w({inst:b})})},[p]),i(y),y}function l(p){var m=p.getSnapshot;p=p.value;try{var y=m();return!t(p,y)}catch{return!0}}function c(p,m){return m()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return rb.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:d,rb}var I$;function vT(){return I$||(I$=1,nb.exports=V3()),nb.exports}var G3=vT(),sb={exports:{}},ob={};var $$;function j3(){if($$)return ob;$$=1;var n=Xm(),e=vT();function t(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var r=typeof Object.is=="function"?Object.is:t,s=e.useSyncExternalStore,o=n.useRef,i=n.useEffect,a=n.useMemo,l=n.useDebugValue;return ob.useSyncExternalStoreWithSelector=function(c,d,p,m,y){var v=o(null);if(v.current===null){var b={hasValue:!1,value:null};v.current=b}else b=v.current;v=a(function(){function k(O){if(!I){if(I=!0,N=O,O=m(O),y!==void 0&&b.hasValue){var P=b.value;if(y(P,O))return T=P}return T=O}if(P=T,r(N,O))return P;var B=m(O);return y!==void 0&&y(P,B)?(N=O,P):(N=O,T=B)}var I=!1,N,T,A=p===void 0?null:p;return[function(){return k(d())},A===null?void 0:function(){return k(A())}]},[d,p,m,y]);var w=s(c,v[0],v[1]);return i(function(){b.hasValue=!0,b.value=w},[w]),l(w),w},ob}var N$;function H3(){return N$||(N$=1,sb.exports=j3()),sb.exports}H3();var wT=yT();const q3=xf(wT);function K3(n){n()}let bT=K3;const X3=n=>bT=n,Y3=()=>bT,T$=Symbol.for("react-redux-context"),E$=typeof globalThis<"u"?globalThis:{};function Q3(){var n;if(!Re.createContext)return{};const e=(n=E$[T$])!=null?n:E$[T$]=new Map;let t=e.get(Re.createContext);return t||(t=Re.createContext(null),e.set(Re.createContext,t)),t}const CT=Q3(),J3=()=>{throw new Error("uSES not initialized!")};function Kd(){return Kd=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Kd.apply(null,arguments)}function ST(n,e){if(n==null)return{};var t={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(e.indexOf(r)!==-1)continue;t[r]=n[r]}return t}var ib={exports:{}},tn={};var R$;function Z3(){if(R$)return tn;R$=1;var n=typeof Symbol=="function"&&Symbol.for,e=n?Symbol.for("react.element"):60103,t=n?Symbol.for("react.portal"):60106,r=n?Symbol.for("react.fragment"):60107,s=n?Symbol.for("react.strict_mode"):60108,o=n?Symbol.for("react.profiler"):60114,i=n?Symbol.for("react.provider"):60109,a=n?Symbol.for("react.context"):60110,l=n?Symbol.for("react.async_mode"):60111,c=n?Symbol.for("react.concurrent_mode"):60111,d=n?Symbol.for("react.forward_ref"):60112,p=n?Symbol.for("react.suspense"):60113,m=n?Symbol.for("react.suspense_list"):60120,y=n?Symbol.for("react.memo"):60115,v=n?Symbol.for("react.lazy"):60116,b=n?Symbol.for("react.block"):60121,w=n?Symbol.for("react.fundamental"):60117,k=n?Symbol.for("react.responder"):60118,I=n?Symbol.for("react.scope"):60119;function N(A){if(typeof A=="object"&&A!==null){var O=A.$$typeof;switch(O){case e:switch(A=A.type,A){case l:case c:case r:case o:case s:case p:return A;default:switch(A=A&&A.$$typeof,A){case a:case d:case v:case y:case i:return A;default:return O}}case t:return O}}}function T(A){return N(A)===c}return tn.AsyncMode=l,tn.ConcurrentMode=c,tn.ContextConsumer=a,tn.ContextProvider=i,tn.Element=e,tn.ForwardRef=d,tn.Fragment=r,tn.Lazy=v,tn.Memo=y,tn.Portal=t,tn.Profiler=o,tn.StrictMode=s,tn.Suspense=p,tn.isAsyncMode=function(A){return T(A)||N(A)===l},tn.isConcurrentMode=T,tn.isContextConsumer=function(A){return N(A)===a},tn.isContextProvider=function(A){return N(A)===i},tn.isElement=function(A){return typeof A=="object"&&A!==null&&A.$$typeof===e},tn.isForwardRef=function(A){return N(A)===d},tn.isFragment=function(A){return N(A)===r},tn.isLazy=function(A){return N(A)===v},tn.isMemo=function(A){return N(A)===y},tn.isPortal=function(A){return N(A)===t},tn.isProfiler=function(A){return N(A)===o},tn.isStrictMode=function(A){return N(A)===s},tn.isSuspense=function(A){return N(A)===p},tn.isValidElementType=function(A){return typeof A=="string"||typeof A=="function"||A===r||A===c||A===o||A===s||A===p||A===m||typeof A=="object"&&A!==null&&(A.$$typeof===v||A.$$typeof===y||A.$$typeof===i||A.$$typeof===a||A.$$typeof===d||A.$$typeof===w||A.$$typeof===k||A.$$typeof===I||A.$$typeof===b)},tn.typeOf=N,tn}var A$;function eM(){return A$||(A$=1,ib.exports=Z3()),ib.exports}var ab,_$;function tM(){if(_$)return ab;_$=1;var n=eM(),e={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},t={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},r={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},s={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},o={};o[n.ForwardRef]=r,o[n.Memo]=s;function i(v){return n.isMemo(v)?s:o[v.$$typeof]||e}var a=Object.defineProperty,l=Object.getOwnPropertyNames,c=Object.getOwnPropertySymbols,d=Object.getOwnPropertyDescriptor,p=Object.getPrototypeOf,m=Object.prototype;function y(v,b,w){if(typeof b!="string"){if(m){var k=p(b);k&&k!==m&&y(v,k,w)}var I=l(b);c&&(I=I.concat(c(b)));for(var N=i(v),T=i(b),A=0;A<I.length;++A){var O=I[A];if(!t[O]&&!(w&&w[O])&&!(T&&T[O])&&!(N&&N[O])){var P=d(b,O);try{a(v,O,P)}catch{}}}}return v}return ab=y,ab}var nM=tM();const D$=xf(nM);var lb={exports:{}},nn={};var O$;function rM(){if(O$)return nn;O$=1;var n=Symbol.for("react.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),i=Symbol.for("react.context"),a=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen"),v;v=Symbol.for("react.module.reference");function b(w){if(typeof w=="object"&&w!==null){var k=w.$$typeof;switch(k){case n:switch(w=w.type,w){case t:case s:case r:case c:case d:return w;default:switch(w=w&&w.$$typeof,w){case a:case i:case l:case m:case p:case o:return w;default:return k}}case e:return k}}}return nn.ContextConsumer=i,nn.ContextProvider=o,nn.Element=n,nn.ForwardRef=l,nn.Fragment=t,nn.Lazy=m,nn.Memo=p,nn.Portal=e,nn.Profiler=s,nn.StrictMode=r,nn.Suspense=c,nn.SuspenseList=d,nn.isAsyncMode=function(){return!1},nn.isConcurrentMode=function(){return!1},nn.isContextConsumer=function(w){return b(w)===i},nn.isContextProvider=function(w){return b(w)===o},nn.isElement=function(w){return typeof w=="object"&&w!==null&&w.$$typeof===n},nn.isForwardRef=function(w){return b(w)===l},nn.isFragment=function(w){return b(w)===t},nn.isLazy=function(w){return b(w)===m},nn.isMemo=function(w){return b(w)===p},nn.isPortal=function(w){return b(w)===e},nn.isProfiler=function(w){return b(w)===s},nn.isStrictMode=function(w){return b(w)===r},nn.isSuspense=function(w){return b(w)===c},nn.isSuspenseList=function(w){return b(w)===d},nn.isValidElementType=function(w){return typeof w=="string"||typeof w=="function"||w===t||w===s||w===r||w===c||w===d||w===y||typeof w=="object"&&w!==null&&(w.$$typeof===m||w.$$typeof===p||w.$$typeof===o||w.$$typeof===i||w.$$typeof===l||w.$$typeof===v||w.getModuleId!==void 0)},nn.typeOf=b,nn}var F$;function sM(){return F$||(F$=1,lb.exports=rM()),lb.exports}var oM=sM();const iM=["initMapStateToProps","initMapDispatchToProps","initMergeProps"];function aM(n,e,t,r,{areStatesEqual:s,areOwnPropsEqual:o,areStatePropsEqual:i}){let a=!1,l,c,d,p,m;function y(I,N){return l=I,c=N,d=n(l,c),p=e(r,c),m=t(d,p,c),a=!0,m}function v(){return d=n(l,c),e.dependsOnOwnProps&&(p=e(r,c)),m=t(d,p,c),m}function b(){return n.dependsOnOwnProps&&(d=n(l,c)),e.dependsOnOwnProps&&(p=e(r,c)),m=t(d,p,c),m}function w(){const I=n(l,c),N=!i(I,d);return d=I,N&&(m=t(d,p,c)),m}function k(I,N){const T=!o(N,c),A=!s(I,l,N,c);return l=I,c=N,T&&A?v():T?b():A?w():m}return function(N,T){return a?k(N,T):y(N,T)}}function lM(n,e){let{initMapStateToProps:t,initMapDispatchToProps:r,initMergeProps:s}=e,o=ST(e,iM);const i=t(n,o),a=r(n,o),l=s(n,o);return aM(i,a,l,n,o)}function uM(n,e){const t={};for(const r in n){const s=n[r];typeof s=="function"&&(t[r]=(...o)=>e(s(...o)))}return t}function jb(n){return function(t){const r=n(t);function s(){return r}return s.dependsOnOwnProps=!1,s}}function P$(n){return n.dependsOnOwnProps?!!n.dependsOnOwnProps:n.length!==1}function kT(n,e){return function(r,{displayName:s}){const o=function(a,l){return o.dependsOnOwnProps?o.mapToProps(a,l):o.mapToProps(a,void 0)};return o.dependsOnOwnProps=!0,o.mapToProps=function(a,l){o.mapToProps=n,o.dependsOnOwnProps=P$(n);let c=o(a,l);return typeof c=="function"&&(o.mapToProps=c,o.dependsOnOwnProps=P$(c),c=o(a,l)),c},o}}function IT(n,e){return(t,r)=>{throw new Error(`Invalid value of type ${typeof n} for ${e} argument when connecting component ${r.wrappedComponentName}.`)}}function cM(n){return n&&typeof n=="object"?jb(e=>uM(n,e)):n?typeof n=="function"?kT(n):IT(n,"mapDispatchToProps"):jb(e=>({dispatch:e}))}function hM(n){return n?typeof n=="function"?kT(n):IT(n,"mapStateToProps"):jb(()=>({}))}function dM(n,e,t){return Kd({},t,n,e)}function fM(n){return()=>dM}function pM(){const n=Y3();let e=null,t=null;return{clear(){e=null,t=null},notify(){n(()=>{let r=e;for(;r;)r.callback(),r=r.next})},get(){let r=[],s=e;for(;s;)r.push(s),s=s.next;return r},subscribe(r){let s=!0,o=t={callback:r,next:null,prev:t};return o.prev?o.prev.next=o:e=o,function(){!s||e===null||(s=!1,o.next?o.next.prev=o.prev:t=o.prev,o.prev?o.prev.next=o.next:e=o.next)}}}}const L$={notify(){},get:()=>[]};function $T(n,e){let t,r=L$,s=0,o=!1;function i(b){d();const w=r.subscribe(b);let k=!1;return()=>{k||(k=!0,w(),p())}}function a(){r.notify()}function l(){v.onStateChange&&v.onStateChange()}function c(){return o}function d(){s++,t||(t=e?e.addNestedSub(l):n.subscribe(l),r=pM())}function p(){s--,t&&s===0&&(t(),t=void 0,r.clear(),r=L$)}function m(){o||(o=!0,d())}function y(){o&&(o=!1,p())}const v={addNestedSub:i,notifyNestedSubs:a,handleChangeWrapper:l,isSubscribed:c,trySubscribe:m,tryUnsubscribe:y,getListeners:()=>r};return v}const mM=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ty=mM?Re.useLayoutEffect:Re.useEffect;function M$(n,e){return n===e?n!==0||e!==0||1/n===1/e:n!==n&&e!==e}function ub(n,e){if(M$(n,e))return!0;if(typeof n!="object"||n===null||typeof e!="object"||e===null)return!1;const t=Object.keys(n),r=Object.keys(e);if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(!Object.prototype.hasOwnProperty.call(e,t[s])||!M$(n[t[s]],e[t[s]]))return!1;return!0}const gM=["reactReduxForwardedRef"];let NT=J3;const xM=n=>{NT=n},yM=[null,null];function vM(n,e,t){Ty(()=>n(...e),t)}function wM(n,e,t,r,s,o){n.current=r,t.current=!1,s.current&&(s.current=null,o())}function bM(n,e,t,r,s,o,i,a,l,c,d){if(!n)return()=>{};let p=!1,m=null;const y=()=>{if(p||!a.current)return;const b=e.getState();let w,k;try{w=r(b,s.current)}catch(I){k=I,m=I}k||(m=null),w===o.current?i.current||c():(o.current=w,l.current=w,i.current=!0,d())};return t.onStateChange=y,t.trySubscribe(),y(),()=>{if(p=!0,t.tryUnsubscribe(),t.onStateChange=null,m)throw m}}function CM(n,e){return n===e}function oh(n,e,t,{pure:r,areStatesEqual:s=CM,areOwnPropsEqual:o=ub,areStatePropsEqual:i=ub,areMergedPropsEqual:a=ub,forwardRef:l=!1,context:c=CT}={}){const d=c,p=hM(n),m=cM(e),y=fM(),v=!!n;return w=>{const k=w.displayName||w.name||"Component",I=`Connect(${k})`,N={shouldHandleStateChanges:v,displayName:I,wrappedComponentName:k,WrappedComponent:w,initMapStateToProps:p,initMapDispatchToProps:m,initMergeProps:y,areStatesEqual:s,areStatePropsEqual:i,areOwnPropsEqual:o,areMergedPropsEqual:a};function T(P){const[B,z,L]=Re.useMemo(()=>{const{reactReduxForwardedRef:pt}=P,bt=ST(P,gM);return[P.context,pt,bt]},[P]),_=Re.useMemo(()=>B&&B.Consumer&&oM.isContextConsumer(Re.createElement(B.Consumer,null))?B:d,[B,d]),H=Re.useContext(_),Y=!!P.store&&!!P.store.getState&&!!P.store.dispatch,re=!!H&&!!H.store,te=Y?P.store:H.store,le=re?H.getServerState:te.getState,de=Re.useMemo(()=>lM(te.dispatch,N),[te]),[j,ie]=Re.useMemo(()=>{if(!v)return yM;const pt=$T(te,Y?void 0:H.subscription),bt=pt.notifyNestedSubs.bind(pt);return[pt,bt]},[te,Y,H]),se=Re.useMemo(()=>Y?H:Kd({},H,{subscription:j}),[Y,H,j]),V=Re.useRef(),X=Re.useRef(L),xe=Re.useRef(),Ie=Re.useRef(!1);Re.useRef(!1);const ke=Re.useRef(!1),Ee=Re.useRef();Ty(()=>(ke.current=!0,()=>{ke.current=!1}),[]);const Me=Re.useMemo(()=>()=>xe.current&&L===X.current?xe.current:de(te.getState(),L),[te,L]),ze=Re.useMemo(()=>bt=>j?bM(v,te,j,de,X,V,Ie,ke,xe,ie,bt):()=>{},[j]);vM(wM,[X,V,Ie,L,xe,ie]);let Be;try{Be=NT(ze,Me,le?()=>de(le(),L):Me)}catch(pt){throw Ee.current&&(pt.message+=`
The error may be correlated with this previous error:
${Ee.current.stack}
`),pt}Ty(()=>{Ee.current=void 0,xe.current=void 0,V.current=Be});const Je=Re.useMemo(()=>Re.createElement(w,Kd({},Be,{ref:z})),[z,w,Be]);return Re.useMemo(()=>v?Re.createElement(_.Provider,{value:se},Je):Je,[_,Je,se])}const O=Re.memo(T);if(O.WrappedComponent=w,O.displayName=T.displayName=I,l){const B=Re.forwardRef(function(L,_){return Re.createElement(O,Kd({},L,{reactReduxForwardedRef:_}))});return B.displayName=I,B.WrappedComponent=w,D$(B,w)}return D$(O,w)}}function SM({store:n,context:e,children:t,serverState:r,stabilityCheck:s="once",noopCheck:o="once"}){const i=Re.useMemo(()=>{const c=$T(n);return{store:n,subscription:c,getServerState:r?()=>r:void 0,stabilityCheck:s,noopCheck:o}},[n,r,s,o]),a=Re.useMemo(()=>n.getState(),[n]);Ty(()=>{const{subscription:c}=i;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),a!==n.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[i,a]);const l=e||CT;return Re.createElement(l.Provider,{value:i},t)}xM(G3.useSyncExternalStore);X3(wT.unstable_batchedUpdates);function Em(n){"@babel/helpers - typeof";return Em=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Em(n)}function kM(n,e){if(Em(n)!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(Em(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function IM(n){var e=kM(n,"string");return Em(e)=="symbol"?e:e+""}function $M(n,e,t){return(e=IM(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function z$(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),t.push.apply(t,r)}return t}function B$(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?z$(Object(t),!0).forEach(function(r){$M(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):z$(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function ss(n){return"Minified Redux error #"+n+"; visit https://redux.js.org/Errors?code="+n+" for the full message or use the non-minified dev environment for full errors. "}var U$=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})(),cb=function(){return Math.random().toString(36).substring(7).split("").join(".")},Ey={INIT:"@@redux/INIT"+cb(),REPLACE:"@@redux/REPLACE"+cb(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+cb()}};function NM(n){if(typeof n!="object"||n===null)return!1;for(var e=n;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(n)===e}function TT(n,e,t){var r;if(typeof e=="function"&&typeof t=="function"||typeof t=="function"&&typeof arguments[3]=="function")throw new Error(ss(0));if(typeof e=="function"&&typeof t>"u"&&(t=e,e=void 0),typeof t<"u"){if(typeof t!="function")throw new Error(ss(1));return t(TT)(n,e)}if(typeof n!="function")throw new Error(ss(2));var s=n,o=e,i=[],a=i,l=!1;function c(){a===i&&(a=i.slice())}function d(){if(l)throw new Error(ss(3));return o}function p(b){if(typeof b!="function")throw new Error(ss(4));if(l)throw new Error(ss(5));var w=!0;return c(),a.push(b),function(){if(w){if(l)throw new Error(ss(6));w=!1,c();var I=a.indexOf(b);a.splice(I,1),i=null}}}function m(b){if(!NM(b))throw new Error(ss(7));if(typeof b.type>"u")throw new Error(ss(8));if(l)throw new Error(ss(9));try{l=!0,o=s(o,b)}finally{l=!1}for(var w=i=a,k=0;k<w.length;k++){var I=w[k];I()}return b}function y(b){if(typeof b!="function")throw new Error(ss(10));s=b,m({type:Ey.REPLACE})}function v(){var b,w=p;return b={subscribe:function(I){if(typeof I!="object"||I===null)throw new Error(ss(11));function N(){I.next&&I.next(d())}N();var T=w(N);return{unsubscribe:T}}},b[U$]=function(){return this},b}return m({type:Ey.INIT}),r={dispatch:m,subscribe:p,getState:d,replaceReducer:y},r[U$]=v,r}function TM(n){Object.keys(n).forEach(function(e){var t=n[e],r=t(void 0,{type:Ey.INIT});if(typeof r>"u")throw new Error(ss(12));if(typeof t(void 0,{type:Ey.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(ss(13))})}function ET(n){for(var e=Object.keys(n),t={},r=0;r<e.length;r++){var s=e[r];typeof n[s]=="function"&&(t[s]=n[s])}var o=Object.keys(t),i;try{TM(t)}catch(a){i=a}return function(l,c){if(l===void 0&&(l={}),i)throw i;for(var d=!1,p={},m=0;m<o.length;m++){var y=o[m],v=t[y],b=l[y],w=v(b,c);if(typeof w>"u")throw c&&c.type,new Error(ss(14));p[y]=w,d=d||w!==b}return d=d||o.length!==Object.keys(l).length,d?p:l}}function Rm(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return e.length===0?function(r){return r}:e.length===1?e[0]:e.reduce(function(r,s){return function(){return r(s.apply(void 0,arguments))}})}function RT(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return function(r){return function(){var s=r.apply(void 0,arguments),o=function(){throw new Error(ss(15))},i={getState:s.getState,dispatch:function(){return o.apply(void 0,arguments)}},a=e.map(function(l){return l(i)});return o=Rm.apply(void 0,a)(s.dispatch),B$(B$({},s),{},{dispatch:o})}}}function wi(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];throw Error("[Immer] minified error nr: "+n+(t.length?" "+t.map((function(s){return"'"+s+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function Bc(n){return!!n&&!!n[Nn]}function Uc(n){var e;return!!n&&((function(t){if(!t||typeof t!="object")return!1;var r=Object.getPrototypeOf(t);if(r===null)return!0;var s=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return s===Object||typeof s=="function"&&Function.toString.call(s)===LM})(n)||Array.isArray(n)||!!n[K$]||!!(!((e=n.constructor)===null||e===void 0)&&e[K$])||YC(n)||QC(n))}function Wc(n,e,t){t===void 0&&(t=!1),yf(n)===0?(t?Object.keys:Yd)(n).forEach((function(r){t&&typeof r=="symbol"||e(r,n[r],n)})):n.forEach((function(r,s){return e(s,r,n)}))}function yf(n){var e=n[Nn];return e?e.i>3?e.i-4:e.i:Array.isArray(n)?1:YC(n)?2:QC(n)?3:0}function Xd(n,e){return yf(n)===2?n.has(e):Object.prototype.hasOwnProperty.call(n,e)}function EM(n,e){return yf(n)===2?n.get(e):n[e]}function AT(n,e,t){var r=yf(n);r===2?n.set(e,t):r===3?n.add(t):n[e]=t}function _T(n,e){return n===e?n!==0||1/n==1/e:n!=n&&e!=e}function YC(n){return FM&&n instanceof Map}function QC(n){return PM&&n instanceof Set}function Tc(n){return n.o||n.t}function JC(n){if(Array.isArray(n))return Array.prototype.slice.call(n);var e=OT(n);delete e[Nn];for(var t=Yd(e),r=0;r<t.length;r++){var s=t[r],o=e[s];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(e[s]={configurable:!0,writable:!0,enumerable:o.enumerable,value:n[s]})}return Object.create(Object.getPrototypeOf(n),e)}function ZC(n,e){return e===void 0&&(e=!1),eS(n)||Bc(n)||!Uc(n)||(yf(n)>1&&(n.set=n.add=n.clear=n.delete=RM),Object.freeze(n),e&&Wc(n,(function(t,r){return ZC(r,!0)}),!0)),n}function RM(){wi(2)}function eS(n){return n==null||typeof n!="object"||Object.isFrozen(n)}function ua(n){var e=Xb[n];return e||wi(18,n),e}function AM(n,e){Xb[n]||(Xb[n]=e)}function Hb(){return Am}function hb(n,e){e&&(ua("Patches"),n.u=[],n.s=[],n.v=e)}function Ry(n){qb(n),n.p.forEach(_M),n.p=null}function qb(n){n===Am&&(Am=n.l)}function W$(n){return Am={p:[],l:Am,h:n,m:!0,_:0}}function _M(n){var e=n[Nn];e.i===0||e.i===1?e.j():e.g=!0}function db(n,e){e._=e.p.length;var t=e.p[0],r=n!==void 0&&n!==t;return e.h.O||ua("ES5").S(e,n,r),r?(t[Nn].P&&(Ry(e),wi(4)),Uc(n)&&(n=Ay(e,n),e.l||_y(e,n)),e.u&&ua("Patches").M(t[Nn].t,n,e.u,e.s)):n=Ay(e,t,[]),Ry(e),e.u&&e.v(e.u,e.s),n!==DT?n:void 0}function Ay(n,e,t){if(eS(e))return e;var r=e[Nn];if(!r)return Wc(e,(function(a,l){return V$(n,r,e,a,l,t)}),!0),e;if(r.A!==n)return e;if(!r.P)return _y(n,r.t,!0),r.t;if(!r.I){r.I=!0,r.A._--;var s=r.i===4||r.i===5?r.o=JC(r.k):r.o,o=s,i=!1;r.i===3&&(o=new Set(s),s.clear(),i=!0),Wc(o,(function(a,l){return V$(n,r,s,a,l,t,i)})),_y(n,s,!1),t&&n.u&&ua("Patches").N(r,t,n.u,n.s)}return r.o}function V$(n,e,t,r,s,o,i){if(Bc(s)){var a=Ay(n,s,o&&e&&e.i!==3&&!Xd(e.R,r)?o.concat(r):void 0);if(AT(t,r,a),!Bc(a))return;n.m=!1}else i&&t.add(s);if(Uc(s)&&!eS(s)){if(!n.h.D&&n._<1)return;Ay(n,s),e&&e.A.l||_y(n,s)}}function _y(n,e,t){t===void 0&&(t=!1),!n.l&&n.h.D&&n.m&&ZC(e,t)}function fb(n,e){var t=n[Nn];return(t?Tc(t):n)[e]}function G$(n,e){if(e in n)for(var t=Object.getPrototypeOf(n);t;){var r=Object.getOwnPropertyDescriptor(t,e);if(r)return r;t=Object.getPrototypeOf(t)}}function Ql(n){n.P||(n.P=!0,n.l&&Ql(n.l))}function pb(n){n.o||(n.o=JC(n.t))}function Kb(n,e,t){var r=YC(e)?ua("MapSet").F(e,t):QC(e)?ua("MapSet").T(e,t):n.O?(function(s,o){var i=Array.isArray(s),a={i:i?1:0,A:o?o.A:Hb(),P:!1,I:!1,R:{},l:o,t:s,k:null,o:null,j:null,C:!1},l=a,c=_m;i&&(l=[a],c=ym);var d=Proxy.revocable(l,c),p=d.revoke,m=d.proxy;return a.k=m,a.j=p,m})(e,t):ua("ES5").J(e,t);return(t?t.A:Hb()).p.push(r),r}function DM(n){return Bc(n)||wi(22,n),(function e(t){if(!Uc(t))return t;var r,s=t[Nn],o=yf(t);if(s){if(!s.P&&(s.i<4||!ua("ES5").K(s)))return s.t;s.I=!0,r=j$(t,o),s.I=!1}else r=j$(t,o);return Wc(r,(function(i,a){s&&EM(s.t,i)===a||AT(r,i,e(a))})),o===3?new Set(r):r})(n)}function j$(n,e){switch(e){case 2:return new Map(n);case 3:return Array.from(n)}return JC(n)}function OM(){function n(o,i){var a=s[o];return a?a.enumerable=i:s[o]=a={configurable:!0,enumerable:i,get:function(){var l=this[Nn];return _m.get(l,o)},set:function(l){var c=this[Nn];_m.set(c,o,l)}},a}function e(o){for(var i=o.length-1;i>=0;i--){var a=o[i][Nn];if(!a.P)switch(a.i){case 5:r(a)&&Ql(a);break;case 4:t(a)&&Ql(a)}}}function t(o){for(var i=o.t,a=o.k,l=Yd(a),c=l.length-1;c>=0;c--){var d=l[c];if(d!==Nn){var p=i[d];if(p===void 0&&!Xd(i,d))return!0;var m=a[d],y=m&&m[Nn];if(y?y.t!==p:!_T(m,p))return!0}}var v=!!i[Nn];return l.length!==Yd(i).length+(v?0:1)}function r(o){var i=o.k;if(i.length!==o.t.length)return!0;var a=Object.getOwnPropertyDescriptor(i,i.length-1);if(a&&!a.get)return!0;for(var l=0;l<i.length;l++)if(!i.hasOwnProperty(l))return!0;return!1}var s={};AM("ES5",{J:function(o,i){var a=Array.isArray(o),l=(function(d,p){if(d){for(var m=Array(p.length),y=0;y<p.length;y++)Object.defineProperty(m,""+y,n(y,!0));return m}var v=OT(p);delete v[Nn];for(var b=Yd(v),w=0;w<b.length;w++){var k=b[w];v[k]=n(k,d||!!v[k].enumerable)}return Object.create(Object.getPrototypeOf(p),v)})(a,o),c={i:a?5:4,A:i?i.A:Hb(),P:!1,I:!1,R:{},l:i,t:o,k:l,o:null,g:!1,C:!1};return Object.defineProperty(l,Nn,{value:c,writable:!0}),l},S:function(o,i,a){a?Bc(i)&&i[Nn].A===o&&e(o.p):(o.u&&(function l(c){if(c&&typeof c=="object"){var d=c[Nn];if(d){var p=d.t,m=d.k,y=d.R,v=d.i;if(v===4)Wc(m,(function(N){N!==Nn&&(p[N]!==void 0||Xd(p,N)?y[N]||l(m[N]):(y[N]=!0,Ql(d)))})),Wc(p,(function(N){m[N]!==void 0||Xd(m,N)||(y[N]=!1,Ql(d))}));else if(v===5){if(r(d)&&(Ql(d),y.length=!0),m.length<p.length)for(var b=m.length;b<p.length;b++)y[b]=!1;else for(var w=p.length;w<m.length;w++)y[w]=!0;for(var k=Math.min(m.length,p.length),I=0;I<k;I++)m.hasOwnProperty(I)||(y[I]=!0),y[I]===void 0&&l(m[I])}}}})(o.p[0]),e(o.p))},K:function(o){return o.i===4?t(o):r(o)}})}var H$,Am,tS=typeof Symbol<"u"&&typeof Symbol("x")=="symbol",FM=typeof Map<"u",PM=typeof Set<"u",q$=typeof Proxy<"u"&&Proxy.revocable!==void 0&&typeof Reflect<"u",DT=tS?Symbol.for("immer-nothing"):((H$={})["immer-nothing"]=!0,H$),K$=tS?Symbol.for("immer-draftable"):"__$immer_draftable",Nn=tS?Symbol.for("immer-state"):"__$immer_state",LM=""+Object.prototype.constructor,Yd=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols!==void 0?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames,OT=Object.getOwnPropertyDescriptors||function(n){var e={};return Yd(n).forEach((function(t){e[t]=Object.getOwnPropertyDescriptor(n,t)})),e},Xb={},_m={get:function(n,e){if(e===Nn)return n;var t=Tc(n);if(!Xd(t,e))return(function(s,o,i){var a,l=G$(o,i);return l?"value"in l?l.value:(a=l.get)===null||a===void 0?void 0:a.call(s.k):void 0})(n,t,e);var r=t[e];return n.I||!Uc(r)?r:r===fb(n.t,e)?(pb(n),n.o[e]=Kb(n.A.h,r,n)):r},has:function(n,e){return e in Tc(n)},ownKeys:function(n){return Reflect.ownKeys(Tc(n))},set:function(n,e,t){var r=G$(Tc(n),e);if(r?.set)return r.set.call(n.k,t),!0;if(!n.P){var s=fb(Tc(n),e),o=s?.[Nn];if(o&&o.t===t)return n.o[e]=t,n.R[e]=!1,!0;if(_T(t,s)&&(t!==void 0||Xd(n.t,e)))return!0;pb(n),Ql(n)}return n.o[e]===t&&(t!==void 0||e in n.o)||Number.isNaN(t)&&Number.isNaN(n.o[e])||(n.o[e]=t,n.R[e]=!0),!0},deleteProperty:function(n,e){return fb(n.t,e)!==void 0||e in n.t?(n.R[e]=!1,pb(n),Ql(n)):delete n.R[e],n.o&&delete n.o[e],!0},getOwnPropertyDescriptor:function(n,e){var t=Tc(n),r=Reflect.getOwnPropertyDescriptor(t,e);return r&&{writable:!0,configurable:n.i!==1||e!=="length",enumerable:r.enumerable,value:t[e]}},defineProperty:function(){wi(11)},getPrototypeOf:function(n){return Object.getPrototypeOf(n.t)},setPrototypeOf:function(){wi(12)}},ym={};Wc(_m,(function(n,e){ym[n]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}})),ym.deleteProperty=function(n,e){return ym.set.call(this,n,e,void 0)},ym.set=function(n,e,t){return _m.set.call(this,n[0],e,t,n[0])};var MM=(function(){function n(t){var r=this;this.O=q$,this.D=!0,this.produce=function(s,o,i){if(typeof s=="function"&&typeof o!="function"){var a=o;o=s;var l=r;return function(b){var w=this;b===void 0&&(b=a);for(var k=arguments.length,I=Array(k>1?k-1:0),N=1;N<k;N++)I[N-1]=arguments[N];return l.produce(b,(function(T){var A;return(A=o).call.apply(A,[w,T].concat(I))}))}}var c;if(typeof o!="function"&&wi(6),i!==void 0&&typeof i!="function"&&wi(7),Uc(s)){var d=W$(r),p=Kb(r,s,void 0),m=!0;try{c=o(p),m=!1}finally{m?Ry(d):qb(d)}return typeof Promise<"u"&&c instanceof Promise?c.then((function(b){return hb(d,i),db(b,d)}),(function(b){throw Ry(d),b})):(hb(d,i),db(c,d))}if(!s||typeof s!="object"){if((c=o(s))===void 0&&(c=s),c===DT&&(c=void 0),r.D&&ZC(c,!0),i){var y=[],v=[];ua("Patches").M(s,c,y,v),i(y,v)}return c}wi(21,s)},this.produceWithPatches=function(s,o){if(typeof s=="function")return function(c){for(var d=arguments.length,p=Array(d>1?d-1:0),m=1;m<d;m++)p[m-1]=arguments[m];return r.produceWithPatches(c,(function(y){return s.apply(void 0,[y].concat(p))}))};var i,a,l=r.produce(s,o,(function(c,d){i=c,a=d}));return typeof Promise<"u"&&l instanceof Promise?l.then((function(c){return[c,i,a]})):[l,i,a]},typeof t?.useProxies=="boolean"&&this.setUseProxies(t.useProxies),typeof t?.autoFreeze=="boolean"&&this.setAutoFreeze(t.autoFreeze)}var e=n.prototype;return e.createDraft=function(t){Uc(t)||wi(8),Bc(t)&&(t=DM(t));var r=W$(this),s=Kb(this,t,void 0);return s[Nn].C=!0,qb(r),s},e.finishDraft=function(t,r){var s=t&&t[Nn],o=s.A;return hb(o,r),db(void 0,o)},e.setAutoFreeze=function(t){this.D=t},e.setUseProxies=function(t){t&&!q$&&wi(20),this.O=t},e.applyPatches=function(t,r){var s;for(s=r.length-1;s>=0;s--){var o=r[s];if(o.path.length===0&&o.op==="replace"){t=o.value;break}}s>-1&&(r=r.slice(s+1));var i=ua("Patches").$;return Bc(t)?i(t,r):this.produce(t,(function(a){return i(a,r)}))},n})(),vo=new MM;vo.produce;vo.produceWithPatches.bind(vo);vo.setAutoFreeze.bind(vo);vo.setUseProxies.bind(vo);vo.applyPatches.bind(vo);vo.createDraft.bind(vo);vo.finishDraft.bind(vo);function FT(n){var e=function(r){var s=r.dispatch,o=r.getState;return function(i){return function(a){return typeof a=="function"?a(s,o,n):i(a)}}};return e}var Dy=FT();Dy.withExtraArgument=FT;var PT=(function(){var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},n(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");n(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}})(),zM=function(n,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,s,o,i;return i={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(c){return function(d){return l([c,d])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;t;)try{if(r=1,s&&(o=c[0]&2?s.return:c[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,c[1])).done)return o;switch(s=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,s=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){t.label=c[1];break}if(c[0]===6&&t.label<o[1]){t.label=o[1],o=c;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(c);break}o[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(n,t)}catch(d){c=[6,d],s=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},Dm=function(n,e){for(var t=0,r=e.length,s=n.length;t<r;t++,s++)n[s]=e[t];return n},BM=Object.defineProperty,UM=Object.defineProperties,WM=Object.getOwnPropertyDescriptors,X$=Object.getOwnPropertySymbols,VM=Object.prototype.hasOwnProperty,GM=Object.prototype.propertyIsEnumerable,Y$=function(n,e,t){return e in n?BM(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t},Qd=function(n,e){for(var t in e||(e={}))VM.call(e,t)&&Y$(n,t,e[t]);if(X$)for(var r=0,s=X$(e);r<s.length;r++){var t=s[r];GM.call(e,t)&&Y$(n,t,e[t])}return n},mb=function(n,e){return UM(n,WM(e))},jM=function(n,e,t){return new Promise(function(r,s){var o=function(l){try{a(t.next(l))}catch(c){s(c)}},i=function(l){try{a(t.throw(l))}catch(c){s(c)}},a=function(l){return l.done?r(l.value):Promise.resolve(l.value).then(o,i)};a((t=t.apply(n,e)).next())})},HM=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Rm:Rm.apply(null,arguments)};function qM(n){if(typeof n!="object"||n===null)return!1;var e=Object.getPrototypeOf(n);if(e===null)return!0;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return e===t}function Jd(n,e){function t(){for(var r=[],s=0;s<arguments.length;s++)r[s]=arguments[s];if(e){var o=e.apply(void 0,r);if(!o)throw new Error("prepareAction did not return an object");return Qd(Qd({type:n,payload:o.payload},"meta"in o&&{meta:o.meta}),"error"in o&&{error:o.error})}return{type:n,payload:r[0]}}return t.toString=function(){return""+n},t.type=n,t.match=function(r){return r.type===n},t}var KM=(function(n){PT(e,n);function e(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var s=n.apply(this,t)||this;return Object.setPrototypeOf(s,e.prototype),s}return Object.defineProperty(e,Symbol.species,{get:function(){return e},enumerable:!1,configurable:!0}),e.prototype.concat=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return n.prototype.concat.apply(this,t)},e.prototype.prepend=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return t.length===1&&Array.isArray(t[0])?new(e.bind.apply(e,Dm([void 0],t[0].concat(this)))):new(e.bind.apply(e,Dm([void 0],t.concat(this))))},e})(Array),XM=(function(n){PT(e,n);function e(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var s=n.apply(this,t)||this;return Object.setPrototypeOf(s,e.prototype),s}return Object.defineProperty(e,Symbol.species,{get:function(){return e},enumerable:!1,configurable:!0}),e.prototype.concat=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return n.prototype.concat.apply(this,t)},e.prototype.prepend=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return t.length===1&&Array.isArray(t[0])?new(e.bind.apply(e,Dm([void 0],t[0].concat(this)))):new(e.bind.apply(e,Dm([void 0],t.concat(this))))},e})(Array);function YM(n){return typeof n=="boolean"}function QM(){return function(e){return JM(e)}}function JM(n){n===void 0&&(n={});var e=n.thunk,t=e===void 0?!0:e;n.immutableCheck,n.serializableCheck,n.actionCreatorCheck;var r=new KM;return t&&(YM(t)?r.push(Dy):r.push(Dy.withExtraArgument(t.extraArgument))),r}function ZM(n){var e=QM(),t=n||{},r=t.reducer,s=r===void 0?void 0:r,o=t.middleware,i=o===void 0?e():o,a=t.devTools,l=a===void 0?!0:a,c=t.preloadedState,d=c===void 0?void 0:c,p=t.enhancers,m=p===void 0?void 0:p,y;if(typeof s=="function")y=s;else if(qM(s))y=ET(s);else throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');var v=i;typeof v=="function"&&(v=v(e));var b=RT.apply(void 0,v),w=Rm;l&&(w=HM(Qd({trace:!1},typeof l=="object"&&l)));var k=new XM(b),I=k;Array.isArray(m)?I=Dm([b],m):typeof m=="function"&&(I=m(k));var N=w.apply(void 0,I);return TT(y,d,N)}var ez="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",tz=function(n){n===void 0&&(n=21);for(var e="",t=n;t--;)e+=ez[Math.random()*64|0];return e},nz=["name","message","stack","code"],gb=(function(){function n(e,t){this.payload=e,this.meta=t}return n})(),Q$=(function(){function n(e,t){this.payload=e,this.meta=t}return n})(),rz=function(n){if(typeof n=="object"&&n!==null){for(var e={},t=0,r=nz;t<r.length;t++){var s=r[t];typeof n[s]=="string"&&(e[s]=n[s])}return e}return{message:String(n)}};(function(){function n(e,t,r){var s=Jd(e+"/fulfilled",function(c,d,p,m){return{payload:c,meta:mb(Qd({},m||{}),{arg:p,requestId:d,requestStatus:"fulfilled"})}}),o=Jd(e+"/pending",function(c,d,p){return{payload:void 0,meta:mb(Qd({},p||{}),{arg:d,requestId:c,requestStatus:"pending"})}}),i=Jd(e+"/rejected",function(c,d,p,m,y){return{payload:m,error:(r&&r.serializeError||rz)(c||"Rejected"),meta:mb(Qd({},y||{}),{arg:p,requestId:d,rejectedWithValue:!!m,requestStatus:"rejected",aborted:c?.name==="AbortError",condition:c?.name==="ConditionError"})}}),a=typeof AbortController<"u"?AbortController:(function(){function c(){this.signal={aborted:!1,addEventListener:function(){},dispatchEvent:function(){return!1},onabort:function(){},removeEventListener:function(){},reason:void 0,throwIfAborted:function(){}}}return c.prototype.abort=function(){},c})();function l(c){return function(d,p,m){var y=r?.idGenerator?r.idGenerator(c):tz(),v=new a,b;function w(I){b=I,v.abort()}var k=(function(){return jM(this,null,function(){var I,N,T,A,O,P,B;return zM(this,function(z){switch(z.label){case 0:return z.trys.push([0,4,,5]),A=(I=r?.condition)==null?void 0:I.call(r,c,{getState:p,extra:m}),oz(A)?[4,A]:[3,2];case 1:A=z.sent(),z.label=2;case 2:if(A===!1||v.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};return O=new Promise(function(L,_){return v.signal.addEventListener("abort",function(){return _({name:"AbortError",message:b||"Aborted"})})}),d(o(y,c,(N=r?.getPendingMeta)==null?void 0:N.call(r,{requestId:y,arg:c},{getState:p,extra:m}))),[4,Promise.race([O,Promise.resolve(t(c,{dispatch:d,getState:p,extra:m,requestId:y,signal:v.signal,abort:w,rejectWithValue:function(L,_){return new gb(L,_)},fulfillWithValue:function(L,_){return new Q$(L,_)}})).then(function(L){if(L instanceof gb)throw L;return L instanceof Q$?s(L.payload,y,c,L.meta):s(L,y,c)})])];case 3:return T=z.sent(),[3,5];case 4:return P=z.sent(),T=P instanceof gb?i(null,y,c,P.payload,P.meta):i(P,y,c),[3,5];case 5:return B=r&&!r.dispatchConditionRejection&&i.match(T)&&T.meta.condition,B||d(T),[2,T]}})})})();return Object.assign(k,{abort:w,requestId:y,arg:c,unwrap:function(){return k.then(sz)}})}}return Object.assign(l,{pending:o,rejected:i,fulfilled:s,typePrefix:e})}return n.withTypes=function(){return n},n})();function sz(n){if(n.meta&&n.meta.rejectedWithValue)throw n.payload;if(n.error)throw n.error;return n.payload}function oz(n){return n!==null&&typeof n=="object"&&typeof n.then=="function"}var nS="listenerMiddleware";Jd(nS+"/add");Jd(nS+"/removeAll");Jd(nS+"/remove");var J$;typeof queueMicrotask=="function"&&queueMicrotask.bind(typeof window<"u"?window:typeof global<"u"?global:globalThis);OM();function Om(){return Om=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Om.apply(this,arguments)}var Jl;(function(n){n.Pop="POP",n.Push="PUSH",n.Replace="REPLACE"})(Jl||(Jl={}));const Z$="popstate";function iz(n){n===void 0&&(n={});function e(r,s){let{pathname:o,search:i,hash:a}=r.location;return Yb("",{pathname:o,search:i,hash:a},s.state&&s.state.usr||null,s.state&&s.state.key||"default")}function t(r,s){return typeof s=="string"?s:Oy(s)}return lz(e,t,null,n)}function sr(n,e){if(n===!1||n===null||typeof n>"u")throw new Error(e)}function rS(n,e){if(!n){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function az(){return Math.random().toString(36).substr(2,8)}function eN(n,e){return{usr:n.state,key:n.key,idx:e}}function Yb(n,e,t,r){return t===void 0&&(t=null),Om({pathname:typeof n=="string"?n:n.pathname,search:"",hash:""},typeof e=="string"?vf(e):e,{state:t,key:e&&e.key||r||az()})}function Oy(n){let{pathname:e="/",search:t="",hash:r=""}=n;return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function vf(n){let e={};if(n){let t=n.indexOf("#");t>=0&&(e.hash=n.substr(t),n=n.substr(0,t));let r=n.indexOf("?");r>=0&&(e.search=n.substr(r),n=n.substr(0,r)),n&&(e.pathname=n)}return e}function lz(n,e,t,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:o=!1}=r,i=s.history,a=Jl.Pop,l=null,c=d();c==null&&(c=0,i.replaceState(Om({},i.state,{idx:c}),""));function d(){return(i.state||{idx:null}).idx}function p(){a=Jl.Pop;let w=d(),k=w==null?null:w-c;c=w,l&&l({action:a,location:b.location,delta:k})}function m(w,k){a=Jl.Push;let I=Yb(b.location,w,k);c=d()+1;let N=eN(I,c),T=b.createHref(I);try{i.pushState(N,"",T)}catch(A){if(A instanceof DOMException&&A.name==="DataCloneError")throw A;s.location.assign(T)}o&&l&&l({action:a,location:b.location,delta:1})}function y(w,k){a=Jl.Replace;let I=Yb(b.location,w,k);c=d();let N=eN(I,c),T=b.createHref(I);i.replaceState(N,"",T),o&&l&&l({action:a,location:b.location,delta:0})}function v(w){let k=s.location.origin!=="null"?s.location.origin:s.location.href,I=typeof w=="string"?w:Oy(w);return I=I.replace(/ $/,"%20"),sr(k,"No window.location.(origin|href) available to create URL for href: "+I),new URL(I,k)}let b={get action(){return a},get location(){return n(s,i)},listen(w){if(l)throw new Error("A history only accepts one active listener");return s.addEventListener(Z$,p),l=w,()=>{s.removeEventListener(Z$,p),l=null}},createHref(w){return e(s,w)},createURL:v,encodeLocation(w){let k=v(w);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:m,replace:y,go(w){return i.go(w)}};return b}var tN;(function(n){n.data="data",n.deferred="deferred",n.redirect="redirect",n.error="error"})(tN||(tN={}));function uz(n,e,t){return t===void 0&&(t="/"),cz(n,e,t)}function cz(n,e,t,r){let s=typeof e=="string"?vf(e):e,o=sS(s.pathname||"/",t);if(o==null)return null;let i=LT(n);hz(i);let a=null;for(let l=0;a==null&&l<i.length;++l){let c=Sz(o);a=wz(i[l],c)}return a}function LT(n,e,t,r){e===void 0&&(e=[]),t===void 0&&(t=[]),r===void 0&&(r="");let s=(o,i,a)=>{let l={relativePath:a===void 0?o.path||"":a,caseSensitive:o.caseSensitive===!0,childrenIndex:i,route:o};l.relativePath.startsWith("/")&&(sr(l.relativePath.startsWith(r),'Absolute route path "'+l.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),l.relativePath=l.relativePath.slice(r.length));let c=nu([r,l.relativePath]),d=t.concat(l);o.children&&o.children.length>0&&(sr(o.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+c+'".')),LT(o.children,e,d,c)),!(o.path==null&&!o.index)&&e.push({path:c,score:yz(c,o.index),routesMeta:d})};return n.forEach((o,i)=>{var a;if(o.path===""||!((a=o.path)!=null&&a.includes("?")))s(o,i);else for(let l of MT(o.path))s(o,i,l)}),e}function MT(n){let e=n.split("/");if(e.length===0)return[];let[t,...r]=e,s=t.endsWith("?"),o=t.replace(/\?$/,"");if(r.length===0)return s?[o,""]:[o];let i=MT(r.join("/")),a=[];return a.push(...i.map(l=>l===""?o:[o,l].join("/"))),s&&a.push(...i),a.map(l=>n.startsWith("/")&&l===""?"/":l)}function hz(n){n.sort((e,t)=>e.score!==t.score?t.score-e.score:vz(e.routesMeta.map(r=>r.childrenIndex),t.routesMeta.map(r=>r.childrenIndex)))}const dz=/^:[\w-]+$/,fz=3,pz=2,mz=1,gz=10,xz=-2,nN=n=>n==="*";function yz(n,e){let t=n.split("/"),r=t.length;return t.some(nN)&&(r+=xz),e&&(r+=pz),t.filter(s=>!nN(s)).reduce((s,o)=>s+(dz.test(o)?fz:o===""?mz:gz),r)}function vz(n,e){return n.length===e.length&&n.slice(0,-1).every((r,s)=>r===e[s])?n[n.length-1]-e[e.length-1]:0}function wz(n,e,t){let{routesMeta:r}=n,s={},o="/",i=[];for(let a=0;a<r.length;++a){let l=r[a],c=a===r.length-1,d=o==="/"?e:e.slice(o.length)||"/",p=bz({path:l.relativePath,caseSensitive:l.caseSensitive,end:c},d),m=l.route;if(!p)return null;Object.assign(s,p.params),i.push({params:s,pathname:nu([o,p.pathname]),pathnameBase:Tz(nu([o,p.pathnameBase])),route:m}),p.pathnameBase!=="/"&&(o=nu([o,p.pathnameBase]))}return i}function bz(n,e){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[t,r]=Cz(n.path,n.caseSensitive,n.end),s=e.match(t);if(!s)return null;let o=s[0],i=o.replace(/(.)\/+$/,"$1"),a=s.slice(1);return{params:r.reduce((c,d,p)=>{let{paramName:m,isOptional:y}=d;if(m==="*"){let b=a[p]||"";i=o.slice(0,o.length-b.length).replace(/(.)\/+$/,"$1")}const v=a[p];return y&&!v?c[m]=void 0:c[m]=(v||"").replace(/%2F/g,"/"),c},{}),pathname:o,pathnameBase:i,pattern:n}}function Cz(n,e,t){e===void 0&&(e=!1),t===void 0&&(t=!0),rS(n==="*"||!n.endsWith("*")||n.endsWith("/*"),'Route path "'+n+'" will be treated as if it were '+('"'+n.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+n.replace(/\*$/,"/*")+'".'));let r=[],s="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,a,l)=>(r.push({paramName:a,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)"));return n.endsWith("*")?(r.push({paramName:"*"}),s+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):t?s+="\\/*$":n!==""&&n!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,e?void 0:"i"),r]}function Sz(n){try{return n.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return rS(!1,'The URL path "'+n+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+e+").")),n}}function sS(n,e){if(e==="/")return n;if(!n.toLowerCase().startsWith(e.toLowerCase()))return null;let t=e.endsWith("/")?e.length-1:e.length,r=n.charAt(t);return r&&r!=="/"?null:n.slice(t)||"/"}const kz=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Iz=n=>kz.test(n);function $z(n,e){e===void 0&&(e="/");let{pathname:t,search:r="",hash:s=""}=typeof n=="string"?vf(n):n,o;if(t)if(Iz(t))o=t;else{if(t.includes("//")){let i=t;t=t.replace(/\/\/+/g,"/"),rS(!1,"Pathnames cannot have embedded double slashes - normalizing "+(i+" -> "+t))}t.startsWith("/")?o=rN(t.substring(1),"/"):o=rN(t,e)}else o=e;return{pathname:o,search:Ez(r),hash:Rz(s)}}function rN(n,e){let t=e.replace(/\/+$/,"").split("/");return n.split("/").forEach(s=>{s===".."?t.length>1&&t.pop():s!=="."&&t.push(s)}),t.length>1?t.join("/"):"/"}function xb(n,e,t,r){return"Cannot include a '"+n+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+t+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function Nz(n){return n.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function zT(n,e){let t=Nz(n);return e?t.map((r,s)=>s===t.length-1?r.pathname:r.pathnameBase):t.map(r=>r.pathnameBase)}function BT(n,e,t,r){r===void 0&&(r=!1);let s;typeof n=="string"?s=vf(n):(s=Om({},n),sr(!s.pathname||!s.pathname.includes("?"),xb("?","pathname","search",s)),sr(!s.pathname||!s.pathname.includes("#"),xb("#","pathname","hash",s)),sr(!s.search||!s.search.includes("#"),xb("#","search","hash",s)));let o=n===""||s.pathname==="",i=o?"/":s.pathname,a;if(i==null)a=t;else{let p=e.length-1;if(!r&&i.startsWith("..")){let m=i.split("/");for(;m[0]==="..";)m.shift(),p-=1;s.pathname=m.join("/")}a=p>=0?e[p]:"/"}let l=$z(s,a),c=i&&i!=="/"&&i.endsWith("/"),d=(o||i===".")&&t.endsWith("/");return!l.pathname.endsWith("/")&&(c||d)&&(l.pathname+="/"),l}const nu=n=>n.join("/").replace(/\/\/+/g,"/"),Tz=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),Ez=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,Rz=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n;function Az(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.internal=="boolean"&&"data"in n}const UT=["post","put","patch","delete"];new Set(UT);const _z=["get",...UT];new Set(_z);function Fm(){return Fm=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Fm.apply(this,arguments)}const oS=Re.createContext(null),Dz=Re.createContext(null),ih=Re.createContext(null),d1=Re.createContext(null),fu=Re.createContext({outlet:null,matches:[],isDataRoute:!1}),WT=Re.createContext(null);function Oz(n,e){let{relative:t}=e===void 0?{}:e;Ym()||sr(!1);let{basename:r,navigator:s}=Re.useContext(ih),{hash:o,pathname:i,search:a}=GT(n,{relative:t}),l=i;return r!=="/"&&(l=i==="/"?r:nu([r,i])),s.createHref({pathname:l,search:a,hash:o})}function Ym(){return Re.useContext(d1)!=null}function f1(){return Ym()||sr(!1),Re.useContext(d1).location}function VT(n){Re.useContext(ih).static||Re.useLayoutEffect(n)}function Fz(){let{isDataRoute:n}=Re.useContext(fu);return n?Xz():Pz()}function Pz(){Ym()||sr(!1);let n=Re.useContext(oS),{basename:e,future:t,navigator:r}=Re.useContext(ih),{matches:s}=Re.useContext(fu),{pathname:o}=f1(),i=JSON.stringify(zT(s,t.v7_relativeSplatPath)),a=Re.useRef(!1);return VT(()=>{a.current=!0}),Re.useCallback(function(c,d){if(d===void 0&&(d={}),!a.current)return;if(typeof c=="number"){r.go(c);return}let p=BT(c,JSON.parse(i),o,d.relative==="path");n==null&&e!=="/"&&(p.pathname=p.pathname==="/"?e:nu([e,p.pathname])),(d.replace?r.replace:r.push)(p,d.state,d)},[e,r,i,o,n])}function Lz(){let{matches:n}=Re.useContext(fu),e=n[n.length-1];return e?e.params:{}}function GT(n,e){let{relative:t}=e===void 0?{}:e,{future:r}=Re.useContext(ih),{matches:s}=Re.useContext(fu),{pathname:o}=f1(),i=JSON.stringify(zT(s,r.v7_relativeSplatPath));return Re.useMemo(()=>BT(n,JSON.parse(i),o,t==="path"),[n,i,o,t])}function Mz(n,e){return zz(n,e)}function zz(n,e,t,r){Ym()||sr(!1);let{navigator:s}=Re.useContext(ih),{matches:o}=Re.useContext(fu),i=o[o.length-1],a=i?i.params:{};i&&i.pathname;let l=i?i.pathnameBase:"/";i&&i.route;let c=f1(),d;if(e){var p;let w=typeof e=="string"?vf(e):e;l==="/"||(p=w.pathname)!=null&&p.startsWith(l)||sr(!1),d=w}else d=c;let m=d.pathname||"/",y=m;if(l!=="/"){let w=l.replace(/^\//,"").split("/");y="/"+m.replace(/^\//,"").split("/").slice(w.length).join("/")}let v=uz(n,{pathname:y}),b=Gz(v&&v.map(w=>Object.assign({},w,{params:Object.assign({},a,w.params),pathname:nu([l,s.encodeLocation?s.encodeLocation(w.pathname).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?l:nu([l,s.encodeLocation?s.encodeLocation(w.pathnameBase).pathname:w.pathnameBase])})),o,t,r);return e&&b?Re.createElement(d1.Provider,{value:{location:Fm({pathname:"/",search:"",hash:"",state:null,key:"default"},d),navigationType:Jl.Pop}},b):b}function Bz(){let n=Kz(),e=Az(n)?n.status+" "+n.statusText:n instanceof Error?n.message:JSON.stringify(n),t=n instanceof Error?n.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return Re.createElement(Re.Fragment,null,Re.createElement("h2",null,"Unexpected Application Error!"),Re.createElement("h3",{style:{fontStyle:"italic"}},e),t?Re.createElement("pre",{style:s},t):null,null)}const Uz=Re.createElement(Bz,null);class Wz extends Re.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){console.error("React Router caught the following error during render",e,t)}render(){return this.state.error!==void 0?Re.createElement(fu.Provider,{value:this.props.routeContext},Re.createElement(WT.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Vz(n){let{routeContext:e,match:t,children:r}=n,s=Re.useContext(oS);return s&&s.static&&s.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=t.route.id),Re.createElement(fu.Provider,{value:e},r)}function Gz(n,e,t,r){var s;if(e===void 0&&(e=[]),t===void 0&&(t=null),r===void 0&&(r=null),n==null){var o;if(!t)return null;if(t.errors)n=t.matches;else if((o=r)!=null&&o.v7_partialHydration&&e.length===0&&!t.initialized&&t.matches.length>0)n=t.matches;else return null}let i=n,a=(s=t)==null?void 0:s.errors;if(a!=null){let d=i.findIndex(p=>p.route.id&&a?.[p.route.id]!==void 0);d>=0||sr(!1),i=i.slice(0,Math.min(i.length,d+1))}let l=!1,c=-1;if(t&&r&&r.v7_partialHydration)for(let d=0;d<i.length;d++){let p=i[d];if((p.route.HydrateFallback||p.route.hydrateFallbackElement)&&(c=d),p.route.id){let{loaderData:m,errors:y}=t,v=p.route.loader&&m[p.route.id]===void 0&&(!y||y[p.route.id]===void 0);if(p.route.lazy||v){l=!0,c>=0?i=i.slice(0,c+1):i=[i[0]];break}}}return i.reduceRight((d,p,m)=>{let y,v=!1,b=null,w=null;t&&(y=a&&p.route.id?a[p.route.id]:void 0,b=p.route.errorElement||Uz,l&&(c<0&&m===0?(Yz("route-fallback"),v=!0,w=null):c===m&&(v=!0,w=p.route.hydrateFallbackElement||null)));let k=e.concat(i.slice(0,m+1)),I=()=>{let N;return y?N=b:v?N=w:p.route.Component?N=Re.createElement(p.route.Component,null):p.route.element?N=p.route.element:N=d,Re.createElement(Vz,{match:p,routeContext:{outlet:d,matches:k,isDataRoute:t!=null},children:N})};return t&&(p.route.ErrorBoundary||p.route.errorElement||m===0)?Re.createElement(Wz,{location:t.location,revalidation:t.revalidation,component:b,error:y,children:I(),routeContext:{outlet:null,matches:k,isDataRoute:!0}}):I()},null)}var jT=(function(n){return n.UseBlocker="useBlocker",n.UseRevalidator="useRevalidator",n.UseNavigateStable="useNavigate",n})(jT||{}),HT=(function(n){return n.UseBlocker="useBlocker",n.UseLoaderData="useLoaderData",n.UseActionData="useActionData",n.UseRouteError="useRouteError",n.UseNavigation="useNavigation",n.UseRouteLoaderData="useRouteLoaderData",n.UseMatches="useMatches",n.UseRevalidator="useRevalidator",n.UseNavigateStable="useNavigate",n.UseRouteId="useRouteId",n})(HT||{});function jz(n){let e=Re.useContext(oS);return e||sr(!1),e}function Hz(n){let e=Re.useContext(Dz);return e||sr(!1),e}function qz(n){let e=Re.useContext(fu);return e||sr(!1),e}function qT(n){let e=qz(),t=e.matches[e.matches.length-1];return t.route.id||sr(!1),t.route.id}function Kz(){var n;let e=Re.useContext(WT),t=Hz(),r=qT();return e!==void 0?e:(n=t.errors)==null?void 0:n[r]}function Xz(){let{router:n}=jz(jT.UseNavigateStable),e=qT(HT.UseNavigateStable),t=Re.useRef(!1);return VT(()=>{t.current=!0}),Re.useCallback(function(s,o){o===void 0&&(o={}),t.current&&(typeof s=="number"?n.navigate(s):n.navigate(s,Fm({fromRouteId:e},o)))},[n,e])}const sN={};function Yz(n,e,t){sN[n]||(sN[n]=!0)}function Qz(n,e){n?.v7_startTransition,n?.v7_relativeSplatPath}function Xl(n){sr(!1)}function Jz(n){let{basename:e="/",children:t=null,location:r,navigationType:s=Jl.Pop,navigator:o,static:i=!1,future:a}=n;Ym()&&sr(!1);let l=e.replace(/^\/*/,"/"),c=Re.useMemo(()=>({basename:l,navigator:o,static:i,future:Fm({v7_relativeSplatPath:!1},a)}),[l,a,o,i]);typeof r=="string"&&(r=vf(r));let{pathname:d="/",search:p="",hash:m="",state:y=null,key:v="default"}=r,b=Re.useMemo(()=>{let w=sS(d,l);return w==null?null:{location:{pathname:w,search:p,hash:m,state:y,key:v},navigationType:s}},[l,d,p,m,y,v,s]);return b==null?null:Re.createElement(ih.Provider,{value:c},Re.createElement(d1.Provider,{children:t,value:b}))}function Zz(n){let{children:e,location:t}=n;return Mz(Qb(e),t)}new Promise(()=>{});function Qb(n,e){e===void 0&&(e=[]);let t=[];return Re.Children.forEach(n,(r,s)=>{if(!Re.isValidElement(r))return;let o=[...e,s];if(r.type===Re.Fragment){t.push.apply(t,Qb(r.props.children,o));return}r.type!==Xl&&sr(!1),!r.props.index||!r.props.children||sr(!1);let i={id:r.props.id||o.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(i.children=Qb(r.props.children,o)),t.push(i)}),t}function Jb(){return Jb=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},Jb.apply(this,arguments)}function eB(n,e){if(n==null)return{};var t={},r=Object.keys(n),s,o;for(o=0;o<r.length;o++)s=r[o],!(e.indexOf(s)>=0)&&(t[s]=n[s]);return t}function tB(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function nB(n,e){return n.button===0&&(!e||e==="_self")&&!tB(n)}const rB=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],sB="6";try{window.__reactRouterVersion=sB}catch{}const oB="startTransition",oN=L3[oB];function iB(n){let{basename:e,children:t,future:r,window:s}=n,o=Re.useRef();o.current==null&&(o.current=iz({window:s,v5Compat:!0}));let i=o.current,[a,l]=Re.useState({action:i.action,location:i.location}),{v7_startTransition:c}=r||{},d=Re.useCallback(p=>{c&&oN?oN(()=>l(p)):l(p)},[l,c]);return Re.useLayoutEffect(()=>i.listen(d),[i,d]),Re.useEffect(()=>Qz(r),[r]),Re.createElement(Jz,{basename:e,children:t,location:a.location,navigationType:a.action,navigator:i,future:r})}const aB=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",lB=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,aa=Re.forwardRef(function(e,t){let{onClick:r,relative:s,reloadDocument:o,replace:i,state:a,target:l,to:c,preventScrollReset:d,viewTransition:p}=e,m=eB(e,rB),{basename:y}=Re.useContext(ih),v,b=!1;if(typeof c=="string"&&lB.test(c)&&(v=c,aB))try{let N=new URL(window.location.href),T=c.startsWith("//")?new URL(N.protocol+c):new URL(c),A=sS(T.pathname,y);T.origin===N.origin&&A!=null?c=A+T.search+T.hash:b=!0}catch{}let w=Oz(c,{relative:s}),k=uB(c,{replace:i,state:a,target:l,preventScrollReset:d,relative:s,viewTransition:p});function I(N){r&&r(N),N.defaultPrevented||k(N)}return Re.createElement("a",Jb({},m,{href:v||w,onClick:b||o?r:I,ref:t,target:l}))});var iN;(function(n){n.UseScrollRestoration="useScrollRestoration",n.UseSubmit="useSubmit",n.UseSubmitFetcher="useSubmitFetcher",n.UseFetcher="useFetcher",n.useViewTransitionState="useViewTransitionState"})(iN||(iN={}));var aN;(function(n){n.UseFetcher="useFetcher",n.UseFetchers="useFetchers",n.UseScrollRestoration="useScrollRestoration"})(aN||(aN={}));function uB(n,e){let{target:t,replace:r,state:s,preventScrollReset:o,relative:i,viewTransition:a}=e===void 0?{}:e,l=Fz(),c=f1(),d=GT(n,{relative:i});return Re.useCallback(p=>{if(nB(p,t)){p.preventDefault();let m=r!==void 0?r:Oy(c)===Oy(d);l(n,{replace:m,state:s,preventScrollReset:o,relative:i,viewTransition:a})}},[c,l,d,r,s,t,n,o,i,a])}function KT(n,e){return function(){return n.apply(e,arguments)}}const{toString:cB}=Object.prototype,{getPrototypeOf:iS}=Object,{iterator:p1,toStringTag:XT}=Symbol,m1=(n=>e=>{const t=cB.call(e);return n[t]||(n[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Ti=n=>(n=n.toLowerCase(),e=>m1(e)===n),g1=n=>e=>typeof e===n,{isArray:wf}=Array,sf=g1("undefined");function Qm(n){return n!==null&&!sf(n)&&n.constructor!==null&&!sf(n.constructor)&&Ks(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const YT=Ti("ArrayBuffer");function hB(n){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(n):e=n&&n.buffer&&YT(n.buffer),e}const dB=g1("string"),Ks=g1("function"),QT=g1("number"),Jm=n=>n!==null&&typeof n=="object",fB=n=>n===!0||n===!1,gy=n=>{if(m1(n)!=="object")return!1;const e=iS(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(XT in n)&&!(p1 in n)},pB=n=>{if(!Jm(n)||Qm(n))return!1;try{return Object.keys(n).length===0&&Object.getPrototypeOf(n)===Object.prototype}catch{return!1}},mB=Ti("Date"),gB=Ti("File"),xB=Ti("Blob"),yB=Ti("FileList"),vB=n=>Jm(n)&&Ks(n.pipe),wB=n=>{let e;return n&&(typeof FormData=="function"&&n instanceof FormData||Ks(n.append)&&((e=m1(n))==="formdata"||e==="object"&&Ks(n.toString)&&n.toString()==="[object FormData]"))},bB=Ti("URLSearchParams"),[CB,SB,kB,IB]=["ReadableStream","Request","Response","Headers"].map(Ti),$B=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Zm(n,e,{allOwnKeys:t=!1}={}){if(n===null||typeof n>"u")return;let r,s;if(typeof n!="object"&&(n=[n]),wf(n))for(r=0,s=n.length;r<s;r++)e.call(null,n[r],r,n);else{if(Qm(n))return;const o=t?Object.getOwnPropertyNames(n):Object.keys(n),i=o.length;let a;for(r=0;r<i;r++)a=o[r],e.call(null,n[a],a,n)}}function JT(n,e){if(Qm(n))return null;e=e.toLowerCase();const t=Object.keys(n);let r=t.length,s;for(;r-- >0;)if(s=t[r],e===s.toLowerCase())return s;return null}const Dc=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ZT=n=>!sf(n)&&n!==Dc;function Zb(){const{caseless:n,skipUndefined:e}=ZT(this)&&this||{},t={},r=(s,o)=>{const i=n&&JT(t,o)||o;gy(t[i])&&gy(s)?t[i]=Zb(t[i],s):gy(s)?t[i]=Zb({},s):wf(s)?t[i]=s.slice():(!e||!sf(s))&&(t[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&Zm(arguments[s],r);return t}const NB=(n,e,t,{allOwnKeys:r}={})=>(Zm(e,(s,o)=>{t&&Ks(s)?n[o]=KT(s,t):n[o]=s},{allOwnKeys:r}),n),TB=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),EB=(n,e,t,r)=>{n.prototype=Object.create(e.prototype,r),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:e.prototype}),t&&Object.assign(n.prototype,t)},RB=(n,e,t,r)=>{let s,o,i;const a={};if(e=e||{},n==null)return e;do{for(s=Object.getOwnPropertyNames(n),o=s.length;o-- >0;)i=s[o],(!r||r(i,n,e))&&!a[i]&&(e[i]=n[i],a[i]=!0);n=t!==!1&&iS(n)}while(n&&(!t||t(n,e))&&n!==Object.prototype);return e},AB=(n,e,t)=>{n=String(n),(t===void 0||t>n.length)&&(t=n.length),t-=e.length;const r=n.indexOf(e,t);return r!==-1&&r===t},_B=n=>{if(!n)return null;if(wf(n))return n;let e=n.length;if(!QT(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=n[e];return t},DB=(n=>e=>n&&e instanceof n)(typeof Uint8Array<"u"&&iS(Uint8Array)),OB=(n,e)=>{const r=(n&&n[p1]).call(n);let s;for(;(s=r.next())&&!s.done;){const o=s.value;e.call(n,o[0],o[1])}},FB=(n,e)=>{let t;const r=[];for(;(t=n.exec(e))!==null;)r.push(t);return r},PB=Ti("HTMLFormElement"),LB=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,r,s){return r.toUpperCase()+s}),lN=(({hasOwnProperty:n})=>(e,t)=>n.call(e,t))(Object.prototype),MB=Ti("RegExp"),eE=(n,e)=>{const t=Object.getOwnPropertyDescriptors(n),r={};Zm(t,(s,o)=>{let i;(i=e(s,o,n))!==!1&&(r[o]=i||s)}),Object.defineProperties(n,r)},zB=n=>{eE(n,(e,t)=>{if(Ks(n)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const r=n[t];if(Ks(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},BB=(n,e)=>{const t={},r=s=>{s.forEach(o=>{t[o]=!0})};return wf(n)?r(n):r(String(n).split(e)),t},UB=()=>{},WB=(n,e)=>n!=null&&Number.isFinite(n=+n)?n:e;function VB(n){return!!(n&&Ks(n.append)&&n[XT]==="FormData"&&n[p1])}const GB=n=>{const e=new Array(10),t=(r,s)=>{if(Jm(r)){if(e.indexOf(r)>=0)return;if(Qm(r))return r;if(!("toJSON"in r)){e[s]=r;const o=wf(r)?[]:{};return Zm(r,(i,a)=>{const l=t(i,s+1);!sf(l)&&(o[a]=l)}),e[s]=void 0,o}}return r};return t(n,0)},jB=Ti("AsyncFunction"),HB=n=>n&&(Jm(n)||Ks(n))&&Ks(n.then)&&Ks(n.catch),tE=((n,e)=>n?setImmediate:e?((t,r)=>(Dc.addEventListener("message",({source:s,data:o})=>{s===Dc&&o===t&&r.length&&r.shift()()},!1),s=>{r.push(s),Dc.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Ks(Dc.postMessage)),qB=typeof queueMicrotask<"u"?queueMicrotask.bind(Dc):typeof process<"u"&&process.nextTick||tE,KB=n=>n!=null&&Ks(n[p1]),be={isArray:wf,isArrayBuffer:YT,isBuffer:Qm,isFormData:wB,isArrayBufferView:hB,isString:dB,isNumber:QT,isBoolean:fB,isObject:Jm,isPlainObject:gy,isEmptyObject:pB,isReadableStream:CB,isRequest:SB,isResponse:kB,isHeaders:IB,isUndefined:sf,isDate:mB,isFile:gB,isBlob:xB,isRegExp:MB,isFunction:Ks,isStream:vB,isURLSearchParams:bB,isTypedArray:DB,isFileList:yB,forEach:Zm,merge:Zb,extend:NB,trim:$B,stripBOM:TB,inherits:EB,toFlatObject:RB,kindOf:m1,kindOfTest:Ti,endsWith:AB,toArray:_B,forEachEntry:OB,matchAll:FB,isHTMLForm:PB,hasOwnProperty:lN,hasOwnProp:lN,reduceDescriptors:eE,freezeMethods:zB,toObjectSet:BB,toCamelCase:LB,noop:UB,toFiniteNumber:WB,findKey:JT,global:Dc,isContextDefined:ZT,isSpecCompliantForm:VB,toJSONObject:GB,isAsyncFn:jB,isThenable:HB,setImmediate:tE,asap:qB,isIterable:KB};function vt(n,e,t,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),r&&(this.request=r),s&&(this.response=s,this.status=s.status?s.status:null)}be.inherits(vt,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:be.toJSONObject(this.config),code:this.code,status:this.status}}});const nE=vt.prototype,rE={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(n=>{rE[n]={value:n}});Object.defineProperties(vt,rE);Object.defineProperty(nE,"isAxiosError",{value:!0});vt.from=(n,e,t,r,s,o)=>{const i=Object.create(nE);be.toFlatObject(n,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=n&&n.message?n.message:"Error",l=e==null&&n?n.code:e;return vt.call(i,a,l,t,r,s),n&&i.cause==null&&Object.defineProperty(i,"cause",{value:n,configurable:!0}),i.name=n&&n.name||"Error",o&&Object.assign(i,o),i};const XB=null;function eC(n){return be.isPlainObject(n)||be.isArray(n)}function sE(n){return be.endsWith(n,"[]")?n.slice(0,-2):n}function uN(n,e,t){return n?n.concat(e).map(function(s,o){return s=sE(s),!t&&o?"["+s+"]":s}).join(t?".":""):e}function YB(n){return be.isArray(n)&&!n.some(eC)}const QB=be.toFlatObject(be,{},null,function(e){return/^is[A-Z]/.test(e)});function x1(n,e,t){if(!be.isObject(n))throw new TypeError("target must be an object");e=e||new FormData,t=be.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(b,w){return!be.isUndefined(w[b])});const r=t.metaTokens,s=t.visitor||d,o=t.dots,i=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&be.isSpecCompliantForm(e);if(!be.isFunction(s))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(be.isDate(v))return v.toISOString();if(be.isBoolean(v))return v.toString();if(!l&&be.isBlob(v))throw new vt("Blob is not supported. Use a Buffer instead.");return be.isArrayBuffer(v)||be.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,b,w){let k=v;if(v&&!w&&typeof v=="object"){if(be.endsWith(b,"{}"))b=r?b:b.slice(0,-2),v=JSON.stringify(v);else if(be.isArray(v)&&YB(v)||(be.isFileList(v)||be.endsWith(b,"[]"))&&(k=be.toArray(v)))return b=sE(b),k.forEach(function(N,T){!(be.isUndefined(N)||N===null)&&e.append(i===!0?uN([b],T,o):i===null?b:b+"[]",c(N))}),!1}return eC(v)?!0:(e.append(uN(w,b,o),c(v)),!1)}const p=[],m=Object.assign(QB,{defaultVisitor:d,convertValue:c,isVisitable:eC});function y(v,b){if(!be.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+b.join("."));p.push(v),be.forEach(v,function(k,I){(!(be.isUndefined(k)||k===null)&&s.call(e,k,be.isString(I)?I.trim():I,b,m))===!0&&y(k,b?b.concat(I):[I])}),p.pop()}}if(!be.isObject(n))throw new TypeError("data must be an object");return y(n),e}function cN(n){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function aS(n,e){this._pairs=[],n&&x1(n,this,e)}const oE=aS.prototype;oE.append=function(e,t){this._pairs.push([e,t])};oE.toString=function(e){const t=e?function(r){return e.call(this,r,cN)}:cN;return this._pairs.map(function(s){return t(s[0])+"="+t(s[1])},"").join("&")};function JB(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function iE(n,e,t){if(!e)return n;const r=t&&t.encode||JB;be.isFunction(t)&&(t={serialize:t});const s=t&&t.serialize;let o;if(s?o=s(e,t):o=be.isURLSearchParams(e)?e.toString():new aS(e,t).toString(r),o){const i=n.indexOf("#");i!==-1&&(n=n.slice(0,i)),n+=(n.indexOf("?")===-1?"?":"&")+o}return n}class hN{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){be.forEach(this.handlers,function(r){r!==null&&e(r)})}}const aE={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ZB=typeof URLSearchParams<"u"?URLSearchParams:aS,e4=typeof FormData<"u"?FormData:null,t4=typeof Blob<"u"?Blob:null,n4={isBrowser:!0,classes:{URLSearchParams:ZB,FormData:e4,Blob:t4},protocols:["http","https","file","blob","url","data"]},lS=typeof window<"u"&&typeof document<"u",tC=typeof navigator=="object"&&navigator||void 0,r4=lS&&(!tC||["ReactNative","NativeScript","NS"].indexOf(tC.product)<0),s4=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",o4=lS&&window.location.href||"http://localhost",i4=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:lS,hasStandardBrowserEnv:r4,hasStandardBrowserWebWorkerEnv:s4,navigator:tC,origin:o4},Symbol.toStringTag,{value:"Module"})),as={...i4,...n4};function a4(n,e){return x1(n,new as.classes.URLSearchParams,{visitor:function(t,r,s,o){return as.isNode&&be.isBuffer(t)?(this.append(r,t.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...e})}function l4(n){return be.matchAll(/\w+|\[(\w*)]/g,n).map(e=>e[0]==="[]"?"":e[1]||e[0])}function u4(n){const e={},t=Object.keys(n);let r;const s=t.length;let o;for(r=0;r<s;r++)o=t[r],e[o]=n[o];return e}function lE(n){function e(t,r,s,o){let i=t[o++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=o>=t.length;return i=!i&&be.isArray(s)?s.length:i,l?(be.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!a):((!s[i]||!be.isObject(s[i]))&&(s[i]=[]),e(t,r,s[i],o)&&be.isArray(s[i])&&(s[i]=u4(s[i])),!a)}if(be.isFormData(n)&&be.isFunction(n.entries)){const t={};return be.forEachEntry(n,(r,s)=>{e(l4(r),s,t,0)}),t}return null}function c4(n,e,t){if(be.isString(n))try{return(e||JSON.parse)(n),be.trim(n)}catch(r){if(r.name!=="SyntaxError")throw r}return(t||JSON.stringify)(n)}const eg={transitional:aE,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",s=r.indexOf("application/json")>-1,o=be.isObject(e);if(o&&be.isHTMLForm(e)&&(e=new FormData(e)),be.isFormData(e))return s?JSON.stringify(lE(e)):e;if(be.isArrayBuffer(e)||be.isBuffer(e)||be.isStream(e)||be.isFile(e)||be.isBlob(e)||be.isReadableStream(e))return e;if(be.isArrayBufferView(e))return e.buffer;if(be.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return a4(e,this.formSerializer).toString();if((a=be.isFileList(e))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return x1(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return o||s?(t.setContentType("application/json",!1),c4(e)):e}],transformResponse:[function(e){const t=this.transitional||eg.transitional,r=t&&t.forcedJSONParsing,s=this.responseType==="json";if(be.isResponse(e)||be.isReadableStream(e))return e;if(e&&be.isString(e)&&(r&&!this.responseType||s)){const i=!(t&&t.silentJSONParsing)&&s;try{return JSON.parse(e,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?vt.from(a,vt.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:as.classes.FormData,Blob:as.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};be.forEach(["delete","get","head","post","put","patch"],n=>{eg.headers[n]={}});const h4=be.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),d4=n=>{const e={};let t,r,s;return n&&n.split(`
`).forEach(function(i){s=i.indexOf(":"),t=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!t||e[t]&&h4[t])&&(t==="set-cookie"?e[t]?e[t].push(r):e[t]=[r]:e[t]=e[t]?e[t]+", "+r:r)}),e},dN=Symbol("internals");function fm(n){return n&&String(n).trim().toLowerCase()}function xy(n){return n===!1||n==null?n:be.isArray(n)?n.map(xy):String(n)}function f4(n){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=t.exec(n);)e[r[1]]=r[2];return e}const p4=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function yb(n,e,t,r,s){if(be.isFunction(r))return r.call(this,e,t);if(s&&(e=t),!!be.isString(e)){if(be.isString(r))return e.indexOf(r)!==-1;if(be.isRegExp(r))return r.test(e)}}function m4(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r)}function g4(n,e){const t=be.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(n,r+t,{value:function(s,o,i){return this[r].call(this,e,s,o,i)},configurable:!0})})}let Xs=class{constructor(e){e&&this.set(e)}set(e,t,r){const s=this;function o(a,l,c){const d=fm(l);if(!d)throw new Error("header name must be a non-empty string");const p=be.findKey(s,d);(!p||s[p]===void 0||c===!0||c===void 0&&s[p]!==!1)&&(s[p||l]=xy(a))}const i=(a,l)=>be.forEach(a,(c,d)=>o(c,d,l));if(be.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(be.isString(e)&&(e=e.trim())&&!p4(e))i(d4(e),t);else if(be.isObject(e)&&be.isIterable(e)){let a={},l,c;for(const d of e){if(!be.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?be.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,t)}else e!=null&&o(t,e,r);return this}get(e,t){if(e=fm(e),e){const r=be.findKey(this,e);if(r){const s=this[r];if(!t)return s;if(t===!0)return f4(s);if(be.isFunction(t))return t.call(this,s,r);if(be.isRegExp(t))return t.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=fm(e),e){const r=be.findKey(this,e);return!!(r&&this[r]!==void 0&&(!t||yb(this,this[r],r,t)))}return!1}delete(e,t){const r=this;let s=!1;function o(i){if(i=fm(i),i){const a=be.findKey(r,i);a&&(!t||yb(r,r[a],a,t))&&(delete r[a],s=!0)}}return be.isArray(e)?e.forEach(o):o(e),s}clear(e){const t=Object.keys(this);let r=t.length,s=!1;for(;r--;){const o=t[r];(!e||yb(this,this[o],o,e,!0))&&(delete this[o],s=!0)}return s}normalize(e){const t=this,r={};return be.forEach(this,(s,o)=>{const i=be.findKey(r,o);if(i){t[i]=xy(s),delete t[o];return}const a=e?m4(o):String(o).trim();a!==o&&delete t[o],t[a]=xy(s),r[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return be.forEach(this,(r,s)=>{r!=null&&r!==!1&&(t[s]=e&&be.isArray(r)?r.join(", "):r)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach(s=>r.set(s)),r}static accessor(e){const r=(this[dN]=this[dN]={accessors:{}}).accessors,s=this.prototype;function o(i){const a=fm(i);r[a]||(g4(s,i),r[a]=!0)}return be.isArray(e)?e.forEach(o):o(e),this}};Xs.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);be.reduceDescriptors(Xs.prototype,({value:n},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>n,set(r){this[t]=r}}});be.freezeMethods(Xs);function vb(n,e){const t=this||eg,r=e||t,s=Xs.from(r.headers);let o=r.data;return be.forEach(n,function(a){o=a.call(t,o,s.normalize(),e?e.status:void 0)}),s.normalize(),o}function uE(n){return!!(n&&n.__CANCEL__)}function bf(n,e,t){vt.call(this,n??"canceled",vt.ERR_CANCELED,e,t),this.name="CanceledError"}be.inherits(bf,vt,{__CANCEL__:!0});function cE(n,e,t){const r=t.config.validateStatus;!t.status||!r||r(t.status)?n(t):e(new vt("Request failed with status code "+t.status,[vt.ERR_BAD_REQUEST,vt.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function x4(n){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return e&&e[1]||""}function y4(n,e){n=n||10;const t=new Array(n),r=new Array(n);let s=0,o=0,i;return e=e!==void 0?e:1e3,function(l){const c=Date.now(),d=r[o];i||(i=c),t[s]=l,r[s]=c;let p=o,m=0;for(;p!==s;)m+=t[p++],p=p%n;if(s=(s+1)%n,s===o&&(o=(o+1)%n),c-i<e)return;const y=d&&c-d;return y?Math.round(m*1e3/y):void 0}}function v4(n,e){let t=0,r=1e3/e,s,o;const i=(c,d=Date.now())=>{t=d,s=null,o&&(clearTimeout(o),o=null),n(...c)};return[(...c)=>{const d=Date.now(),p=d-t;p>=r?i(c,d):(s=c,o||(o=setTimeout(()=>{o=null,i(s)},r-p)))},()=>s&&i(s)]}const Fy=(n,e,t=3)=>{let r=0;const s=y4(50,250);return v4(o=>{const i=o.loaded,a=o.lengthComputable?o.total:void 0,l=i-r,c=s(l),d=i<=a;r=i;const p={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:o,lengthComputable:a!=null,[e?"download":"upload"]:!0};n(p)},t)},fN=(n,e)=>{const t=n!=null;return[r=>e[0]({lengthComputable:t,total:n,loaded:r}),e[1]]},pN=n=>(...e)=>be.asap(()=>n(...e)),w4=as.hasStandardBrowserEnv?((n,e)=>t=>(t=new URL(t,as.origin),n.protocol===t.protocol&&n.host===t.host&&(e||n.port===t.port)))(new URL(as.origin),as.navigator&&/(msie|trident)/i.test(as.navigator.userAgent)):()=>!0,b4=as.hasStandardBrowserEnv?{write(n,e,t,r,s,o,i){if(typeof document>"u")return;const a=[`${n}=${encodeURIComponent(e)}`];be.isNumber(t)&&a.push(`expires=${new Date(t).toUTCString()}`),be.isString(r)&&a.push(`path=${r}`),be.isString(s)&&a.push(`domain=${s}`),o===!0&&a.push("secure"),be.isString(i)&&a.push(`SameSite=${i}`),document.cookie=a.join("; ")},read(n){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+n+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(n){this.write(n,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function C4(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function S4(n,e){return e?n.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):n}function hE(n,e,t){let r=!C4(e);return n&&(r||t==!1)?S4(n,e):e}const mN=n=>n instanceof Xs?{...n}:n;function Vc(n,e){e=e||{};const t={};function r(c,d,p,m){return be.isPlainObject(c)&&be.isPlainObject(d)?be.merge.call({caseless:m},c,d):be.isPlainObject(d)?be.merge({},d):be.isArray(d)?d.slice():d}function s(c,d,p,m){if(be.isUndefined(d)){if(!be.isUndefined(c))return r(void 0,c,p,m)}else return r(c,d,p,m)}function o(c,d){if(!be.isUndefined(d))return r(void 0,d)}function i(c,d){if(be.isUndefined(d)){if(!be.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,p){if(p in e)return r(c,d);if(p in n)return r(void 0,c)}const l={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,p)=>s(mN(c),mN(d),p,!0)};return be.forEach(Object.keys({...n,...e}),function(d){const p=l[d]||s,m=p(n[d],e[d],d);be.isUndefined(m)&&p!==a||(t[d]=m)}),t}const dE=n=>{const e=Vc({},n);let{data:t,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:a}=e;if(e.headers=i=Xs.from(i),e.url=iE(hE(e.baseURL,e.url,e.allowAbsoluteUrls),n.params,n.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),be.isFormData(t)){if(as.hasStandardBrowserEnv||as.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(be.isFunction(t.getHeaders)){const l=t.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,p])=>{c.includes(d.toLowerCase())&&i.set(d,p)})}}if(as.hasStandardBrowserEnv&&(r&&be.isFunction(r)&&(r=r(e)),r||r!==!1&&w4(e.url))){const l=s&&o&&b4.read(o);l&&i.set(s,l)}return e},k4=typeof XMLHttpRequest<"u",I4=k4&&function(n){return new Promise(function(t,r){const s=dE(n);let o=s.data;const i=Xs.from(s.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=s,d,p,m,y,v;function b(){y&&y(),v&&v(),s.cancelToken&&s.cancelToken.unsubscribe(d),s.signal&&s.signal.removeEventListener("abort",d)}let w=new XMLHttpRequest;w.open(s.method.toUpperCase(),s.url,!0),w.timeout=s.timeout;function k(){if(!w)return;const N=Xs.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders()),A={data:!a||a==="text"||a==="json"?w.responseText:w.response,status:w.status,statusText:w.statusText,headers:N,config:n,request:w};cE(function(P){t(P),b()},function(P){r(P),b()},A),w=null}"onloadend"in w?w.onloadend=k:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(k)},w.onabort=function(){w&&(r(new vt("Request aborted",vt.ECONNABORTED,n,w)),w=null)},w.onerror=function(T){const A=T&&T.message?T.message:"Network Error",O=new vt(A,vt.ERR_NETWORK,n,w);O.event=T||null,r(O),w=null},w.ontimeout=function(){let T=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const A=s.transitional||aE;s.timeoutErrorMessage&&(T=s.timeoutErrorMessage),r(new vt(T,A.clarifyTimeoutError?vt.ETIMEDOUT:vt.ECONNABORTED,n,w)),w=null},o===void 0&&i.setContentType(null),"setRequestHeader"in w&&be.forEach(i.toJSON(),function(T,A){w.setRequestHeader(A,T)}),be.isUndefined(s.withCredentials)||(w.withCredentials=!!s.withCredentials),a&&a!=="json"&&(w.responseType=s.responseType),c&&([m,v]=Fy(c,!0),w.addEventListener("progress",m)),l&&w.upload&&([p,y]=Fy(l),w.upload.addEventListener("progress",p),w.upload.addEventListener("loadend",y)),(s.cancelToken||s.signal)&&(d=N=>{w&&(r(!N||N.type?new bf(null,n,w):N),w.abort(),w=null)},s.cancelToken&&s.cancelToken.subscribe(d),s.signal&&(s.signal.aborted?d():s.signal.addEventListener("abort",d)));const I=x4(s.url);if(I&&as.protocols.indexOf(I)===-1){r(new vt("Unsupported protocol "+I+":",vt.ERR_BAD_REQUEST,n));return}w.send(o||null)})},$4=(n,e)=>{const{length:t}=n=n?n.filter(Boolean):[];if(e||t){let r=new AbortController,s;const o=function(c){if(!s){s=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof vt?d:new bf(d instanceof Error?d.message:d))}};let i=e&&setTimeout(()=>{i=null,o(new vt(`timeout ${e} of ms exceeded`,vt.ETIMEDOUT))},e);const a=()=>{n&&(i&&clearTimeout(i),i=null,n.forEach(c=>{c.unsubscribe?c.unsubscribe(o):c.removeEventListener("abort",o)}),n=null)};n.forEach(c=>c.addEventListener("abort",o));const{signal:l}=r;return l.unsubscribe=()=>be.asap(a),l}},N4=function*(n,e){let t=n.byteLength;if(t<e){yield n;return}let r=0,s;for(;r<t;)s=r+e,yield n.slice(r,s),r=s},T4=async function*(n,e){for await(const t of E4(n))yield*N4(t,e)},E4=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}const e=n.getReader();try{for(;;){const{done:t,value:r}=await e.read();if(t)break;yield r}}finally{await e.cancel()}},gN=(n,e,t,r)=>{const s=T4(n,e);let o=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await s.next();if(c){a(),l.close();return}let p=d.byteLength;if(t){let m=o+=p;t(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),s.return()}},{highWaterMark:2})},xN=64*1024,{isFunction:ny}=be,R4=(({Request:n,Response:e})=>({Request:n,Response:e}))(be.global),{ReadableStream:yN,TextEncoder:vN}=be.global,wN=(n,...e)=>{try{return!!n(...e)}catch{return!1}},A4=n=>{n=be.merge.call({skipUndefined:!0},R4,n);const{fetch:e,Request:t,Response:r}=n,s=e?ny(e):typeof fetch=="function",o=ny(t),i=ny(r);if(!s)return!1;const a=s&&ny(yN),l=s&&(typeof vN=="function"?(v=>b=>v.encode(b))(new vN):async v=>new Uint8Array(await new t(v).arrayBuffer())),c=o&&a&&wN(()=>{let v=!1;const b=new t(as.origin,{body:new yN,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!b}),d=i&&a&&wN(()=>be.isReadableStream(new r("").body)),p={stream:d&&(v=>v.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!p[v]&&(p[v]=(b,w)=>{let k=b&&b[v];if(k)return k.call(b);throw new vt(`Response type '${v}' is not supported`,vt.ERR_NOT_SUPPORT,w)})});const m=async v=>{if(v==null)return 0;if(be.isBlob(v))return v.size;if(be.isSpecCompliantForm(v))return(await new t(as.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(be.isArrayBufferView(v)||be.isArrayBuffer(v))return v.byteLength;if(be.isURLSearchParams(v)&&(v=v+""),be.isString(v))return(await l(v)).byteLength},y=async(v,b)=>{const w=be.toFiniteNumber(v.getContentLength());return w??m(b)};return async v=>{let{url:b,method:w,data:k,signal:I,cancelToken:N,timeout:T,onDownloadProgress:A,onUploadProgress:O,responseType:P,headers:B,withCredentials:z="same-origin",fetchOptions:L}=dE(v),_=e||fetch;P=P?(P+"").toLowerCase():"text";let H=$4([I,N&&N.toAbortSignal()],T),Y=null;const re=H&&H.unsubscribe&&(()=>{H.unsubscribe()});let te;try{if(O&&c&&w!=="get"&&w!=="head"&&(te=await y(B,k))!==0){let V=new t(b,{method:"POST",body:k,duplex:"half"}),X;if(be.isFormData(k)&&(X=V.headers.get("content-type"))&&B.setContentType(X),V.body){const[xe,Ie]=fN(te,Fy(pN(O)));k=gN(V.body,xN,xe,Ie)}}be.isString(z)||(z=z?"include":"omit");const le=o&&"credentials"in t.prototype,de={...L,signal:H,method:w.toUpperCase(),headers:B.normalize().toJSON(),body:k,duplex:"half",credentials:le?z:void 0};Y=o&&new t(b,de);let j=await(o?_(Y,L):_(b,de));const ie=d&&(P==="stream"||P==="response");if(d&&(A||ie&&re)){const V={};["status","statusText","headers"].forEach(ke=>{V[ke]=j[ke]});const X=be.toFiniteNumber(j.headers.get("content-length")),[xe,Ie]=A&&fN(X,Fy(pN(A),!0))||[];j=new r(gN(j.body,xN,xe,()=>{Ie&&Ie(),re&&re()}),V)}P=P||"text";let se=await p[be.findKey(p,P)||"text"](j,v);return!ie&&re&&re(),await new Promise((V,X)=>{cE(V,X,{data:se,headers:Xs.from(j.headers),status:j.status,statusText:j.statusText,config:v,request:Y})})}catch(le){throw re&&re(),le&&le.name==="TypeError"&&/Load failed|fetch/i.test(le.message)?Object.assign(new vt("Network Error",vt.ERR_NETWORK,v,Y),{cause:le.cause||le}):vt.from(le,le&&le.code,v,Y)}}},_4=new Map,fE=n=>{let e=n&&n.env||{};const{fetch:t,Request:r,Response:s}=e,o=[r,s,t];let i=o.length,a=i,l,c,d=_4;for(;a--;)l=o[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:A4(e)),d=c;return c};fE();const uS={http:XB,xhr:I4,fetch:{get:fE}};be.forEach(uS,(n,e)=>{if(n){try{Object.defineProperty(n,"name",{value:e})}catch{}Object.defineProperty(n,"adapterName",{value:e})}});const bN=n=>`- ${n}`,D4=n=>be.isFunction(n)||n===null||n===!1;function O4(n,e){n=be.isArray(n)?n:[n];const{length:t}=n;let r,s;const o={};for(let i=0;i<t;i++){r=n[i];let a;if(s=r,!D4(r)&&(s=uS[(a=String(r)).toLowerCase()],s===void 0))throw new vt(`Unknown adapter '${a}'`);if(s&&(be.isFunction(s)||(s=s.get(e))))break;o[a||"#"+i]=s}if(!s){const i=Object.entries(o).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=t?i.length>1?`since :
`+i.map(bN).join(`
`):" "+bN(i[0]):"as no adapter specified";throw new vt("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return s}const pE={getAdapter:O4,adapters:uS};function wb(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new bf(null,n)}function CN(n){return wb(n),n.headers=Xs.from(n.headers),n.data=vb.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),pE.getAdapter(n.adapter||eg.adapter,n)(n).then(function(r){return wb(n),r.data=vb.call(n,n.transformResponse,r),r.headers=Xs.from(r.headers),r},function(r){return uE(r)||(wb(n),r&&r.response&&(r.response.data=vb.call(n,n.transformResponse,r.response),r.response.headers=Xs.from(r.response.headers))),Promise.reject(r)})}const mE="1.13.2",y1={};["object","boolean","number","function","string","symbol"].forEach((n,e)=>{y1[n]=function(r){return typeof r===n||"a"+(e<1?"n ":" ")+n}});const SN={};y1.transitional=function(e,t,r){function s(o,i){return"[Axios v"+mE+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,a)=>{if(e===!1)throw new vt(s(i," has been removed"+(t?" in "+t:"")),vt.ERR_DEPRECATED);return t&&!SN[i]&&(SN[i]=!0,console.warn(s(i," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(o,i,a):!0}};y1.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};function F4(n,e,t){if(typeof n!="object")throw new vt("options must be an object",vt.ERR_BAD_OPTION_VALUE);const r=Object.keys(n);let s=r.length;for(;s-- >0;){const o=r[s],i=e[o];if(i){const a=n[o],l=a===void 0||i(a,o,n);if(l!==!0)throw new vt("option "+o+" must be "+l,vt.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new vt("Unknown option "+o,vt.ERR_BAD_OPTION)}}const yy={assertOptions:F4,validators:y1},ta=yy.validators;let Pc=class{constructor(e){this.defaults=e||{},this.interceptors={request:new hN,response:new hN}}async request(e,t){try{return await this._request(e,t)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+=`
`+o):r.stack=o}catch{}}throw r}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Vc(this.defaults,t);const{transitional:r,paramsSerializer:s,headers:o}=t;r!==void 0&&yy.assertOptions(r,{silentJSONParsing:ta.transitional(ta.boolean),forcedJSONParsing:ta.transitional(ta.boolean),clarifyTimeoutError:ta.transitional(ta.boolean)},!1),s!=null&&(be.isFunction(s)?t.paramsSerializer={serialize:s}:yy.assertOptions(s,{encode:ta.function,serialize:ta.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),yy.assertOptions(t,{baseUrl:ta.spelling("baseURL"),withXsrfToken:ta.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=o&&be.merge(o.common,o[t.method]);o&&be.forEach(["delete","get","head","post","put","patch","common"],v=>{delete o[v]}),t.headers=Xs.concat(i,o);const a=[];let l=!0;this.interceptors.request.forEach(function(b){typeof b.runWhen=="function"&&b.runWhen(t)===!1||(l=l&&b.synchronous,a.unshift(b.fulfilled,b.rejected))});const c=[];this.interceptors.response.forEach(function(b){c.push(b.fulfilled,b.rejected)});let d,p=0,m;if(!l){const v=[CN.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(t);p<m;)d=d.then(v[p++],v[p++]);return d}m=a.length;let y=t;for(;p<m;){const v=a[p++],b=a[p++];try{y=v(y)}catch(w){b.call(this,w);break}}try{d=CN.call(this,y)}catch(v){return Promise.reject(v)}for(p=0,m=c.length;p<m;)d=d.then(c[p++],c[p++]);return d}getUri(e){e=Vc(this.defaults,e);const t=hE(e.baseURL,e.url,e.allowAbsoluteUrls);return iE(t,e.params,e.paramsSerializer)}};be.forEach(["delete","get","head","options"],function(e){Pc.prototype[e]=function(t,r){return this.request(Vc(r||{},{method:e,url:t,data:(r||{}).data}))}});be.forEach(["post","put","patch"],function(e){function t(r){return function(o,i,a){return this.request(Vc(a||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}Pc.prototype[e]=t(),Pc.prototype[e+"Form"]=t(!0)});let P4=class gE{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(o){t=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(a=>{r.subscribe(a),o=a}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},e(function(o,i,a){r.reason||(r.reason=new bf(o,i,a),t(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=r=>{e.abort(r)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new gE(function(s){e=s}),cancel:e}}};function L4(n){return function(t){return n.apply(null,t)}}function M4(n){return be.isObject(n)&&n.isAxiosError===!0}const nC={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(nC).forEach(([n,e])=>{nC[e]=n});function xE(n){const e=new Pc(n),t=KT(Pc.prototype.request,e);return be.extend(t,Pc.prototype,e,{allOwnKeys:!0}),be.extend(t,e,null,{allOwnKeys:!0}),t.create=function(s){return xE(Vc(n,s))},t}const Bn=xE(eg);Bn.Axios=Pc;Bn.CanceledError=bf;Bn.CancelToken=P4;Bn.isCancel=uE;Bn.VERSION=mE;Bn.toFormData=x1;Bn.AxiosError=vt;Bn.Cancel=Bn.CanceledError;Bn.all=function(e){return Promise.all(e)};Bn.spread=L4;Bn.isAxiosError=M4;Bn.mergeConfig=Vc;Bn.AxiosHeaders=Xs;Bn.formToJSON=n=>lE(be.isHTMLForm(n)?new FormData(n):n);Bn.getAdapter=pE.getAdapter;Bn.HttpStatusCode=nC;Bn.default=Bn;const{Axios:Wde,AxiosError:Vde,CanceledError:Gde,isCancel:jde,CancelToken:Hde,VERSION:qde,all:Kde,Cancel:Xde,isAxiosError:Yde,spread:Qde,toFormData:Jde,AxiosHeaders:Zde,HttpStatusCode:efe,formToJSON:tfe,getAdapter:nfe,mergeConfig:rfe}=Bn,cS=Bn.create({baseURL:"https://api.github.com"}),z4=Bn.create({baseURL:"/api"});const B4=1e-7,U4=1e-4;class yE{constructor(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}get(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)}set(e,t){this.dataIdsCount++,this.data.set(e,t)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}}class hS{refCount(e){return js("refCount")}incRef(e){return js("incRef")}timerAvailable(){return!0}time(e){return js("time")}read(e){return js("read")}readSync(e){return js("readSync")}readToGPU(e,t){return js("readToGPU")}numDataIds(){return js("numDataIds")}disposeData(e,t){return js("disposeData")}write(e,t,r){return js("write")}move(e,t,r,s,o){return js("move")}createTensorFromGPUData(e,t,r){return js("createTensorFromGPUData")}memory(){return js("memory")}floatPrecision(){return js("floatPrecision")}epsilon(){return this.floatPrecision()===32?B4:U4}dispose(){return js("dispose")}}function js(n){throw new Error(`'${n}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}function W4(n){let e=n.length,t=0;for(;e>0;)t=Math.random()*e|0,e--,jd(n,e,t)}function Gc(n,e,t){return Math.max(n,Math.min(e,t))}function dS(n){return n%2===0?n:n+1}function jd(n,e,t){const r=n[e];n[e]=n[t],n[t]=r}function V4(n){let e=0;for(let t=0;t<n.length;t++)e+=n[t];return e}function U(n,e){if(!n)throw new Error(typeof e=="string"?e:e())}function fS(n,e,t=""){U(Xt(n,e),()=>t+` Shapes ${n} and ${e} must match`)}function pS(n){U(n!=null,()=>"The input to the tensor constructor must be a non-null value.")}function Se(n){if(n.length===0)return 1;let e=n[0];for(let t=1;t<n.length;t++)e*=n[t];return e}function Xt(n,e){if(n===e)return!0;if(n==null||e==null||n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}function of(n){return n%1===0}function rC(n){const e=Math.ceil(Math.sqrt(n));return[e,Math.ceil(n/e)]}function Zd(n,e){return e<=n.length?n:n+" ".repeat(e-n.length)}function kN(n,e=s=>0,t,r){return new Promise((s,o)=>{let i=0;const a=()=>{if(n()){s();return}i++;const l=e(i);if(t!=null&&i>=t){o();return}r!=null?r(a,l):setTimeout(a,l)};a()})}function vE(n,e){let t=1,r=-1;for(let o=0;o<n.length;++o)if(n[o]>=0)t*=n[o];else if(n[o]===-1){if(r!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${r} and dim ${o}`);r=o}else if(n[o]<0)throw Error(`Shapes can not be < 0. Found ${n[o]} at dim ${o}`);if(r===-1){if(e>0&&e!==t)throw Error(`Size(${e}) must match the product of shape ${n}`);return n}if(t===0)throw Error(`Cannot infer the missing size in [${n}] when there are 0 elements`);if(e%t!==0)throw Error(`The implicit shape can't be a fractional number. Got ${e} / ${t}`);const s=n.slice();return s[r]=e/t,s}function Tt(n,e){const t=e.length;return n=n==null?e.map((r,s)=>s):[].concat(n),U(n.every(r=>r>=-t&&r<t),()=>`All values in axis param must be in range [-${t}, ${t}) but got axis ${n}`),U(n.every(r=>of(r)),()=>`All values in axis param must be integers but got axis ${n}`),n.map(r=>r<0?t+r:r)}function pu(n,e){const t=[],r=[],s=e!=null&&Array.isArray(e)&&e.length===0,o=e==null||s?null:Tt(e,n).sort();let i=0;for(let a=0;a<n.length;++a){if(o!=null){if(o[i]===a&&n[a]!==1)throw new Error(`Can't squeeze axis ${a} since its dim '${n[a]}' is not 1`);(o[i]==null||o[i]>a)&&n[a]===1&&(t.push(n[a]),r.push(a)),o[i]<=a&&i++}n[a]!==1&&(t.push(n[a]),r.push(a))}return{newShape:t,keptDims:r}}function Vr(n,e){return Mn(n,e)}function Mn(n,e){let t=null;if(n==null||n==="float32")t=new Float32Array(e);else if(n==="int32")t=new Int32Array(e);else if(n==="bool")t=new Uint8Array(e);else if(n==="string")t=new Array(e);else throw new Error(`Unknown data type ${n}`);return t}function G4(n,e){for(let t=0;t<n.length;t++){const r=n[t];if(isNaN(r)||!isFinite(r))throw Error(`A tensor of type ${e} being uploaded contains ${r}.`)}}function j4(n){return n==="bool"||n==="complex64"||n==="float32"||n==="int32"||n==="string"}function wE(n,e){return!(e==="complex64"||e==="float32"&&n!=="complex64"||e==="int32"&&n!=="float32"&&n!=="complex64"||e==="bool"&&n==="bool")}function Py(n){if(n==="float32"||n==="int32")return 4;if(n==="complex64")return 8;if(n==="bool")return 1;throw new Error(`Unknown dtype ${n}`)}function H4(n){if(n==null)return 0;let e=0;return n.forEach(t=>e+=t.length),e}function tg(n){return typeof n=="string"||n instanceof String}function q4(n){return typeof n=="boolean"}function sC(n){return typeof n=="number"}function Cf(n){return Array.isArray(n)?Cf(n[0]):n instanceof Float32Array?"float32":n instanceof Int32Array||n instanceof Uint8Array||n instanceof Uint8ClampedArray?"int32":sC(n)?"float32":tg(n)?"string":q4(n)?"bool":"float32"}function oC(n){return!!(n&&n.constructor&&n.call&&n.apply)}function iC(n,e){for(let t=e;t<n;++t)if(n%t===0)return t;return n}function tt(n){const e=n.length;if(e<2)return[];const t=new Array(e-1);t[e-2]=n[e-1];for(let r=e-3;r>=0;--r)t[r]=t[r+1]*n[r+1];return t}function bE(n,e,t,r=!1){const s=new Array;if(e.length===1){const o=e[0]*(r?2:1);for(let i=0;i<o;i++)s[i]=t[n+i]}else{const o=e[0],i=e.slice(1),a=i.reduce((l,c)=>l*c)*(r?2:1);for(let l=0;l<o;l++)s[l]=bE(n+l*a,i,t,r)}return s}function Ci(n,e,t=!1){if(n.length===0)return e[0];const r=n.reduce((s,o)=>s*o)*(t?2:1);if(r===0)return[];if(r!==e.length)throw new Error(`[${n}] does not match the input size ${e.length}${t?" for a complex tensor":""}.`);return bE(0,n,e,t)}function K4(n,e){if(Array.isArray(n))return n;if(e==="float32")return n instanceof Float32Array?n:new Float32Array(n);if(e==="int32")return n instanceof Int32Array?n:new Int32Array(n);if(e==="bool"||e==="string")return Uint8Array.from(new Int32Array(n));throw new Error(`Unknown dtype ${e}`)}function mS(n,e){const t=Gr(n,e);for(let r=0;r<t.length;r++)t[r]=1;return t}function Gr(n,e){if(e==null||e==="float32"||e==="complex64")return new Float32Array(n);if(e==="int32")return new Int32Array(n);if(e==="bool")return new Uint8Array(n);throw new Error(`Unknown data type ${e}`)}function CE(n,e){const t=n.reduce((r,s)=>r*s,1);if(e==null||e==="float32")return Ci(n,new Float32Array(t));if(e==="int32")return Ci(n,new Int32Array(t));if(e==="bool")return Ci(n,new Uint8Array(t));throw new Error(`Unknown data type ${e}`)}function al(n){n.forEach(e=>{U(Number.isInteger(e)&&e>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${n}].`)})}function ca(n,e,t){if(e===0)return 0;if(e===1)return n[0];let r=n[n.length-1];for(let s=0;s<n.length-1;++s)r+=t[s]*n[s];return r}function Sf(n,e,t){if(e===0)return[];if(e===1)return[n];const r=new Array(e);for(let s=0;s<r.length-1;++s)r[s]=Math.floor(n/t[s]),n-=r[s]*t[s];return r[r.length-1]=n,r}function gS(n){return n&&n.then&&typeof n.then=="function"}const IN="tfjsflags";class X4{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=Y4,this.populateURLFlags()}setPlatform(e,t){this.platform!=null&&(ye().getBool("IS_TEST")||ye().getBool("PROD")||console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)),this.platformName=e,this.platform=t}registerFlag(e,t,r){if(this.flagRegistry[e]={evaluationFn:t,setHook:r},this.urlFlags[e]!=null){const s=this.urlFlags[e];ye().getBool("IS_TEST")||ye().getBool("PROD")||console.warn(`Setting feature override from URL ${e}: ${s}.`),this.set(e,s)}}async getAsync(e){return e in this.flags?this.flags[e]:(this.flags[e]=await this.evaluateFlag(e),this.flags[e])}get(e){if(e in this.flags)return this.flags[e];const t=this.evaluateFlag(e);if(gS(t))throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`);return this.flags[e]=t,this.flags[e]}getNumber(e){return this.get(e)}getBool(e){return this.get(e)}getString(e){return this.get(e)}getFlags(){return this.flags}get features(){return this.flags}set(e,t){if(this.flagRegistry[e]==null)throw new Error(`Cannot set flag ${e} as it has not been registered.`);this.flags[e]=t,this.flagRegistry[e].setHook!=null&&this.flagRegistry[e].setHook(t)}evaluateFlag(e){if(this.flagRegistry[e]==null)throw new Error(`Cannot evaluate flag '${e}': no evaluation function found.`);return this.flagRegistry[e].evaluationFn()}setFlags(e){this.flags=Object.assign({},e)}reset(){this.flags={},this.urlFlags={},this.populateURLFlags()}populateURLFlags(){if(typeof this.global>"u"||typeof this.global.location>"u"||typeof this.global.location.search>"u")return;const e=this.getQueryParams(this.global.location.search);IN in e&&e[IN].split(",").forEach(r=>{const[s,o]=r.split(":");this.urlFlags[s]=J4(s,o)})}}function Y4(n){const e={};return n.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(t,...r)=>(Q4(e,r[0],r[1]),r.join("="))),e}function Q4(n,e,t){n[decodeURIComponent(e)]=decodeURIComponent(t||"")}function J4(n,e){const t=e.toLowerCase();return t==="true"||t==="false"?t==="true":`${+t}`===t?+t:e}function ye(){return SE}let SE=null;function Z4(n){SE=n}let bb;function kE(){if(bb==null){let n;if(typeof window<"u")n=window;else if(typeof global<"u")n=global;else if(typeof process<"u")n=process;else if(typeof self<"u")n=self;else throw new Error("Could not find a global object");bb=n}return bb}function eU(){const n=kE();return n._tfGlobals==null&&(n._tfGlobals=new Map),n._tfGlobals}function xS(n,e){const t=eU();if(t.has(n))return t.get(n);{const r=e();return t.set(n,r),t.get(n)}}const v1="Abs",ng="Acos",rg="Acosh",kf="Add",yS="AddN",vS="All",wS="Any",w1="ArgMax",b1="ArgMin",sg="Asin",og="Asinh",ig="Atan",ag="Atanh",lg="Atan2",C1="AvgPool",bS="AvgPoolGrad",S1="AvgPool3D",CS="AvgPool3DGrad",k1="BatchMatMul",I1="BatchToSpaceND",SS="Bincount",kS="BitwiseAnd",tU="BroadcastTo",IE="BroadcastArgs",ug="Cast",cg="Ceil",hg="ClipByValue",IS="Complex",$1="ComplexAbs",N1="Concat",T1="Conv2D",$S="Conv2DBackpropFilter",E1="Conv2DBackpropInput",R1="Conv3D",NS="Conv3DBackpropFilterV2",TS="Conv3DBackpropInputV2",dg="Cos",fg="Cosh",ES="Cumprod",A1="Cumsum",RS="CropAndResize",AS="DenseBincount",_S="DepthToSpace",_1="DepthwiseConv2dNative",DS="DepthwiseConv2dNativeBackpropFilter",OS="DepthwiseConv2dNativeBackpropInput",$E="Diag",D1="Dilation2D",aC="Dilation2DBackpropInput",lC="Dilation2DBackpropFilter",nU="Draw",pg="RealDiv",FS="Einsum",mg="Elu",PS="EluGrad",gg="Erf",O1="Equal",xg="Exp",F1="ExpandDims",yg="Expm1",LS="FFT",MS="Fill",zS="FlipLeftRight",vg="Floor",wg="FloorDiv",P1="FusedBatchNorm",L1="GatherV2",NE="GatherNd",M1="Greater",bg="GreaterEqual",Cg="Identity",BS="IFFT",US="Imag",Sg="IsFinite",kg="IsInf",Ig="IsNan",z1="LeakyRelu",B1="Less",U1="LessEqual",TE="LinSpace",$g="Log",Ng="Log1p",W1="LogicalAnd",V1="LogicalNot",G1="LogicalOr",rU="LogSoftmax",j1="LRN",WS="LRNGrad",H1="Max",Tg="Maximum",q1="MaxPool",VS="MaxPoolGrad",K1="MaxPool3D",GS="MaxPool3DGrad",EE="MaxPoolWithArgmax",X1="Mean",Y1="Min",Eg="Minimum",Q1="MirrorPad",Rg="Mod",RE="Multinomial",Ag="Multiply",J1="Neg",Z1="NotEqual",jS="NonMaxSuppressionV3",HS="NonMaxSuppressionV4",qS="NonMaxSuppressionV5",ev="OnesLike",tv="OneHot",nv="Pack",rv="PadV2",_g="Pow",sv="Prelu",ov="Prod",AE="RaggedGather",_E="RaggedRange",DE="RaggedTensorToTensor",KS="Range",XS="Real",Dg="Reciprocal",Og="Relu",iv="Reshape",av="ResizeNearestNeighbor",YS="ResizeNearestNeighborGrad",lv="ResizeBilinear",QS="ResizeBilinearGrad",Fg="Relu6",uv="Reverse",Pg="Round",Lg="Rsqrt",OE="ScatterNd",FE="TensorScatterUpdate",PE="SearchSorted",cv="Select",Mg="Selu",hv="Slice",zg="Sin",Bg="Sinh",Ug="Sign",Wg="Sigmoid",Vg="Softplus",Gg="Sqrt",dv="Sum",fv="SpaceToBatchND",pv="SplitV",mv="Softmax",LE="SparseFillEmptyRows",ME="SparseReshape",zE="SparseSegmentMean",BE="SparseSegmentSum",UE="SparseToDense",jg="SquaredDifference",JS="Square",ZS="StaticRegexReplace",ek="StridedSlice",WE="StringNGrams",VE="StringSplit",GE="StringToHashBucketFast",Hg="Sub",qg="Tan",Kg="Tanh",Xg="Tile",tk="TopK",nk="Transform",ef="Transpose",rk="Unique",gv="Unpack",xv="UnsortedSegmentSum",yv="ZerosLike",Yg="Step",uC="FromPixels",sk="RotateWithOffset",Ly="_FusedMatMul",My="FusedConv2D",jE="FusedDepthwiseConv2D";function go(...n){ye().getBool("IS_TEST")||ye().getBool("PROD")||console.warn(...n)}function sU(...n){ye().getBool("IS_TEST")||ye().getBool("PROD")||console.log(...n)}const zy=xS("kernelRegistry",()=>new Map),cC=xS("gradRegistry",()=>new Map);function hC(n,e){const t=qE(n,e);return zy.get(t)}function $N(n){return cC.get(n)}function NN(n){const e=zy.entries(),t=[];for(;;){const{done:r,value:s}=e.next();if(r)break;const[o,i]=s,[a]=o.split("_");a===n&&t.push(i)}return t}function HE(n){const{kernelName:e,backendName:t}=n,r=qE(e,t);zy.has(r)&&go(`The kernel '${e}' for backend '${t}' is already registered`),zy.set(r,n)}function oU(n){const{kernelName:e}=n;cC.has(e)&&ye().getBool("DEBUG")&&go(`Overriding the gradient for '${e}'`),cC.set(e,n)}function qE(n,e){return`${e}_${n}`}function KE(n){return n instanceof Float32Array||n instanceof Int32Array||n instanceof Uint8Array||n instanceof Uint8ClampedArray}var Cb,TN;function iU(){if(TN)return Cb;TN=1,Cb=e;var n=null;try{n=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 e(L,_,H){this.low=L|0,this.high=_|0,this.unsigned=!!H}e.prototype.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0});function t(L){return(L&&L.__isLong__)===!0}e.isLong=t;var r={},s={};function o(L,_){var H,Y,re;return _?(L>>>=0,(re=0<=L&&L<256)&&(Y=s[L],Y)?Y:(H=a(L,(L|0)<0?-1:0,!0),re&&(s[L]=H),H)):(L|=0,(re=-128<=L&&L<128)&&(Y=r[L],Y)?Y:(H=a(L,L<0?-1:0,!1),re&&(r[L]=H),H))}e.fromInt=o;function i(L,_){if(isNaN(L))return _?I:k;if(_){if(L<0)return I;if(L>=v)return P}else{if(L<=-b)return B;if(L+1>=b)return O}return L<0?i(-L,_).neg():a(L%y|0,L/y|0,_)}e.fromNumber=i;function a(L,_,H){return new e(L,_,H)}e.fromBits=a;var l=Math.pow;function c(L,_,H){if(L.length===0)throw Error("empty string");if(L==="NaN"||L==="Infinity"||L==="+Infinity"||L==="-Infinity")return k;if(typeof _=="number"?(H=_,_=!1):_=!!_,H=H||10,H<2||36<H)throw RangeError("radix");var Y;if((Y=L.indexOf("-"))>0)throw Error("interior hyphen");if(Y===0)return c(L.substring(1),_,H).neg();for(var re=i(l(H,8)),te=k,le=0;le<L.length;le+=8){var de=Math.min(8,L.length-le),j=parseInt(L.substring(le,le+de),H);if(de<8){var ie=i(l(H,de));te=te.mul(ie).add(i(j))}else te=te.mul(re),te=te.add(i(j))}return te.unsigned=_,te}e.fromString=c;function d(L,_){return typeof L=="number"?i(L,_):typeof L=="string"?c(L,_):a(L.low,L.high,typeof _=="boolean"?_:L.unsigned)}e.fromValue=d;var p=65536,m=1<<24,y=p*p,v=y*y,b=v/2,w=o(m),k=o(0);e.ZERO=k;var I=o(0,!0);e.UZERO=I;var N=o(1);e.ONE=N;var T=o(1,!0);e.UONE=T;var A=o(-1);e.NEG_ONE=A;var O=a(-1,2147483647,!1);e.MAX_VALUE=O;var P=a(-1,-1,!0);e.MAX_UNSIGNED_VALUE=P;var B=a(0,-2147483648,!1);e.MIN_VALUE=B;var z=e.prototype;return z.toInt=function(){return this.unsigned?this.low>>>0:this.low},z.toNumber=function(){return this.unsigned?(this.high>>>0)*y+(this.low>>>0):this.high*y+(this.low>>>0)},z.toString=function(_){if(_=_||10,_<2||36<_)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(B)){var H=i(_),Y=this.div(H),re=Y.mul(H).sub(this);return Y.toString(_)+re.toInt().toString(_)}else return"-"+this.neg().toString(_);for(var te=i(l(_,6),this.unsigned),le=this,de="";;){var j=le.div(te),ie=le.sub(j.mul(te)).toInt()>>>0,se=ie.toString(_);if(le=j,le.isZero())return se+de;for(;se.length<6;)se="0"+se;de=""+se+de}},z.getHighBits=function(){return this.high},z.getHighBitsUnsigned=function(){return this.high>>>0},z.getLowBits=function(){return this.low},z.getLowBitsUnsigned=function(){return this.low>>>0},z.getNumBitsAbs=function(){if(this.isNegative())return this.eq(B)?64:this.neg().getNumBitsAbs();for(var _=this.high!=0?this.high:this.low,H=31;H>0&&(_&1<<H)==0;H--);return this.high!=0?H+33:H+1},z.isZero=function(){return this.high===0&&this.low===0},z.eqz=z.isZero,z.isNegative=function(){return!this.unsigned&&this.high<0},z.isPositive=function(){return this.unsigned||this.high>=0},z.isOdd=function(){return(this.low&1)===1},z.isEven=function(){return(this.low&1)===0},z.equals=function(_){return t(_)||(_=d(_)),this.unsigned!==_.unsigned&&this.high>>>31===1&&_.high>>>31===1?!1:this.high===_.high&&this.low===_.low},z.eq=z.equals,z.notEquals=function(_){return!this.eq(_)},z.neq=z.notEquals,z.ne=z.notEquals,z.lessThan=function(_){return this.comp(_)<0},z.lt=z.lessThan,z.lessThanOrEqual=function(_){return this.comp(_)<=0},z.lte=z.lessThanOrEqual,z.le=z.lessThanOrEqual,z.greaterThan=function(_){return this.comp(_)>0},z.gt=z.greaterThan,z.greaterThanOrEqual=function(_){return this.comp(_)>=0},z.gte=z.greaterThanOrEqual,z.ge=z.greaterThanOrEqual,z.compare=function(_){if(t(_)||(_=d(_)),this.eq(_))return 0;var H=this.isNegative(),Y=_.isNegative();return H&&!Y?-1:!H&&Y?1:this.unsigned?_.high>>>0>this.high>>>0||_.high===this.high&&_.low>>>0>this.low>>>0?-1:1:this.sub(_).isNegative()?-1:1},z.comp=z.compare,z.negate=function(){return!this.unsigned&&this.eq(B)?B:this.not().add(N)},z.neg=z.negate,z.add=function(_){t(_)||(_=d(_));var H=this.high>>>16,Y=this.high&65535,re=this.low>>>16,te=this.low&65535,le=_.high>>>16,de=_.high&65535,j=_.low>>>16,ie=_.low&65535,se=0,V=0,X=0,xe=0;return xe+=te+ie,X+=xe>>>16,xe&=65535,X+=re+j,V+=X>>>16,X&=65535,V+=Y+de,se+=V>>>16,V&=65535,se+=H+le,se&=65535,a(X<<16|xe,se<<16|V,this.unsigned)},z.subtract=function(_){return t(_)||(_=d(_)),this.add(_.neg())},z.sub=z.subtract,z.multiply=function(_){if(this.isZero())return k;if(t(_)||(_=d(_)),n){var H=n.mul(this.low,this.high,_.low,_.high);return a(H,n.get_high(),this.unsigned)}if(_.isZero())return k;if(this.eq(B))return _.isOdd()?B:k;if(_.eq(B))return this.isOdd()?B:k;if(this.isNegative())return _.isNegative()?this.neg().mul(_.neg()):this.neg().mul(_).neg();if(_.isNegative())return this.mul(_.neg()).neg();if(this.lt(w)&&_.lt(w))return i(this.toNumber()*_.toNumber(),this.unsigned);var Y=this.high>>>16,re=this.high&65535,te=this.low>>>16,le=this.low&65535,de=_.high>>>16,j=_.high&65535,ie=_.low>>>16,se=_.low&65535,V=0,X=0,xe=0,Ie=0;return Ie+=le*se,xe+=Ie>>>16,Ie&=65535,xe+=te*se,X+=xe>>>16,xe&=65535,xe+=le*ie,X+=xe>>>16,xe&=65535,X+=re*se,V+=X>>>16,X&=65535,X+=te*ie,V+=X>>>16,X&=65535,X+=le*j,V+=X>>>16,X&=65535,V+=Y*se+re*ie+te*j+le*de,V&=65535,a(xe<<16|Ie,V<<16|X,this.unsigned)},z.mul=z.multiply,z.divide=function(_){if(t(_)||(_=d(_)),_.isZero())throw Error("division by zero");if(n){if(!this.unsigned&&this.high===-2147483648&&_.low===-1&&_.high===-1)return this;var H=(this.unsigned?n.div_u:n.div_s)(this.low,this.high,_.low,_.high);return a(H,n.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?I:k;var Y,re,te;if(this.unsigned){if(_.unsigned||(_=_.toUnsigned()),_.gt(this))return I;if(_.gt(this.shru(1)))return T;te=I}else{if(this.eq(B)){if(_.eq(N)||_.eq(A))return B;if(_.eq(B))return N;var le=this.shr(1);return Y=le.div(_).shl(1),Y.eq(k)?_.isNegative()?N:A:(re=this.sub(_.mul(Y)),te=Y.add(re.div(_)),te)}else if(_.eq(B))return this.unsigned?I:k;if(this.isNegative())return _.isNegative()?this.neg().div(_.neg()):this.neg().div(_).neg();if(_.isNegative())return this.div(_.neg()).neg();te=k}for(re=this;re.gte(_);){Y=Math.max(1,Math.floor(re.toNumber()/_.toNumber()));for(var de=Math.ceil(Math.log(Y)/Math.LN2),j=de<=48?1:l(2,de-48),ie=i(Y),se=ie.mul(_);se.isNegative()||se.gt(re);)Y-=j,ie=i(Y,this.unsigned),se=ie.mul(_);ie.isZero()&&(ie=N),te=te.add(ie),re=re.sub(se)}return te},z.div=z.divide,z.modulo=function(_){if(t(_)||(_=d(_)),n){var H=(this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,_.low,_.high);return a(H,n.get_high(),this.unsigned)}return this.sub(this.div(_).mul(_))},z.mod=z.modulo,z.rem=z.modulo,z.not=function(){return a(~this.low,~this.high,this.unsigned)},z.and=function(_){return t(_)||(_=d(_)),a(this.low&_.low,this.high&_.high,this.unsigned)},z.or=function(_){return t(_)||(_=d(_)),a(this.low|_.low,this.high|_.high,this.unsigned)},z.xor=function(_){return t(_)||(_=d(_)),a(this.low^_.low,this.high^_.high,this.unsigned)},z.shiftLeft=function(_){return t(_)&&(_=_.toInt()),(_&=63)===0?this:_<32?a(this.low<<_,this.high<<_|this.low>>>32-_,this.unsigned):a(0,this.low<<_-32,this.unsigned)},z.shl=z.shiftLeft,z.shiftRight=function(_){return t(_)&&(_=_.toInt()),(_&=63)===0?this:_<32?a(this.low>>>_|this.high<<32-_,this.high>>_,this.unsigned):a(this.high>>_-32,this.high>=0?0:-1,this.unsigned)},z.shr=z.shiftRight,z.shiftRightUnsigned=function(_){if(t(_)&&(_=_.toInt()),_&=63,_===0)return this;var H=this.high;if(_<32){var Y=this.low;return a(Y>>>_|H<<32-_,H>>>_,this.unsigned)}else return _===32?a(H,0,this.unsigned):a(H>>>_-32,0,this.unsigned)},z.shru=z.shiftRightUnsigned,z.shr_u=z.shiftRightUnsigned,z.toSigned=function(){return this.unsigned?a(this.low,this.high,!1):this},z.toUnsigned=function(){return this.unsigned?this:a(this.low,this.high,!0)},z.toBytes=function(_){return _?this.toBytesLE():this.toBytesBE()},z.toBytesLE=function(){var _=this.high,H=this.low;return[H&255,H>>>8&255,H>>>16&255,H>>>24,_&255,_>>>8&255,_>>>16&255,_>>>24]},z.toBytesBE=function(){var _=this.high,H=this.low;return[_>>>24,_>>>16&255,_>>>8&255,_&255,H>>>24,H>>>16&255,H>>>8&255,H&255]},e.fromBytes=function(_,H,Y){return Y?e.fromBytesLE(_,H):e.fromBytesBE(_,H)},e.fromBytesLE=function(_,H){return new e(_[0]|_[1]<<8|_[2]<<16|_[3]<<24,_[4]|_[5]<<8|_[6]<<16|_[7]<<24,H)},e.fromBytesBE=function(_,H){return new e(_[4]<<24|_[5]<<16|_[6]<<8|_[7],_[0]<<24|_[1]<<16|_[2]<<8|_[3],H)},Cb}var XE=iU();const YE=xf(XE),aU=xT({__proto__:null,default:YE},[XE]);const Rc=YE||aU;function vv(n){return Rc.fromString(n,!0,16)}const QE=vv("c3a5c85c97cb3127"),Ec=vv("b492b66fbe98f273"),is=vv("9ae16a3b2f90404f");function dC(n){return n.xor(n.shru(47))}function JE(n,e,t){const r=n.slice(e,e+t);return Rc.fromBytes(Array.from(r),!0,!0)}function pn(n,e){return JE(n,e,8)}function EN(n,e){return JE(n,e,4)}function mr(n,e){return e===0?n:n.shru(e).or(n.shl(64-e))}function ru(n,e,t=vv("9ddfea08eb382d69")){let r=n.xor(e).mul(t);r=r.xor(r.shru(47));let s=e.xor(r).mul(t);return s=s.xor(s.shru(47)),s=s.mul(t),s}function lU(n,e,t,r,s,o){s=s.add(n),o=mr(o.add(s).add(r),21);const i=s;return s=s.add(e),s=s.add(t),o=o.add(mr(s,44)),[s.add(r),o.add(i)]}function ry(n,e,t,r){return lU(pn(n,e),pn(n,e+8),pn(n,e+16),pn(n,e+24),t,r)}function uU(n,e=n.length){if(e>=8){const t=is.add(e*2),r=pn(n,0).add(is),s=pn(n,e-8),o=mr(s,37).mul(t).add(r),i=mr(r,25).add(s).mul(t);return ru(o,i,t)}if(e>=4){const t=is.add(e*2),r=EN(n,0);return ru(r.shl(3).add(e),EN(n,e-4),t)}if(e>0){const t=n[0],r=n[e>>1],s=n[e-1],o=t+(r<<8),i=e+(s<<2);return dC(is.mul(o).xor(QE.mul(i))).mul(is)}return is}function cU(n,e=n.length){const t=is.add(e*2),r=pn(n,0).mul(Ec),s=pn(n,8),o=pn(n,e-8).mul(t),i=pn(n,e-16).mul(is);return ru(mr(r.add(s),43).add(mr(o,30)).add(i),r.add(mr(s.add(is),18)).add(o),t)}function hU(n,e=n.length){const t=is.add(e*2),r=pn(n,0).mul(is),s=pn(n,8),o=pn(n,e-8).mul(t),i=pn(n,e-16).mul(is),a=mr(r.add(s),43).add(mr(o,30)).add(i),l=ru(a,r.add(mr(s.add(is),18)).add(o),t),c=pn(n,16).mul(t),d=pn(n,24),p=a.add(pn(n,e-32)).mul(t),m=l.add(pn(n,e-24)).mul(t);return ru(mr(c.add(d),43).add(mr(p,30)).add(m),c.add(mr(d.add(r),18)).add(p),t)}function dU(n,e=n.length){const t=Rc.fromNumber(81,!0);if(e<=32)return e<=16?uU(n,e):cU(n,e);if(e<=64)return hU(n,e);let r=t,s=t.mul(Ec).add(113),o=dC(s.mul(is).add(113)).mul(is),i=[Rc.UZERO,Rc.UZERO],a=[Rc.UZERO,Rc.UZERO];r=r.mul(is).add(pn(n,0));let l=0;const c=(e-1>>6)*64,d=c+(e-1&63)-63;do r=mr(r.add(s).add(i[0]).add(pn(n,l+8)),37).mul(Ec),s=mr(s.add(i[1]).add(pn(n,l+48)),42).mul(Ec),r=r.xor(a[1]),s=s.add(i[0]).add(pn(n,l+40)),o=mr(o.add(a[0]),33).mul(Ec),i=ry(n,l,i[1].mul(Ec),r.add(a[0])),a=ry(n,l+32,o.add(a[1]),s.add(pn(n,l+16))),[o,r]=[r,o],l+=64;while(l!==c);const p=Ec.add(o.and(255).shl(1));return l=d,a[0]=a[0].add(e-1&63),i[0]=i[0].add(a[0]),a[0]=a[0].add(i[0]),r=mr(r.add(s).add(i[0]).add(pn(n,l+8)),37).mul(p),s=mr(s.add(i[1]).add(pn(n,l+48)),42).mul(p),r=r.xor(a[1].mul(9)),s=s.add(i[0].mul(9).add(pn(n,l+40))),o=mr(o.add(a[0]),33).mul(p),i=ry(n,l,i[1].mul(p),r.add(a[0])),a=ry(n,l+32,o.add(a[1]),s.add(pn(n,l+16))),[o,r]=[r,o],ru(ru(i[0],a[0],p).add(dC(s).mul(QE)).add(o),ru(i[1],a[1],p).add(r),p)}function mu(n,e){return e==="string"?su(n):ah([n],e)}function fU(n,e){return n instanceof Float32Array&&e==="float32"||n instanceof Int32Array&&e==="int32"||n instanceof Uint8Array&&e==="bool"}function ah(n,e){if(e==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(n)&&(n=jc(n)),ye().getBool("DEBUG")&&G4(n,e),fU(n,e))return n;if(e==null||e==="float32"||e==="complex64")return new Float32Array(n);if(e==="int32")return new Int32Array(n);if(e==="bool"){const t=new Uint8Array(n.length);for(let r=0;r<t.length;++r)Math.round(n[r])!==0&&(t[r]=1);return t}else throw new Error(`Unknown data type ${e}`)}function Cs(){return ye().platform.now()}function su(n,e="utf-8"){return e=e||"utf-8",ye().platform.encode(n,e)}function au(n,e="utf-8"){return e=e||"utf-8",ye().platform.decode(n,e)}function qo(n){return ye().platform.isTypedArray!=null?ye().platform.isTypedArray(n):KE(n)}function jc(n,e=[],t=!1){if(e==null&&(e=[]),typeof n=="boolean"||typeof n=="number"||typeof n=="string"||gS(n)||n==null||qo(n)&&t)e.push(n);else if(Array.isArray(n)||qo(n))for(let r=0;r<n.length;++r)jc(n[r],e,t);else{let r=-1;for(const s of Object.keys(n))/^([1-9]+[0-9]*|0)$/.test(s)&&(r=Math.max(r,Number(s)));for(let s=0;s<=r;s++)jc(n[s],e,t)}return e}class pU{constructor(e,t){this.backendTimer=e,this.logger=t,t==null&&(this.logger=new gU)}profileKernel(e,t,r){let s;const o=()=>{s=r()};let i;const a=Cs();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(o);else{o();for(const c of s)c.dataSync();i=Promise.resolve({kernelMs:Cs()-a})}if(ye().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let c=0;c<s.length;c++){const d=s[c];d.data().then(p=>{mU(p,d.dtype,e)})}return{kernelName:e,outputs:s,inputs:t,timeMs:i.then(c=>c.kernelMs),extraInfo:i.then(c=>c.getExtraProfileInfo!=null?c.getExtraProfileInfo():"")}}logKernelProfile(e){const{kernelName:t,outputs:r,timeMs:s,inputs:o,extraInfo:i}=e;r.forEach(a=>{Promise.all([a.data(),s,i]).then(l=>{this.logger.logKernelProfile(t,a,l[0],l[1],o,l[2])})})}}function mU(n,e,t){if(e!=="float32")return!1;for(let r=0;r<n.length;r++){const s=n[r];if(isNaN(s)||!isFinite(s))return console.warn(`Found ${s} in the result of '${t}'`),!0}return!1}class gU{logKernelProfile(e,t,r,s,o,i){const a=typeof s=="number"?Zd(`${s}ms`,9):s.error,l=Zd(e,25),c=t.rank,d=t.size,p=Zd(t.shape.toString(),14);let m="";for(const y in o){const v=o[y];if(v!=null){const b=v.shape||t.shape,w=b.length;m+=`${y}: ${w}D ${w>0?b:""} `}}console.log(`%c${l} %c${a} %c${c}D ${p} %c${d} %c${m} %c${i}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}function xU(n,e,t){const r={},s={};for(let l=0;l<e.length;l++)r[e[l].id]=!0;for(let l=0;l<n.length;l++){const c=n[l],d=c.inputs;for(const p in d){const m=d[p];let y=!1;for(let v=0;v<e.length;v++)if(r[m.id]){c.outputs.forEach(b=>r[b.id]=!0),y=!0,s[c.id]=!0;break}if(y)break}}const o={};o[t.id]=!0;const i={};for(let l=n.length-1;l>=0;l--){const c=n[l],d=c.inputs;for(let p=0;p<c.outputs.length;p++)if(o[c.outputs[p].id]){for(const m in d)o[d[m].id]=!0,i[c.id]=!0;break}}const a=[];for(let l=0;l<n.length;l++){const c=n[l];if(s[c.id]&&i[c.id]){const d={};for(const m in c.inputs){const y=c.inputs[m];r[y.id]&&(d[m]=y)}const p=Object.assign({},c);p.inputs=d,p.outputs=c.outputs,a.push(p)}}return a}function yU(n,e,t,r){for(let s=e.length-1;s>=0;s--){const o=e[s],i=[];if(o.outputs.forEach(l=>{const c=n[l.id];c!=null?i.push(c):i.push(null)}),o.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${o.kernelName}.`);const a=o.gradient(i);for(const l in o.inputs){if(!(l in a))throw new Error(`Cannot backprop through input ${l}. Available gradients found: ${Object.keys(a)}.`);const c=t(()=>a[l]());if(c.dtype!=="float32")throw new Error(`Error in gradient for op ${o.kernelName}. The gradient of input ${l} must have 'float32' dtype, but has '${c.dtype}'`);const d=o.inputs[l];if(!Xt(c.shape,d.shape))throw new Error(`Error in gradient for op ${o.kernelName}. The gradient of input '${l}' has shape '${c.shape}', which does not match the shape of the input '${d.shape}'`);if(n[d.id]==null)n[d.id]=c;else{const p=n[d.id];n[d.id]=r(p,c),p.dispose()}}}}const RN=20,pm=3,Sb=7;function vU(n,e,t,r){const s=tt(e),o=wU(n,e,t,s),i=e.length,a=vy(n,e,t,s,o),l=["Tensor"];return r&&(l.push(` dtype: ${t}`),l.push(` rank: ${i}`),l.push(` shape: [${e}]`),l.push(" values:")),l.push(a.map(c=>" "+c).join(`
`)),l.join(`
`)}function wU(n,e,t,r){const s=Se(e),o=r[r.length-1],i=new Array(o).fill(0),a=e.length,l=t==="complex64"?wm(n):n;if(a>1)for(let c=0;c<s/o;c++){const d=c*o;for(let p=0;p<o;p++)i[p]=Math.max(i[p],vm(l[d+p],0,t).length)}return i}function vm(n,e,t){let r;return Array.isArray(n)?r=`${parseFloat(n[0].toFixed(Sb))} + ${parseFloat(n[1].toFixed(Sb))}j`:tg(n)?r=`'${n}'`:t==="bool"?r=ZE(n):r=parseFloat(n.toFixed(Sb)).toString(),Zd(r,e)}function ZE(n){return n===0?"false":"true"}function vy(n,e,t,r,s,o=!0){const i=t==="complex64"?2:1,a=e[0],l=e.length;if(l===0){if(t==="complex64"){const b=wm(n);return[vm(b[0],0,t)]}return t==="bool"?[ZE(n[0])]:[n[0].toString()]}if(l===1){if(a>RN){const w=pm*i;let k=Array.from(n.slice(0,w)),I=Array.from(n.slice((a-pm)*i,a*i));return t==="complex64"&&(k=wm(k),I=wm(I)),["["+k.map((N,T)=>vm(N,s[T],t)).join(", ")+", ..., "+I.map((N,T)=>vm(N,s[a-pm+T],t)).join(", ")+"]"]}return["["+(t==="complex64"?wm(n):Array.from(n)).map((w,k)=>vm(w,s[k],t)).join(", ")+"]"]}const c=e.slice(1),d=r.slice(1),p=r[0]*i,m=[];if(a>RN){for(let b=0;b<pm;b++){const w=b*p,k=w+p;m.push(...vy(n.slice(w,k),c,t,d,s,!1))}m.push("...");for(let b=a-pm;b<a;b++){const w=b*p,k=w+p;m.push(...vy(n.slice(w,k),c,t,d,s,b===a-1))}}else for(let b=0;b<a;b++){const w=b*p,k=w+p;m.push(...vy(n.slice(w,k),c,t,d,s,b===a-1))}const y=l===2?",":"";m[0]="["+(a>0?m[0]+y:"");for(let b=1;b<m.length-1;b++)m[b]=" "+m[b]+y;let v=`,
`;for(let b=2;b<l;b++)v+=`
`;return m[m.length-1]=" "+m[m.length-1]+"]"+(o?"":v),m}function wm(n){const e=[];for(let t=0;t<n.length;t+=2)e.push([n[t],n[t+1]]);return e}class Ar{constructor(e,t,r){if(this.dtype=t,this.shape=e.slice(),this.size=Se(e),r!=null){const s=r.length;U(s===this.size,()=>`Length of values '${s}' does not match the size inferred by the shape '${this.size}'.`)}if(t==="complex64")throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=r||Mn(t,this.size),this.strides=tt(e)}set(e,...t){t.length===0&&(t=[0]),U(t.length===this.rank,()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`);const r=this.locToIndex(t);this.values[r]=e}get(...e){e.length===0&&(e=[0]);let t=0;for(const s of e){if(s<0||s>=this.shape[t]){const o=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(o)}t++}let r=e[e.length-1];for(let s=0;s<e.length-1;++s)r+=this.strides[s]*e[s];return this.values[r]}locToIndex(e){if(this.rank===0)return 0;if(this.rank===1)return e[0];let t=e[e.length-1];for(let r=0;r<e.length-1;++r)t+=this.strides[r]*e[r];return t}indexToLoc(e){if(this.rank===0)return[];if(this.rank===1)return[e];const t=new Array(this.shape.length);for(let r=0;r<t.length-1;++r)t[r]=Math.floor(e/this.strides[r]),e-=t[r]*this.strides[r];return t[t.length-1]=e,t}get rank(){return this.shape.length}toTensor(){return yi().makeTensor(this.values,this.shape,this.dtype)}}let yi=null,Hd=null;function bU(n){yi=n}function CU(n){Hd=n}class tr{constructor(e,t,r,s){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=Se(e),this.strides=tt(e),this.dataId=r,this.id=s,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){const e=await this.data();return Hd.buffer(this.shape,this.dtype,e)}bufferSync(){return Hd.buffer(this.shape,this.dtype,this.dataSync())}async array(){const e=await this.data();return Ci(this.shape,e,this.dtype==="complex64")}arraySync(){return Ci(this.shape,this.dataSync(),this.dtype==="complex64")}async data(){this.throwIfDisposed();const e=yi().read(this.dataId);if(this.dtype==="string"){const t=await e;try{return t.map(r=>au(r))}catch{throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return e}dataToGPU(e){return this.throwIfDisposed(),yi().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=yi().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>au(t))}catch{throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return e}async bytes(){this.throwIfDisposed();const e=await yi().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(this.kerasMask&&this.kerasMask.dispose(),yi().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return Hd.print(this,e)}clone(){return this.throwIfDisposed(),Hd.clone(this)}toString(e=!1){const t=this.dataSync();return vU(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Hd.cast(this,e)}variable(e=!0,t,r){return this.throwIfDisposed(),yi().makeVariable(this,e,t,r)}}Object.defineProperty(tr,Symbol.hasInstance,{value:n=>!!n&&n.data!=null&&n.dataSync!=null&&n.throwIfDisposed!=null});function Ce(){return xS("Tensor",()=>tr)}Ce();class By extends tr{constructor(e,t,r,s){super(e.shape,e.dtype,e.dataId,s),this.trainable=t,this.name=r}assign(e){if(e.dtype!==this.dtype)throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!Xt(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);yi().disposeTensor(this),this.dataId=e.dataId,yi().incRef(this,null)}dispose(){yi().disposeVariable(this),this.isDisposedInternal=!0}}Object.defineProperty(By,Symbol.hasInstance,{value:n=>n instanceof tr&&n.assign!=null&&n.assign instanceof Function});var AN;(function(n){n.R0="R0",n.R1="R1",n.R2="R2",n.R3="R3",n.R4="R4",n.R5="R5",n.R6="R6"})(AN||(AN={}));var fC;(function(n){n.float32="float32",n.int32="int32",n.bool="int32",n.complex64="complex64"})(fC||(fC={}));var pC;(function(n){n.float32="float32",n.int32="int32",n.bool="bool",n.complex64="complex64"})(pC||(pC={}));var mC;(function(n){n.float32="float32",n.int32="float32",n.bool="float32",n.complex64="complex64"})(mC||(mC={}));var gC;(function(n){n.float32="complex64",n.int32="complex64",n.bool="complex64",n.complex64="complex64"})(gC||(gC={}));const SU={float32:mC,int32:fC,bool:pC,complex64:gC};function Ys(n,e){if(n==="string"||e==="string"){if(n==="string"&&e==="string")return"string";throw new Error(`Can not upcast ${n} with ${e}`)}return SU[n][e]}function ok(n){return Ys(n,"int32")}function eR(n){return n!=null&&typeof n=="object"&&"texture"in n&&n.texture instanceof WebGLTexture}function tR(n){return typeof GPUBuffer<"u"&&n!=null&&typeof n=="object"&&"buffer"in n&&n.buffer instanceof GPUBuffer}function Un(n,e){if(n.dtype===e.dtype)return[n,e];const t=Ys(n.dtype,e.dtype);return[n.cast(t),e.cast(t)]}function nR(n){const e=[];return rR(n,e,new Set),e}function rR(n,e,t){if(n==null)return;if(n instanceof tr){e.push(n);return}if(!kU(n))return;const r=n;for(const s in r){const o=r[s];t.has(o)||(t.add(o),rR(o,e,t))}}function kU(n){return Array.isArray(n)||typeof n=="object"}function kb(n){return n.kernelName!=null}class _N{constructor(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map(e=>e.name)))}}}dispose(){for(const e in this.registeredVariables)this.registeredVariables[e].dispose()}}class af{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new _N}async ready(){if(this.pendingBackendInit!=null)return this.pendingBackendInit.then(()=>{});if(this.backendInstance!=null)return;const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const r=e[t];if(await this.initializeBackend(r).success){await this.setBackend(r);return}}throw new Error("Could not initialize any backends, all backend initializations failed.")}get backend(){if(this.pendingBackendInit!=null)throw new Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);if(this.backendInstance==null){const{name:e,asyncInit:t}=this.initializeBackendsAndReturnBest();if(t)throw new Error(`The highest priority backend '${e}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);this.setBackend(e)}return this.backendInstance}backendNames(){return Object.keys(this.registryFactory)}findBackend(e){if(!(e in this.registry))if(e in this.registryFactory){const{asyncInit:t}=this.initializeBackend(e);if(t)return null}else return null;return this.registry[e]}findBackendFactory(e){return e in this.registryFactory?this.registryFactory[e].factory:null}registerBackend(e,t,r=1){return e in this.registryFactory?(go(`${e} backend was already registered. Reusing existing backend factory.`),!1):(this.registryFactory[e]={factory:t,priority:r},!0)}async setBackend(e){if(this.registryFactory[e]==null)throw new Error(`Backend name '${e}' not found in registry`);if(this.backendName=e,this.registry[e]==null){this.backendInstance=null;const{success:t,asyncInit:r}=this.initializeBackend(e);if(!(r?await t:t))return!1}return this.backendInstance=this.registry[e],this.setupRegisteredKernels(),this.profiler=new pU(this.backendInstance),!0}setupRegisteredKernels(){NN(this.backendName).forEach(t=>{t.setupFunc!=null&&t.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){NN(e).forEach(r=>{r.disposeFunc!=null&&r.disposeFunc(this.registry[e])})}initializeBackend(e){const t=this.registryFactory[e];if(t==null)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const r=t.factory();if(r&&!(r instanceof hS)&&typeof r.then=="function"){const s=++this.pendingBackendInitId,o=r.then(i=>s<this.pendingBackendInitId?!1:(this.registry[e]=i,this.pendingBackendInit=null,!0)).catch(i=>(s<this.pendingBackendInitId||(this.pendingBackendInit=null,go(`Initialization of backend ${e} failed`),go(i.stack||i.message)),!1));return this.pendingBackendInit=o,{success:o,asyncInit:!0}}else return this.registry[e]=r,{success:!0,asyncInit:!1}}catch(r){return go(`Initialization of backend ${e} failed`),go(r.stack||r.message),{success:!1,asyncInit:!1}}}removeBackend(e){if(!(e in this.registryFactory))throw new Error(`${e} backend not found in registry`);this.backendName===e&&this.pendingBackendInit!=null&&this.pendingBackendInitId++,e in this.registry&&(this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e]),delete this.registryFactory[e],this.backendName===e&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)}getSortedBackends(){if(Object.keys(this.registryFactory).length===0)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort((e,t)=>this.registryFactory[t].priority-this.registryFactory[e].priority)}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const r=e[t],{success:s,asyncInit:o}=this.initializeBackend(r);if(o||s)return{name:r,asyncInit:o}}throw new Error("Could not initialize any backends, all backend initializations failed.")}moveData(e,t){const r=this.state.tensorInfo.get(t),s=r.backend,o=this.readSync(t),i=s.refCount(t);s.disposeData(t,!0),r.backend=e,e.move(t,o,r.shape,r.dtype,i),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++}tidy(e,t){let r=null;if(t==null){if(typeof e!="function")throw new Error("Please provide a function to tidy()");t=e}else{if(typeof e!="string"&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if(typeof t!="function")throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");r=e}let s;return this.scopedRun(()=>this.startScope(r),()=>this.endScope(s),()=>(s=t(),s instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),s))}scopedRun(e,t,r){e();try{const s=r();return t(),s}catch(s){throw t(),s}}nextTensorId(){return af.nextTensorId++}nextVariableId(){return af.nextVariableId++}clone(e){const t=ae.runKernel(Cg,{x:e}),r={x:e},s=i=>({x:()=>{const a="float32",l={x:i},c={dtype:a};return ae.runKernel(ug,l,c)}}),o=[];return this.addTapeNode(this.state.activeScope.name,r,[t],s,o,{}),t}runKernel(e,t,r){if(this.backendName==null&&this.backend,!(hC(e,this.backendName)!=null))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:r})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,r){const s=this.backend.numDataIds();let o=0;r.forEach(l=>{o+=l.dtype==="complex64"?3:1});const i=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],a=s-t-o-i;if(a>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${a} data ids) after running '${e}'`)}runKernelFunc(e){let t,r=[];const s=this.isTapeOn(),o=this.state.numBytes,i=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let a;this.backendName==null&&this.backend;let l;const c=kb(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(kb(e)){const{kernelName:v,inputs:b,attrs:w}=e;this.backendName==null&&this.backend;const k=hC(v,this.backendName);U(k!=null,()=>`Cannot find registered kernel '${v}' for backend '${this.backendName}'`),a=()=>{const I=this.backend.numDataIds();l=k.kernelFunc({inputs:b,attrs:w,backend:this.backend});const N=Array.isArray(l)?l:[l];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(v,I,N);const T=N.map(A=>A.rank!=null?A:this.makeTensorFromTensorInfo(A));if(s){const A=this.getTensorsForGradient(v,b,T);r=this.saveTensorsForBackwardMode(A)}return T}}else{const{forwardFunc:v}=e,b=w=>{s&&(r=w.map(k=>this.keep(this.clone(k))))};a=()=>{const w=this.backend.numDataIds();l=this.tidy(()=>v(this.backend,b));const k=Array.isArray(l)?l:[l];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(c,w,k),k}}const{inputs:d,attrs:p}=e,m=kb(e)?null:e.backwardsFunc;let y;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{!this.ENV.getBool("DEBUG")&&!this.state.profiling?t=a():(y=this.profiler.profileKernel(c,d,()=>a()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(y),t=y.outputs)}),s&&this.addTapeNode(c,d,t,m,r,p),this.state.profiling&&this.state.activeProfile.kernels.push({name:c,bytesAdded:this.state.numBytes-o,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-i,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(d).map(v=>d[v]!=null?d[v].shape:null),outputShapes:t.map(v=>v.shape),kernelTimeMs:y.timeMs,extraInfo:y.extraInfo}),Array.isArray(l)?t:t[0]}saveTensorsForBackwardMode(e){return e.map(r=>this.keep(this.clone(r)))}getTensorsForGradient(e,t,r){const s=$N(e);if(s!=null){const o=s.inputsToSave||[],i=s.outputsToSave||[];let a;s.saveAllInputs?(U(Array.isArray(t),()=>"saveAllInputs is true, expected inputs to be an array."),a=Object.keys(t).map(c=>t[c])):a=o.map(c=>t[c]);const l=r.filter((c,d)=>i[d]);return a.concat(l)}return[]}makeTensor(e,t,r,s){if(e==null)throw new Error("Values passed to engine.makeTensor() are null");r=r||"float32",s=s||this.backend;let o=e;r==="string"&&tg(e[0])&&(o=e.map(l=>su(l)));const i=s.write(o,t,r),a=new tr(t,r,i,this.nextTensorId());if(this.trackTensor(a,s),r==="string"){const l=this.state.tensorInfo.get(i),c=H4(o);this.state.numBytes+=c-l.bytes,l.bytes=c}return a}makeTensorFromDataId(e,t,r,s){r=r||"float32";const o={dataId:e,shape:t,dtype:r};return this.makeTensorFromTensorInfo(o,s)}makeTensorFromTensorInfo(e,t){const{dataId:r,shape:s,dtype:o}=e,i=new tr(s,o,r,this.nextTensorId());return this.trackTensor(i,t),i}makeVariable(e,t=!0,r,s){r=r||this.nextVariableId().toString(),s!=null&&s!==e.dtype&&(e=e.cast(s));const o=new By(e,t,r,this.nextTensorId());if(this.state.registeredVariables[o.name]!=null)throw new Error(`Variable with name ${o.name} was already registered`);return this.state.registeredVariables[o.name]=o,this.incRef(o,this.backend),o}trackTensor(e,t){this.state.numTensors++,e.dtype==="string"&&this.state.numStringTensors++;let r=0;e.dtype!=="complex64"&&e.dtype!=="string"&&(r=e.size*Py(e.dtype)),this.state.numBytes+=r,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:r})),e instanceof By||this.track(e)}incRef(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)}removeDataId(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))return;const t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,e.dtype==="string"&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),e.dtype!=="complex64"&&e.dtype!=="string"){const r=e.size*Py(e.dtype);this.state.numBytes-=r}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(const e in this.state.registeredVariables){const t=this.state.registeredVariables[e];this.disposeVariable(t)}}disposeVariable(e){this.disposeTensor(e),this.state.registeredVariables[e.name]!=null&&delete this.state.registeredVariables[e.name]}memory(){const e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,e.reasons==null&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e}async profile(e){this.state.profiling=!0;const t=this.state.numBytes,r=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map(s=>s.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-r;for(const s of this.state.activeProfile.kernels)s.kernelTimeMs=await s.kernelTimeMs,s.extraInfo=await s.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&this.state.kernelDepth===0}addTapeNode(e,t,r,s,o,i){const a={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:r,saved:o},l=$N(e);l!=null&&(s=l.gradFunc),s!=null&&(a.gradient=c=>(c=c.map((d,p)=>{if(d==null){const m=r[p],y=Gr(m.size,m.dtype);return this.makeTensor(y,m.shape,m.dtype)}return d}),s(c.length>1?c:c[0],o,i))),this.state.activeTape.push(a)}keep(e){return e.kept=!0,e}startTape(){this.state.gradientDepth===0&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){const t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){const t=nR(e),r=new Set(t.map(o=>o.id));for(let o=0;o<this.state.activeScope.track.length;o++){const i=this.state.activeScope.track[o];!i.kept&&!r.has(i.id)&&i.dispose()}const s=this.state.scopeStack.pop();this.state.activeScope=this.state.scopeStack.length===0?null:this.state.scopeStack[this.state.scopeStack.length-1],t.forEach(o=>{!o.kept&&o.scopeId===s.id&&this.track(o)})}gradients(e,t,r,s=!1){if(U(t.length>0,()=>"gradients() received an empty list of xs."),r!=null&&r.dtype!=="float32")throw new Error(`dy must have 'float32' dtype, but has '${r.dtype}'`);const o=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",e));U(o instanceof tr,()=>"The result y returned by f() must be a tensor.");const i=xU(this.state.activeTape,t,o);if(!s&&i.length===0&&t.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",()=>{const a={};a[o.id]=r??IU(o.shape),yU(a,i,c=>this.tidy(c),$U);const l=t.map(c=>a[c.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(c=>{for(const d of c.saved)d.dispose()}),this.state.activeTape=null),{value:o,grads:l}})}customGrad(e){return U(oC(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{U(t.every(a=>a instanceof tr),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let r;const s={};t.forEach((a,l)=>{s[l]=a});const o=(a,l)=>(r=e(...t,l),U(r.value instanceof tr,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),U(oC(r.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),r.value),i=(a,l)=>{const c=r.gradFunc(a,l),d=Array.isArray(c)?c:[c];U(d.length===t.length,()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."),U(d.every(m=>m instanceof tr),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");const p={};return d.forEach((m,y)=>{p[y]=()=>m}),p};return this.runKernelFunc({forwardFunc:o,backwardsFunc:i,inputs:s})}}readSync(e){return this.state.tensorInfo.get(e).backend.readSync(e)}read(e){return this.state.tensorInfo.get(e).backend.read(e)}readToGPU(e,t){return this.state.tensorInfo.get(e).backend.readToGPU(e,t)}async time(e){const t=Cs(),r=await this.backend.time(e);return r.wallMs=Cs()-t,r}track(e){return this.state.activeScope!=null&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new _N;for(const e in this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}}af.nextTensorId=0;af.nextVariableId=0;function IU(n){const e=mS(Se(n),"float32");return ae.makeTensor(e,n,"float32")}function sR(){const n=kE();if(n._tfengine==null){const e=new X4(n);n._tfengine=new af(e)}return Z4(n._tfengine.ENV),bU(()=>n._tfengine),n._tfengine}const ae=sR();function $U(n,e){const t={a:n,b:e};return ae.runKernel(kf,t)}function NU(){return typeof navigator<"u"&&navigator!=null}function oR(n){if(n||NU()){if(n||(n=navigator),n.product==="ReactNative")return!0;const e=n.userAgent||n.vendor||(typeof window<"u"?window.opera:"");if(!e){const t=n;return t.userAgentData&&t.userAgentData.mobile}return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4))}return!1}function iR(){return typeof window<"u"&&window.document!=null||typeof WorkerGlobalScope<"u"}const $s=ye();$s.registerFlag("DEBUG",()=>!1,n=>{n&&console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.")});$s.registerFlag("IS_BROWSER",()=>iR());$s.registerFlag("IS_NODE",()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u");$s.registerFlag("IS_CHROME",()=>typeof navigator<"u"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));$s.registerFlag("IS_SAFARI",()=>typeof navigator<"u"&&navigator!=null&&navigator.userAgent!=null&&/Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor));$s.registerFlag("PROD",()=>!1);$s.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>$s.getBool("DEBUG"));$s.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);$s.registerFlag("IS_TEST",()=>!1);$s.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>$s.getBool("DEBUG"));$s.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);$s.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",()=>!1);$s.registerFlag("USE_SETTIMEOUTCUSTOM",()=>!1);function Qg(n,e){let t=n;if(qo(n))return e==="string"?[]:[n.length];if(eR(n)){const s=n.channels||"RGBA";return[n.height,n.width*s.length]}else if(tR(n))return[n.buffer.size/(e==null?4:Py(e))];if(!Array.isArray(n))return[];const r=[];for(;Array.isArray(t)||qo(t)&&e!=="string";)r.push(t.length),t=t[0];return Array.isArray(n)&&ye().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&aR(n,r,[]),r}function aR(n,e,t){if(t=t||[],!Array.isArray(n)&&!qo(n)){U(e.length===0,()=>`Element arr[${t.join("][")}] is a primitive, but should be an array/TypedArray of ${e[0]} elements`);return}U(e.length>0,()=>`Element arr[${t.join("][")}] should be a primitive, but is an array of ${n.length} elements`),U(n.length===e[0],()=>`Element arr[${t.join("][")}] should have ${e[0]} elements, but has ${n.length} elements`);const r=e.slice(1);for(let s=0;s<n.length;++s)aR(n[s],r,t.concat(s))}function DN(n,e,t,r){if(n!=="string_or_numeric"){if(n==null)throw new Error("Expected dtype cannot be null.");if(n!=="numeric"&&n!==e||n==="numeric"&&e==="string")throw new Error(`Argument '${t}' passed to '${r}' must be ${n} tensor, but got ${e} tensor`)}}function K(n,e,t,r="numeric"){if(n instanceof Ce())return DN(r,n.dtype,e,t),n;let s=Cf(n);if(s!=="string"&&["bool","int32","float32"].indexOf(r)>=0&&(s=r),DN(r,s,e,t),n==null||!qo(n)&&!Array.isArray(n)&&typeof n!="number"&&typeof n!="boolean"&&typeof n!="string"){const l=n==null?"null":n.constructor.name;throw new Error(`Argument '${e}' passed to '${t}' must be a Tensor or TensorLike, but got '${l}'`)}const o=Qg(n,s);!qo(n)&&!Array.isArray(n)&&(n=[n]);const a=s!=="string"?ah(n,s):jc(n,[],!0);return ae.makeTensor(a,o,s)}function lR(n,e,t,r="numeric"){if(!Array.isArray(n))throw new Error(`Argument ${e} passed to ${t} must be a \`Tensor[]\` or \`TensorLike[]\``);return n.map((o,i)=>K(o,`${e}[${i}]`,t,r))}const TU="__op";function he(n){const e=Object.keys(n);if(e.length!==1)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${e.length} keys.`);let t=e[0];const r=n[t];t.endsWith("_")&&(t=t.substring(0,t.length-1)),t=t+TU;const s=(...o)=>{ae.startScope(t);try{const i=r(...o);return gS(i)&&console.error("Cannot return a Promise inside of tidy."),ae.endScope(i),i}catch(i){throw ae.endScope(null),i}};return Object.defineProperty(s,"name",{value:t,configurable:!0}),s}function EU(n,e){const t=K(n,"real","complex"),r=K(e,"imag","complex");fS(t.shape,r.shape,`real and imag shapes, ${t.shape} and ${r.shape}, must match in call to tf.complex().`);const s={real:t,imag:r};return ae.runKernel(IS,s)}const Hc=he({complex_:EU});function Jg(n,e,t,r){if(r==null)r=Cf(n);else if(r==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(tR(n)||eR(n)){if(r!=="float32"&&r!=="int32")throw new Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${r}.`);return ae.backend.createTensorFromGPUData(n,e||t,r)}if(!qo(n)&&!Array.isArray(n)&&typeof n!="number"&&typeof n!="boolean"&&typeof n!="string")throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(e!=null){al(e);const s=Se(e),o=Se(t);U(s===o,()=>`Based on the provided shape, [${e}], the tensor should have ${s} values but has ${o}`);for(let i=0;i<t.length;++i){const a=t[i],l=i===t.length-1?a!==Se(e.slice(i)):!0;U(t[i]===e[i]||!l,()=>`Error creating a new Tensor. Inferred shape (${t}) does not match the provided shape (${e}). `)}}return!qo(n)&&!Array.isArray(n)&&(n=[n]),e=e||t,n=r!=="string"?ah(n,r):jc(n,[],!0),ae.makeTensor(n,e,r)}function $m(n,e,t){const r=Qg(n,t);return Jg(n,e,r,t)}const Uy={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};class gu{static join(e){return new gu(e).slice()}constructor(e){if(this.shards=[],this.previousShardIndex=0,e==null||(e instanceof Array||(e=[e]),e=e.map(r=>qo(r)?r.buffer:r),e.length===0))return;this.bufferUniformSize=e[0].byteLength;let t=0;for(let r=0;r<e.length;r++){const s=e[r];r!==e.length-1&&s.byteLength!==this.bufferUniformSize&&(this.bufferUniformSize=void 0);const o=t+s.byteLength;this.shards.push({buffer:s,start:t,end:o}),t=o}this.shards.length===0&&(this.byteLength=0),this.byteLength=this.shards[this.shards.length-1].end}slice(e=0,t=this.byteLength){if(this.shards.length===0)return new ArrayBuffer(0);if(e=isNaN(Number(e))?0:e,t=isNaN(Number(t))?0:t,e=Math.max(0,e),t=Math.min(this.byteLength,t),t<=e)return new ArrayBuffer(0);const r=this.findShardForByte(e);if(r===-1)throw new Error(`Could not find start shard for byte ${e}`);const s=t-e,o=new ArrayBuffer(s),i=new Uint8Array(o);let a=0;for(let l=r;l<this.shards.length;l++){const c=this.shards[l],p=e+a-c.start,m=a,v=Math.min(t,c.end)-c.start,b=new Uint8Array(c.buffer,p,v-p);if(i.set(b,m),a+=b.length,t<c.end)break}return o}findShardForByte(e){if(this.shards.length===0||e<0||e>=this.byteLength)return-1;if(this.bufferUniformSize!=null)return this.previousShardIndex=Math.floor(e/this.bufferUniformSize),this.previousShardIndex;function t(s){return e<s.start?-1:e>=s.end?1:0}if(t(this.shards[this.previousShardIndex])===0)return this.previousShardIndex;const r=RU(this.shards,t);return r===-1?-1:(this.previousShardIndex=r,this.previousShardIndex)}}function RU(n,e){let t=0,r=n.length;for(;t<=r;){const s=Math.floor((r-t)/2)+t,o=e(n[s]);if(o===0)return s;o<0?r=s:t=s+1}return-1}function na(){return ae}function ON(){return ae.memory()}function me(n,e){return ae.tidy(n,e)}function kt(n){nR(n).forEach(t=>t.dispose())}function ha(n){return ae.keep(n)}function uR(n,e,t=1){return ae.registerBackend(n,e,t)}function AU(){return ae.backend}const lf=4;async function FN(n,e){const t=[],r=[],s=Array.isArray(n)?n.map(i=>i.name):Object.keys(n);for(let i=0;i<s.length;++i){const a=s[i],l=Array.isArray(n)?n[i].tensor:n[a];if(l.dtype!=="float32"&&l.dtype!=="int32"&&l.dtype!=="bool"&&l.dtype!=="string"&&l.dtype!=="complex64")throw new Error(`Unsupported dtype in weight '${a}': ${l.dtype}`);const c={name:a,shape:l.shape,dtype:l.dtype};if(l.dtype==="string"){const d=new Promise(async p=>{const m=await l.bytes(),y=m.reduce((w,k)=>w+k.length,0)+lf*m.length,v=new Uint8Array(y);let b=0;for(let w=0;w<m.length;w++){const k=m[w],I=new Uint8Array(new Uint32Array([k.length]).buffer);v.set(I,b),b+=lf,v.set(k,b),b+=k.length}p(v)});r.push(d)}else r.push(l.data());e!=null&&(c.group=e),t.push(c)}const o=await Promise.all(r);return{data:FU(o),specs:t}}function _U(n,e){const t=new gu(n),r={};let s=0;for(const o of e){const i=DU(o,(a,l)=>t.slice(s+a,s+l));r[o.name]=OU(o,t.slice(s,s+i)),s+=i}return r}function DU(n,e){const t=Se(n.shape);let r;if("quantization"in n){const s=n.quantization;r=Uy[s.dtype]}else if(n.dtype==="string"){let s=0;for(let o=0;o<t;o++)s+=lf+new Uint32Array(e(s,s+lf))[0];return s}else r=Uy[n.dtype];return t*r}function OU(n,e){const t=n.name,r=n.dtype,s=n.shape,o=Se(s);let i,a=0;if("quantization"in n){const l=n.quantization;if(l.dtype==="uint8"||l.dtype==="uint16"){if(!("min"in l&&"scale"in l))throw new Error(`Weight ${n.name} with quantization ${l.dtype} doesn't have corresponding metadata min and scale.`)}else if(l.dtype==="float16"){if(r!=="float32")throw new Error(`Weight ${n.name} is quantized with ${l.dtype} which only supports weights of type float32 not ${r}.`)}else throw new Error(`Weight ${n.name} has unknown quantization dtype ${l.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`);const c=Uy[l.dtype],d=l.dtype==="uint8"?new Uint8Array(e):new Uint16Array(e);if(r==="float32")if(l.dtype==="uint8"||l.dtype==="uint16"){i=new Float32Array(d.length);for(let p=0;p<d.length;p++){const m=d[p];i[p]=m*l.scale+l.min}}else if(l.dtype==="float16")i=jU()(d);else throw new Error(`Unsupported quantization type ${l.dtype} for weight type float32.`);else if(r==="int32"){if(l.dtype!=="uint8"&&l.dtype!=="uint16")throw new Error(`Unsupported quantization type ${l.dtype} for weight type int32.`);i=new Int32Array(d.length);for(let p=0;p<d.length;p++){const m=d[p];i[p]=Math.round(m*l.scale+l.min)}}else throw new Error(`Unsupported dtype in weight '${t}': ${r}`);a+=o*c}else if(r==="string"){const l=Se(n.shape);i=[];for(let c=0;c<l;c++){const d=new Uint32Array(e.slice(a,a+lf))[0];a+=lf;const p=new Uint8Array(e.slice(a,a+d));i.push(p),a+=d}}else{const l=Uy[r];if(r==="float32")i=new Float32Array(e);else if(r==="int32")i=new Int32Array(e);else if(r==="bool")i=new Uint8Array(e);else if(r==="complex64"){i=new Float32Array(e);const c=new Float32Array(i.length/2),d=new Float32Array(i.length/2);for(let v=0;v<c.length;v++)c[v]=i[v*2],d[v]=i[v*2+1];const p=$m(c,s,"float32"),m=$m(d,s,"float32"),y=Hc(p,m);return p.dispose(),m.dispose(),y}else throw new Error(`Unsupported dtype in weight '${t}': ${r}`);a+=o*l}return $m(i,s,r)}function FU(n){if(n===null)throw new Error(`Invalid input value: ${JSON.stringify(n)}`);let e=0;const t=[];n.forEach(o=>{if(e+=o.byteLength,t.push(o.byteLength===o.buffer.byteLength?o:new o.constructor(o)),!(o instanceof Float32Array||o instanceof Int32Array||o instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${o.constructor.name}`)});const r=new Uint8Array(e);let s=0;return t.forEach(o=>{r.set(new Uint8Array(o.buffer),s),s+=o.byteLength}),r.buffer}const ik=typeof Buffer<"u"&&(typeof Blob>"u"||typeof atob>"u"||typeof btoa>"u");function PN(n){return ik?Buffer.byteLength(n,"utf8"):new Blob([n]).size}function PU(n){if(ik)return Buffer.from(n).toString("base64");const e=new Uint8Array(n);let t="";for(let r=0,s=e.length;r<s;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function LU(n){if(ik){const r=Buffer.from(n,"base64");return r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)}const e=atob(n),t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t.set([e.charCodeAt(r)],r);return t.buffer}function MU(n){return gu.join(n)}function zU(n,e){const t={modelTopology:n.modelTopology,format:n.format,generatedBy:n.generatedBy,convertedBy:n.convertedBy,weightsManifest:e};return n.signature!=null&&(t.signature=n.signature),n.userDefinedMetadata!=null&&(t.userDefinedMetadata=n.userDefinedMetadata),n.modelInitializer!=null&&(t.modelInitializer=n.modelInitializer),n.initializerSignature!=null&&(t.initializerSignature=n.initializerSignature),n.trainingConfig!=null&&(t.trainingConfig=n.trainingConfig),t}function BU(n,e,t){const r={modelTopology:n.modelTopology,format:n.format,generatedBy:n.generatedBy,convertedBy:n.convertedBy};if(n.trainingConfig!=null&&(r.trainingConfig=n.trainingConfig),n.weightsManifest!=null){if(!e)throw new Error("modelJSON has weightsManifest but weightSpecs is null");if(!t)throw new Error("modelJSON has weightsManifest but weightData is null");r.weightSpecs=e,r.weightData=t}return n.signature!=null&&(r.signature=n.signature),n.userDefinedMetadata!=null&&(r.userDefinedMetadata=n.userDefinedMetadata),n.modelInitializer!=null&&(r.modelInitializer=n.modelInitializer),n.initializerSignature!=null&&(r.initializerSignature=n.initializerSignature),r}async function UU(n,e){let t,r;return n.weightsManifest!=null&&([t,r]=await e(n.weightsManifest)),BU(n,t,r)}function ak(n){if(n.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:n.modelTopology==null?0:PN(JSON.stringify(n.modelTopology)),weightSpecsBytes:n.weightSpecs==null?0:PN(JSON.stringify(n.weightSpecs)),weightDataBytes:n.weightData==null?0:new gu(n.weightData).byteLength}}function LN(n){const e=[];for(const t of n)e.push(...t.weights);return e}function WU(){const n=t=>{let r=t<<13,s=0;for(;(r&8388608)===0;)s-=8388608,r<<=1;return r&=-8388609,s+=947912704,r|s},e=new Uint32Array(2048);e[0]=0;for(let t=1;t<1024;t++)e[t]=n(t);for(let t=1024;t<2048;t++)e[t]=939524096+(t-1024<<13);return e}function VU(){const n=new Uint32Array(64);n[0]=0,n[31]=1199570944,n[32]=2147483648,n[63]=3347054592;for(let e=1;e<31;e++)n[e]=e<<23;for(let e=33;e<63;e++)n[e]=2147483648+(e-32<<23);return n}function GU(){const n=new Uint32Array(64);for(let e=0;e<64;e++)n[e]=1024;return n[0]=n[32]=0,n}function jU(){const n=WU(),e=VU(),t=GU();return r=>{const s=new ArrayBuffer(4*r.length),o=new Uint32Array(s);for(let i=0;i<r.length;i++){const a=r[i],l=n[t[a>>10]+(a&1023)]+e[a>>10];o[i]=l}return new Float32Array(s)}}class pr{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return pr.instance==null&&(pr.instance=new pr),pr.instance}static registerSaveRouter(e){pr.getInstance().saveRouters.push(e)}static registerLoadRouter(e){pr.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return pr.getHandlers(e,"save")}static getLoadHandlers(e,t){return pr.getHandlers(e,"load",t)}static getHandlers(e,t,r){const s=[];return(t==="load"?pr.getInstance().loadRouters:pr.getInstance().saveRouters).forEach(i=>{const a=i(e,r);a!==null&&s.push(a)}),s}}const HU=n=>pr.getSaveHandlers(n),qU=(n,e)=>pr.getLoadHandlers(n,e);const xC="tensorflowjs",yC=1,Oc="models_store",Zl="model_info_store";function cR(){if(!ye().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const n=typeof window>"u"?self:window,e=n.indexedDB||n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB||n.shimIndexedDB;if(e==null)throw new Error("The current browser does not appear to support IndexedDB.");return e}function vC(n){const e=n.result;e.createObjectStore(Oc,{keyPath:"modelPath"}),e.createObjectStore(Zl,{keyPath:"modelPath"})}class qc{constructor(e){if(this.indexedDB=cR(),e==null||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise((r,s)=>{const o=this.indexedDB.open(xC,yC);o.onupgradeneeded=()=>vC(o),o.onsuccess=()=>{const i=o.result;if(t==null){const a=i.transaction(Oc,"readonly"),c=a.objectStore(Oc).get(this.modelPath);c.onsuccess=()=>{if(c.result==null)return i.close(),s(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));r(c.result.modelArtifacts)},c.onerror=d=>(i.close(),s(c.error)),a.oncomplete=()=>i.close()}else{t.weightData=gu.join(t.weightData);const a=ak(t),l=i.transaction(Zl,"readwrite");let c=l.objectStore(Zl),d;try{d=c.put({modelPath:this.modelPath,modelArtifactsInfo:a})}catch(m){return s(m)}let p;d.onsuccess=()=>{p=i.transaction(Oc,"readwrite");const m=p.objectStore(Oc);let y;try{y=m.put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:a})}catch(v){return s(v)}y.onsuccess=()=>r({modelArtifactsInfo:a}),y.onerror=v=>{c=l.objectStore(Zl);const b=c.delete(this.modelPath);b.onsuccess=()=>(i.close(),s(y.error)),b.onerror=w=>(i.close(),s(y.error))}},d.onerror=m=>(i.close(),s(d.error)),l.oncomplete=()=>{p==null?i.close():p.oncomplete=()=>i.close()}}},o.onerror=i=>s(o.error)})}}qc.URL_SCHEME="indexeddb://";const hR=n=>ye().getBool("IS_BROWSER")&&!Array.isArray(n)&&n.startsWith(qc.URL_SCHEME)?KU(n.slice(qc.URL_SCHEME.length)):null;pr.registerSaveRouter(hR);pr.registerLoadRouter(hR);function KU(n){return new qc(n)}function XU(n){return n.startsWith(qc.URL_SCHEME)?n.slice(qc.URL_SCHEME.length):n}class YU{constructor(){this.indexedDB=cR()}async listModels(){return new Promise((e,t)=>{const r=this.indexedDB.open(xC,yC);r.onupgradeneeded=()=>vC(r),r.onsuccess=()=>{const s=r.result,o=s.transaction(Zl,"readonly"),a=o.objectStore(Zl).getAll();a.onsuccess=()=>{const l={};for(const c of a.result)l[c.modelPath]=c.modelArtifactsInfo;e(l)},a.onerror=l=>(s.close(),t(a.error)),o.oncomplete=()=>s.close()},r.onerror=s=>t(r.error)})}async removeModel(e){return e=XU(e),new Promise((t,r)=>{const s=this.indexedDB.open(xC,yC);s.onupgradeneeded=()=>vC(s),s.onsuccess=()=>{const o=s.result,i=o.transaction(Zl,"readwrite"),a=i.objectStore(Zl),l=a.get(e);let c;l.onsuccess=()=>{if(l.result==null)return o.close(),r(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const d=a.delete(e),p=()=>{c=o.transaction(Oc,"readwrite");const y=c.objectStore(Oc).delete(e);y.onsuccess=()=>t(l.result.modelArtifactsInfo),y.onerror=v=>r(l.error)};d.onsuccess=p,d.onerror=m=>(p(),o.close(),r(l.error))}},l.onerror=d=>(o.close(),r(l.error)),i.oncomplete=()=>{c==null?o.close():c.oncomplete=()=>o.close()}},s.onerror=o=>r(s.error)})}}const tl="/",qd="tensorflowjs_models",dR="info",QU="model_topology",JU="weight_specs",ZU="weight_data",eW="model_metadata";function fR(n){return{info:[qd,n,dR].join(tl),topology:[qd,n,QU].join(tl),weightSpecs:[qd,n,JU].join(tl),weightData:[qd,n,ZU].join(tl),modelMetadata:[qd,n,eW].join(tl)}}function pR(n){for(const e of Object.values(n))window.localStorage.removeItem(e)}function tW(n){const e=n.split(tl);if(e.length<3)throw new Error(`Invalid key format: ${n}`);return e.slice(1,e.length-1).join(tl)}function nW(n){return n.startsWith(Kc.URL_SCHEME)?n.slice(Kc.URL_SCHEME.length):n}class Kc{constructor(e){if(!ye().getBool("IS_BROWSER")||typeof window>"u"||typeof window.localStorage>"u")throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,e==null||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=fR(this.modelPath)}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{const t=JSON.stringify(e.modelTopology),r=JSON.stringify(e.weightSpecs),s=ak(e),o=gu.join(e.weightData);try{this.LS.setItem(this.keys.info,JSON.stringify(s)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,r),this.LS.setItem(this.keys.weightData,PU(o));const i={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,signature:e.signature!=null?e.signature:void 0,userDefinedMetadata:e.userDefinedMetadata!=null?e.userDefinedMetadata:void 0,modelInitializer:e.modelInitializer!=null?e.modelInitializer:void 0,initializerSignature:e.initializerSignature!=null?e.initializerSignature:void 0,trainingConfig:e.trainingConfig!=null?e.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(i)),{modelArtifactsInfo:s}}catch{throw pR(this.keys),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${s.modelTopologyBytes}, weightSpecsBytes=${s.weightSpecsBytes}, weightDataBytes=${s.weightDataBytes}.`)}}}async load(){const e=JSON.parse(this.LS.getItem(this.keys.info));if(e==null)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if(e.modelTopologyType!=="JSON")throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");const t={},r=JSON.parse(this.LS.getItem(this.keys.topology));if(r==null)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=r;const s=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(s==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=s;const o=this.LS.getItem(this.keys.modelMetadata);if(o!=null){const a=JSON.parse(o);t.format=a.format,t.generatedBy=a.generatedBy,t.convertedBy=a.convertedBy,a.signature!=null&&(t.signature=a.signature),a.userDefinedMetadata!=null&&(t.userDefinedMetadata=a.userDefinedMetadata),a.modelInitializer!=null&&(t.modelInitializer=a.modelInitializer),a.initializerSignature!=null&&(t.initializerSignature=a.initializerSignature),a.trainingConfig!=null&&(t.trainingConfig=a.trainingConfig)}const i=this.LS.getItem(this.keys.weightData);if(i==null)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=LU(i),t}}Kc.URL_SCHEME="localstorage://";const mR=n=>ye().getBool("IS_BROWSER")&&!Array.isArray(n)&&n.startsWith(Kc.URL_SCHEME)?rW(n.slice(Kc.URL_SCHEME.length)):null;pr.registerSaveRouter(mR);pr.registerLoadRouter(mR);function rW(n){return new Kc(n)}class sW{constructor(){U(ye().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),U(typeof window>"u"||typeof window.localStorage<"u",()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){const e={},t=qd+tl,r=tl+dR;for(let s=0;s<this.LS.length;++s){const o=this.LS.key(s);if(o.startsWith(t)&&o.endsWith(r)){const i=tW(o);e[i]=JSON.parse(this.LS.getItem(o))}}return e}async removeModel(e){e=nW(e);const t=fR(e);if(this.LS.getItem(t.info)==null)throw new Error(`Cannot find model at path '${e}'`);const r=JSON.parse(this.LS.getItem(t.info));return pR(t),r}}const MN="://";class ra{constructor(){this.managers={}}static getInstance(){return ra.instance==null&&(ra.instance=new ra),ra.instance}static registerManager(e,t){U(e!=null,()=>"scheme must not be undefined or null."),e.endsWith(MN)&&(e=e.slice(0,e.indexOf(MN))),U(e.length>0,()=>"scheme must not be an empty string.");const r=ra.getInstance();U(r.managers[e]==null,()=>`A model store manager is already registered for scheme '${e}'.`),r.managers[e]=t}static getManager(e){const t=ra.getInstance().managers[e];if(t==null)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(ra.getInstance().managers)}}class oW{constructor(){this.messageName="setTimeoutCustom",this.functionRefs=[],this.handledMessageCount=0,this.hasEventListener=!1}fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if(t!=="utf-8"&&t!=="utf8")throw new Error(`Browser's encoder only supports utf-8, but got ${t}`);return this.textEncoder==null&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,t){return new TextDecoder(t).decode(e)}setTimeoutCustom(e,t){if(typeof window>"u"||!ye().getBool("USE_SETTIMEOUTCUSTOM")){setTimeout(e,t);return}this.functionRefs.push(e),setTimeout(()=>{window.postMessage({name:this.messageName,index:this.functionRefs.length-1},"*")},t),this.hasEventListener||(this.hasEventListener=!0,window.addEventListener("message",r=>{if(r.source===window&&r.data.name===this.messageName){r.stopPropagation();const s=this.functionRefs[r.data.index];s(),this.handledMessageCount++,this.handledMessageCount===this.functionRefs.length&&(this.functionRefs=[],this.handledMessageCount=0)}},!0))}isTypedArray(e){return KE(e)}}if(ye().get("IS_BROWSER")){ye().setPlatform("browser",new oW);try{ra.registerManager(Kc.URL_SCHEME,new sW)}catch{}try{ra.registerManager(qc.URL_SCHEME,new YU)}catch{}}const iW={importFetch:()=>require("node-fetch")};let Ib;class aW{constructor(){this.util=require("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return ye().global.fetch!=null?ye().global.fetch(e,t):(Ib==null&&(Ib=iW.importFetch()),Ib(e,t))}now(){const e=process.hrtime();return e[0]*1e3+e[1]/1e6}encode(e,t){if(t!=="utf-8"&&t!=="utf8")throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`);return this.textEncoder.encode(e)}decode(e,t){return e.length===0?"":new this.util.TextDecoder(t).decode(e)}isTypedArray(e){return this.util.types.isFloat32Array(e)||this.util.types.isInt32Array(e)||this.util.types.isUint8Array(e)||this.util.types.isUint8ClampedArray(e)}}ye().get("IS_NODE")&&!ye().get("IS_BROWSER")&&ye().setPlatform("node",new aW);function Nt(n,e="float32",t){return e=e||"float32",al(n),new Ar(n,e,t)}function lW(n,e){const t=K(n,"x","cast");if(!j4(e))throw new Error(`Failed to cast to unknown dtype ${e}`);if(e==="string"&&t.dtype!=="string"||e!=="string"&&t.dtype==="string")throw new Error("Only strings can be casted to strings");const r={x:t},s={dtype:e};return ae.runKernel(ug,r,s)}const Ge=he({cast_:lW});function uW(n){const t={x:K(n,"x","clone","string_or_numeric")};return ae.runKernel(Cg,t)}const Lc=he({clone_:uW});function cW(n,e=!1){console.log(n.toString(e))}sR();const hW={buffer:Nt,cast:Ge,clone:Lc,print:cW};CU(hW);function dW(n,e){let t=K(n,"a","add"),r=K(e,"b","add");[t,r]=Un(t,r);const s={a:t,b:r};return ae.runKernel(kf,s)}const Pe=he({add_:dW});function fW(n,e){let t=K(n,"a","floorDiv"),r=K(e,"b","floorDiv");[t,r]=Un(t,r);const s={a:t,b:r};return ae.runKernel(wg,s)}const gR=he({floorDiv_:fW});function pW(n,e){let t=K(n,"a","div"),r=K(e,"b","div");if([t,r]=Un(t,r),t.dtype==="int32"&&r.dtype==="int32")return gR(t,r);const s={a:t,b:r},o={};return ae.runKernel(pg,s,o)}const st=he({div_:pW});function mW(n,e){let t=K(n,"a","mul"),r=K(e,"b","mul");[t,r]=Un(t,r);const s={a:t,b:r};return ae.runKernel(Ag,s)}const ne=he({mul_:mW});function gW(n){const e=K(n,"x","abs");if(e.dtype==="complex64"){const t={x:e};return ae.runKernel($1,t)}else{const t={x:e};return ae.runKernel(v1,t)}}const os=he({abs_:gW});function xW(n){const t={x:K(n,"x","acos")};return ae.runKernel(ng,t)}const yW=he({acos_:xW});function vW(n){const t={x:K(n,"x","acosh")};return ae.runKernel(rg,t)}const wW=he({acosh_:vW});function bW(n,e=null,t=!1){const s={x:K(n,"x","all","bool")},o={axis:e,keepDims:t};return ae.runKernel(vS,s,o)}const xR=he({all_:bW});function CW(n,e=null,t=!1){const s={x:K(n,"x","any","bool")},o={axis:e,keepDims:t};return ae.runKernel(wS,s,o)}const wC=he({any_:CW});function SW(n,e=0){const r={x:K(n,"x","argMax")},s={axis:e};return ae.runKernel(w1,r,s)}const Pm=he({argMax_:SW});function kW(n,e=0){const r={x:K(n,"x","argMin")},s={axis:e};return ae.runKernel(b1,r,s)}const IW=he({argMin_:kW});function $W(n){const t={x:K(n,"x","asin")};return ae.runKernel(sg,t)}const NW=he({asin_:$W});function TW(n){const t={x:K(n,"x","asinh")};return ae.runKernel(og,t)}const EW=he({asinh_:TW});function RW(n){const t={x:K(n,"x","atan")};return ae.runKernel(ig,t)}const AW=he({atan_:RW});function _W(n,e){let t=K(n,"a","atan2"),r=K(e,"b","atan2");[t,r]=Un(t,r);const s={a:t,b:r};return ae.runKernel(lg,s)}const DW=he({atan2_:_W});function OW(n){const t={x:K(n,"x","atanh")};return ae.runKernel(ag,t)}const FW=he({atanh_:OW});function Zg(n,e,t,r,s="NHWC",o){const i=n[3],a=[...e,i],l=ul(s);return _r(n,a,t,o,r,null,null,l)}function Xo(n,e,t,r,s,o,i="channelsLast"){const[a,l]=Lm(e);let c;if(i==="channelsLast")c=[a,l,n[3],n[3]];else if(i==="channelsFirst")c=[a,l,n[1],n[1]];else throw new Error(`Unknown dataFormat ${i}`);return _r(n,c,t,r,s,o,!1,i)}function ll(n,e,t,r,s,o,i="NDHWC"){const[a,l,c]=bC(e);let d,p;if(i==="NDHWC")p="channelsLast",d=[a,l,c,n[4],n[4]];else if(i==="NCDHW")p="channelsFirst",d=[a,l,c,n[1],n[1]];else throw new Error(`Unknown dataFormat ${i}`);return xu(n,d,t,r,s,!1,p,o)}function _r(n,e,t,r,s,o,i=!1,a="channelsLast"){let[l,c,d,p]=[-1,-1,-1,-1];if(a==="channelsLast")[l,c,d,p]=n;else if(a==="channelsFirst")[l,p,c,d]=n;else throw new Error(`Unknown dataFormat ${a}`);const[m,y,,v]=e,[b,w]=Lm(t),[k,I]=Lm(r),N=tf(m,k),T=tf(y,I),{padInfo:A,outHeight:O,outWidth:P}=MW(s,c,d,b,w,N,T,o,a),B=i?v*p:v;let z;return a==="channelsFirst"?z=[l,B,O,P]:a==="channelsLast"&&(z=[l,O,P,B]),{batchSize:l,dataFormat:a,inHeight:c,inWidth:d,inChannels:p,outHeight:O,outWidth:P,outChannels:B,padInfo:A,strideHeight:b,strideWidth:w,filterHeight:m,filterWidth:y,effectiveFilterHeight:N,effectiveFilterWidth:T,dilationHeight:k,dilationWidth:I,inShape:n,outShape:z,filterShape:e}}function xu(n,e,t,r,s,o=!1,i="channelsLast",a){let[l,c,d,p,m]=[-1,-1,-1,-1,-1];if(i==="channelsLast")[l,c,d,p,m]=n;else if(i==="channelsFirst")[l,m,c,d,p]=n;else throw new Error(`Unknown dataFormat ${i}`);const[y,v,b,,w]=e,[k,I,N]=bC(t),[T,A,O]=bC(r),P=tf(y,T),B=tf(v,A),z=tf(b,O),{padInfo:L,outDepth:_,outHeight:H,outWidth:Y}=zW(s,c,d,p,k,I,N,P,B,z,a),re=o?w*m:w;let te;return i==="channelsFirst"?te=[l,re,_,H,Y]:i==="channelsLast"&&(te=[l,_,H,Y,re]),{batchSize:l,dataFormat:i,inDepth:c,inHeight:d,inWidth:p,inChannels:m,outDepth:_,outHeight:H,outWidth:Y,outChannels:re,padInfo:L,strideDepth:k,strideHeight:I,strideWidth:N,filterDepth:y,filterHeight:v,filterWidth:b,effectiveFilterDepth:P,effectiveFilterHeight:B,effectiveFilterWidth:z,dilationDepth:T,dilationHeight:A,dilationWidth:O,inShape:n,outShape:te,filterShape:e}}function PW(n,e,t,r,s){r==null&&(r=lk(n,e,t));const o=n[0],i=n[1],a=Mm((o-e+2*r)/t+1,s),l=Mm((i-e+2*r)/t+1,s);return[a,l]}function LW(n,e,t,r,s,o){s==null&&(s=lk(n,e[0],r[0]));const i=[0,0,0,t];for(let a=0;a<3;a++)n[a]+2*s>=e[a]&&(i[a]=Mm((n[a]-e[a]+2*s)/r[a]+1,o));return i}function lk(n,e,t,r=1){const s=tf(e,r);return Math.floor((n[0]*(t-1)-t+s)/2)}function Lm(n){return typeof n=="number"?[n,n,n]:n.length===2?[n[0],n[1],1]:n}function bC(n){return typeof n=="number"?[n,n,n]:n}function tf(n,e){return e<=1?n:n+(n-1)*(e-1)}function MW(n,e,t,r,s,o,i,a,l){let c,d,p;if(typeof n=="number"){c={top:n,bottom:n,left:n,right:n,type:n===0?"VALID":"NUMBER"};const y=PW([e,t],o,r,n,a);d=y[0],p=y[1]}else if(n==="same"){d=Math.ceil(e/r),p=Math.ceil(t/s);const m=Math.max(0,(d-1)*r+o-e),y=Math.max(0,(p-1)*s+i-t),v=Math.floor(m/2),b=m-v,w=Math.floor(y/2),k=y-w;c={top:v,bottom:b,left:w,right:k,type:"SAME"}}else if(n==="valid")c={top:0,bottom:0,left:0,right:0,type:"VALID"},d=Math.ceil((e-o+1)/r),p=Math.ceil((t-i+1)/s);else if(typeof n=="object"){const m=l==="channelsLast"?n[1][0]:n[2][0],y=l==="channelsLast"?n[1][1]:n[2][1],v=l==="channelsLast"?n[2][0]:n[3][0],b=l==="channelsLast"?n[2][1]:n[3][1];c={top:m,bottom:y,left:v,right:b,type:m===0&&y===0&&v===0&&b===0?"VALID":"EXPLICIT"},d=Mm((e-o+m+y)/r+1,a),p=Mm((t-i+v+b)/s+1,a)}else throw Error(`Unknown padding parameter: ${n}`);return{padInfo:c,outHeight:d,outWidth:p}}function zW(n,e,t,r,s,o,i,a,l,c,d){let p,m,y,v;if(n==="valid"&&(n=0),typeof n=="number"){p={top:n,bottom:n,left:n,right:n,front:n,back:n,type:n===0?"VALID":"NUMBER"};const w=LW([e,t,r,1],[a,l,c],1,[s,o,i],n,d);m=w[0],y=w[1],v=w[2]}else if(n==="same"){m=Math.ceil(e/s),y=Math.ceil(t/o),v=Math.ceil(r/i);const b=(m-1)*s+a-e,w=(y-1)*o+l-t,k=(v-1)*i+c-r,I=Math.floor(b/2),N=b-I,T=Math.floor(w/2),A=w-T,O=Math.floor(k/2),P=k-O;p={top:T,bottom:A,left:O,right:P,front:I,back:N,type:"SAME"}}else throw Error(`Unknown padding parameter: ${n}`);return{padInfo:p,outDepth:m,outHeight:y,outWidth:v}}function Mm(n,e){if(!e)return Math.trunc(n);switch(e){case"round":return Math.round(n);case"ceil":return Math.ceil(n);case"floor":return Math.floor(n);default:throw new Error(`Unknown roundingMode ${e}`)}}function Xc(n){const[e,t,r]=Lm(n);return e===1&&t===1&&r===1}function Hr(n,e){return Xc(n)||Xc(e)}function Yc(n){return Lm(n).every(e=>e>0)}function ul(n){if(n==="NHWC")return"channelsLast";if(n==="NCHW")return"channelsFirst";throw new Error(`Unknown dataFormat ${n}`)}function Ts(n,e,t){if(t!=null){if(typeof e=="string")throw Error(`Error in ${n}: pad must be an integer when using dimRoundingMode ${t} but got pad ${e}.`);if(typeof e=="number")U(of(e),()=>`Error in ${n}: pad must be an integer when using dimRoundingMode ${t} but got pad ${e}.`);else if(typeof e=="object")e.forEach(r=>{r.forEach(s=>{U(of(s),()=>`Error in ${n}: pad must be an integer when using dimRoundingMode ${t} but got pad ${s}.`)})});else throw Error(`Error in ${n}: Unknown padding parameter: ${e}`)}}function BW(n,e){const r={x:K(n,"x","reshape","string_or_numeric")},s={shape:e};return ae.runKernel(iv,r,s)}const ce=he({reshape_:BW});function UW(n,e,t,r,s){const o=K(n,"x","avgPool","float32"),i=1;U(Hr(t,i),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${t} and dilations '${i}'`);let a=o,l=!1;o.rank===3&&(l=!0,a=ce(o,[1,o.shape[0],o.shape[1],o.shape[2]])),U(a.rank===4,()=>`Error in avgPool: x must be rank 4 but got rank ${a.rank}.`),Ts("avgPool",r,s);const c={x:a},d={filterSize:e,strides:t,pad:r,dimRoundingMode:s};let p=ae.runKernel(C1,c,d);return p=Ge(p,o.dtype),l?ce(p,[p.shape[1],p.shape[2],p.shape[3]]):p}const uk=he({avgPool_:UW});function WW(n,e,t,r,s,o="NDHWC"){const i=K(n,"x","avgPool3d","float32");let a=i,l=!1;i.rank===4&&(l=!0,a=ce(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),U(a.rank===5,()=>`Error in avgPool3d: x must be rank 5 but got rank ${a.rank}.`),U(o==="NDHWC",()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${o}`),U(typeof t=="number"&&t>0||Array.isArray(t)&&t[0]>0&&t[1]>0&&t[2]>0,()=>`Error in avgPool3d: Stride must be > 0, but got '${t}'`),Ts("avgPool3d",r,s);const c={x:a},d={filterSize:e,strides:t,pad:r,dimRoundingMode:s,dataFormat:o};let p=ae.runKernel(S1,c,d);return p=Ge(p,a.dtype),l?ce(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}const VW=he({avgPool3d_:WW});function GW(n,e=0){U(n.length>=1,()=>"Pass at least one tensor to concat");const t=lR(n,"tensors","concat","string_or_numeric");if(t[0].dtype==="complex64"&&t.forEach(o=>{if(o.dtype!=="complex64")throw new Error(`Cannot concatenate complex64 tensors with a tensor
with dtype ${o.dtype}. `)}),t.length===1)return Lc(t[0]);const r=t,s={axis:e};return ae.runKernel(N1,r,s)}const Is=he({concat_:GW});function jW(n,e,t=!1,r=!1){let s=K(n,"a","matMul"),o=K(e,"b","matMul");[s,o]=Un(s,o);const i={a:s,b:o},a={transposeA:t,transposeB:r};return ae.runKernel(k1,i,a)}const qt=he({matMul_:jW});function HW(n){const t={x:K(n,"x","sigmoid","float32")};return ae.runKernel(Wg,t)}const If=he({sigmoid_:HW});function qW(n,e,t){const r=K(n,"x","slice","string_or_numeric");if(r.rank===0)throw new Error("Slicing scalar is not possible");const s={x:r},o={begin:e,size:t};return ae.runKernel(hv,s,o)}const mn=he({slice_:qW});function KW(n){const t={x:K(n,"x","tanh","float32")};return ae.runKernel(Kg,t)}const wv=he({tanh_:KW});function XW(n,e,t){const r=K(n,"x","batchToSpaceND"),s=e.reduce((a,l)=>a*l);U(r.rank>=1+e.length,()=>`input rank is ${r.rank} but should be > than blockShape.length ${e.length}`),U(t.length===e.length,()=>`crops.length is ${t.length} but should be equal to blockShape.length ${e.length}`),U(r.shape[0]%s===0,()=>`input tensor batch is ${r.shape[0]} but is not divisible by the product of the elements of blockShape ${e.join(" * ")} === ${s}`);const o={x:r},i={blockShape:e,crops:t};return ae.runKernel(I1,o,i)}const ck=he({batchToSpaceND_:XW});function YW(n){let e;return n.rank===0||n.rank===1?e=ce(n,[1,1,1,n.size]):n.rank===2?e=ce(n,[1,1,n.shape[0],n.shape[1]]):n.rank===3?e=ce(n,[1,n.shape[0],n.shape[1],n.shape[2]]):e=n,e}function QW(n,e,t,r,s,o){o==null&&(o=.001);const i=K(n,"x","batchNorm"),a=K(e,"mean","batchNorm"),l=K(t,"variance","batchNorm");let c;s!=null&&(c=K(s,"scale","batchNorm"));let d;r!=null&&(d=K(r,"offset","batchNorm")),U(a.rank===l.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),U(d==null||a.rank===d.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),U(c==null||a.rank===c.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");const m={x:YW(i),scale:c,offset:d,mean:a,variance:l},y={varianceEpsilon:o},v=ae.runKernel(P1,m,y);return ce(v,i.shape)}const bv=he({batchNorm_:QW});function JW(n,e,t,r,s,o){const i=K(n,"x","batchNorm"),a=K(e,"mean","batchNorm"),l=K(t,"variance","batchNorm");let c;s!=null&&(c=K(s,"scale","batchNorm"));let d;return r!=null&&(d=K(r,"offset","batchNorm")),U(i.rank===2,()=>`Error in batchNorm2D: x must be rank 2 but got rank ${i.rank}.`),U(a.rank===2||a.rank===1,()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${a.rank}.`),U(l.rank===2||l.rank===1,()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${l.rank}.`),c!=null&&U(c.rank===2||c.rank===1,()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${c.rank}.`),d!=null&&U(d.rank===2||d.rank===1,()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${d.rank}.`),bv(i,a,l,d,c,o)}const ZW=he({batchNorm2d_:JW});function eV(n,e,t,r,s,o){const i=K(n,"x","batchNorm"),a=K(e,"mean","batchNorm"),l=K(t,"variance","batchNorm");let c;s!=null&&(c=K(s,"scale","batchNorm"));let d;return r!=null&&(d=K(r,"offset","batchNorm")),U(i.rank===3,()=>`Error in batchNorm3D: x must be rank 3 but got rank ${i.rank}.`),U(a.rank===3||a.rank===1,()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${a.rank}.`),U(l.rank===3||l.rank===1,()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${l.rank}.`),c!=null&&U(c.rank===3||c.rank===1,()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${c.rank}.`),d!=null&&U(d.rank===3||d.rank===1,()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${d.rank}.`),bv(i,a,l,d,c,o)}const tV=he({batchNorm3d_:eV});function nV(n,e,t,r,s,o){const i=K(n,"x","batchNorm"),a=K(e,"mean","batchNorm"),l=K(t,"variance","batchNorm");let c;s!=null&&(c=K(s,"scale","batchNorm"));let d;return r!=null&&(d=K(r,"offset","batchNorm")),U(i.rank===4,()=>`Error in batchNorm4D: x must be rank 4 but got rank ${i.rank}.`),U(a.rank===4||a.rank===1,()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${a.rank}.`),U(l.rank===4||l.rank===1,()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${l.rank}.`),c!=null&&U(c.rank===4||c.rank===1,()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${c.rank}.`),d!=null&&U(d.rank===4||d.rank===1,()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${d.rank}.`),bv(i,a,l,d,c,o)}const rV=he({batchNorm4d_:nV});function sV(n,e,t){const r=K(n,"x","bincount"),s=K(e,"weights","bincount");U(r.dtype==="int32",()=>`Error in bincount: input dtype must be int32, but got ${r.dtype}`),U(t>=0,()=>`size must be non-negative, but got ${t}.`),U(s.size===r.size||s.size===0,()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${r.shape}, weights shape: ${s.shape}.`);const o={x:r,weights:s},i={size:t};return ae.runKernel(SS,o,i)}const oV=he({bincount_:sV});function iV(n,e){let t=K(n,"broadcastTo","x");const r=t.shape;if(al(e),e.length<t.rank)throw new Error(`broadcastTo(): shape.length=${e.length} < input.rank=${t.rank}.`);if(e.length>t.rank){const c=t.shape.slice();for(;c.length<e.length;)c.unshift(1);t=ce(t,c)}const s=t.shape,o=Array.from(e);for(let c=e.length-1;c>=0;c--)if(s[c]===e[c])o[c]=1;else if(t.shape[c]!==1)throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${e}].`);if(o.map((c,d)=>c>1?d:-1).filter(c=>c>=0).length===0)return Lc(t);const a={x:t},l={reps:o};return ae.runKernel(Xg,a,l)}const Nm=he({broadcastTo_:iV});function aV(n){const t={x:K(n,"x","ceil","float32")};return ae.runKernel(cg,t)}const lV=he({ceil_:aV});function Cv(n,e,t){al(n),t=t||Cf(e);const r={shape:n,value:e,dtype:t};return ae.runKernel(MS,{},r)}function uV(n,e,t){const r=K(n,"x","clipByValue");if(U(e<=t,()=>`Error in clip: min (${e}) must be less than or equal to max (${t}).`),e===t)return Cv(r.shape,e,r.dtype);const s={x:r},o={clipValueMin:e,clipValueMax:t};return ae.runKernel(hg,s,o)}const wo=he({clipByValue_:uV});function cV(n){return Is(n,0)}const hV=he({concat1d_:cV});function dV(n,e){return Is(n,e)}const fV=he({concat2d_:dV});function pV(n,e){return Is(n,e)}const mV=he({concat3d_:pV});function gV(n,e){return Is(n,e)}const xV=he({concat4d_:gV});function yV(n,e,t,r,s="NHWC",o=[1,1],i){const a=K(n,"x","conv2d","float32"),l=K(e,"filter","conv2d","float32");let c=a,d=!1;a.rank===3&&(d=!0,c=ce(a,[1,a.shape[0],a.shape[1],a.shape[2]])),U(c.rank===4,()=>`Error in conv2d: input must be rank 4, but got rank ${c.rank}.`),U(l.rank===4,()=>`Error in conv2d: filter must be rank 4, but got rank ${l.rank}.`),Ts("conv2d",r,i);const p=s==="NHWC"?c.shape[3]:c.shape[1];U(p===l.shape[2],()=>`Error in conv2d: depth of input (${p}) must match input depth for filter ${l.shape[2]}.`),U(Hr(t,o),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${t} and dilations '${o}'`),U(Yc(o),()=>"Error in conv2D: Dilated rates should be larger than 0."),U(Yc(t),()=>"Error in conv2D: Strides should be larger than 0.");const m={x:c,filter:l},y={strides:t,pad:r,dataFormat:s,dilations:o,dimRoundingMode:i},v=ae.runKernel(T1,m,y);return d?ce(v,[v.shape[1],v.shape[2],v.shape[3]]):v}const Qc=he({conv2d_:yV});function vV(n,e,t,r,s="NWC",o=1,i){const a=K(n,"x","conv1d"),l=K(e,"filter","conv1d");let c=a,d=!1;a.rank===2&&(d=!0,c=ce(a,[1,a.shape[0],a.shape[1]])),U(c.rank===3,()=>`Error in conv1d: input must be rank 3, but got rank ${c.rank}.`),U(l.rank===3,()=>`Error in conv1d: filter must be rank 3, but got rank ${l.rank}.`),Ts("conv1d",r,i),U(c.shape[2]===l.shape[1],()=>`Error in conv1d: depth of input (${c.shape[2]}) must match input depth for filter ${l.shape[1]}.`),U(Hr(t,o),()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${t} and dilation '${o}'`),U(Yc(o),()=>"Error in conv1D: Dilated rates should be larger than 0."),U(Yc(t),()=>"Error in conv1D: Stride should be larger than 0."),U(s==="NWC",()=>`Error in conv1d: got dataFormat of ${s} but only NWC is currently supported.`);const p=ce(l,[1,l.shape[0],l.shape[1],l.shape[2]]),m=ce(c,[c.shape[0],1,c.shape[1],c.shape[2]]),w=Qc(m,p,[1,t],r,"NHWC",[1,o],i);return d?ce(w,[w.shape[2],w.shape[3]]):ce(w,[w.shape[0],w.shape[2],w.shape[3]])}const yR=he({conv1d_:vV});function wV(n,e,t,r,s,o="NHWC",i){U(n.length===e.rank,()=>`Length of inShape (${n.length}) and rank of dy (${e.rank}) must match`);let a=n,l=e,c=!1;e.rank===3&&(c=!0,l=ce(e,[1,e.shape[0],e.shape[1],e.shape[2]]),a=[1,n[0],n[1],n[2]]),U(a.length===4,()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${a.length}.`),U(l.rank===4,()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${l.rank}`),U(t.rank===4,()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${t.rank}`);const d=o==="NHWC"?a[3]:a[1],p=o==="NHWC"?l.shape[3]:l.shape[1];U(d===t.shape[2],()=>`Error in conv2dDerInput: depth of input (${d}) must match input depth for filter ${t.shape[2]}.`),U(p===t.shape[3],()=>`Error in conv2dDerInput: depth of output (${p}) must match output depth for filter ${t.shape[3]}.`),Ts("conv2dDerInput",s,i);const m={dy:l,filter:t},y={strides:r,pad:s,dataFormat:o,dimRoundingMode:i,inputShape:a},v=ae.runKernel(E1,m,y);return c?ce(v,[v.shape[1],v.shape[2],v.shape[3]]):v}const hk=he({conv2DBackpropInput_:wV});function bV(n,e,t,r,s,o){const i=K(n,"x","conv2dTranspose"),a=K(e,"filter","conv2dTranspose");return hk(t,i,a,r,s,"NHWC",o)}const vR=he({conv2dTranspose_:bV});function CV(n,e,t,r,s="NDHWC",o=[1,1,1]){const i=K(n,"x","conv3d"),a=K(e,"filter","conv3d");let l=i,c=!1;i.rank===4&&(c=!0,l=ce(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),U(l.rank===5,()=>`Error in conv3d: input must be rank 5, but got rank ${l.rank}.`),U(a.rank===5,()=>`Error in conv3d: filter must be rank 5, but got rank ${a.rank}.`),U(l.shape[4]===a.shape[3],()=>`Error in conv3d: depth of input (${l.shape[4]}) must match input depth for filter ${a.shape[3]}.`),U(Hr(t,o),()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${t} and dilations '${o}'`),U(s==="NDHWC",()=>`Error in conv3d: got dataFormat of ${s} but only NDHWC is currently supported.`),U(Yc(o),()=>"Error in conv3D: Dilated rates should be larger than 0."),U(Yc(t),()=>"Error in conv3D: Strides should be larger than 0.");const d={x:l,filter:a},p={strides:t,pad:r,dataFormat:s,dilations:o},m=ae.runKernel(R1,d,p);return c?ce(m,[m.shape[1],m.shape[2],m.shape[3],m.shape[4]]):m}const SV=he({conv3d_:CV});function kV(n,e,t,r,s){U(n.length===e.rank,()=>`Length of inShape (${n.length}) and rank of dy (${e.rank}) must match`);let o=n,i=e,a=!1;e.rank===4&&(a=!0,i=ce(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]),o=[1,n[0],n[1],n[2],n[3]]);const l=o[4],c=i.shape[4];U(o.length===5,()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${o.length}.`),U(i.rank===5,()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${i.rank}`),U(t.rank===5,()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${t.rank}`),U(l===t.shape[3],()=>`Error in conv3dDerInput: depth of input (${l}) must match input depth for filter ${t.shape[3]}.`),U(c===t.shape[4],()=>`Error in conv3dDerInput: depth of output (${c}) must match output depth for filter ${t.shape[4]}.`);const d={dy:i,filter:t},p={pad:s,strides:r,inputShape:o},m=ae.runKernel(TS,d,p);return a?ce(m,[m.shape[1],m.shape[2],m.shape[3],m.shape[4]]):m}const wR=he({conv3DBackpropInput_:kV});function IV(n,e,t,r,s){const o=K(n,"x","conv3dTranspose"),i=K(e,"filter","conv3dTranspose");return wR(t,o,i,r,s)}const $V=he({conv3dTranspose_:IV});function NV(n){const t={x:K(n,"x","cos","float32")};return ae.runKernel(dg,t)}const dk=he({cos_:NV});function TV(n){const t={x:K(n,"x","cosh","float32")};return ae.runKernel(fg,t)}const bR=he({cosh_:TV});function EV(n,e=0,t=!1,r=!1){const o={x:K(n,"x","cumprod")},i={axis:e,exclusive:t,reverse:r};return ae.runKernel(ES,o,i)}const CC=he({cumprod_:EV});function RV(n,e=0,t=!1,r=!1){const o={x:K(n,"x","cumsum")},i={axis:e,exclusive:t,reverse:r};return ae.runKernel(A1,o,i)}const CR=he({cumsum_:RV});function AV(n,e,t,r=!1){const s=K(n,"x","denseBincount"),o=K(e,"weights","denseBincount");U(s.dtype==="int32",()=>`Error in denseBincount: input dtype must be int32, but got ${s.dtype}`),U(s.rank<=2,()=>`Error in denseBincount: input must be at most rank 2, but got rank ${s.rank}.`),U(t>=0,()=>`size must be non-negative, but got ${t}.`),U(o.size===s.size||o.size===0,()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${s.shape}, weights shape: ${o.shape}.`);const i={x:s,weights:o},a={size:t,binaryOutput:r};return ae.runKernel(AS,i,a)}const zN=he({denseBincount_:AV});function _V(n,e,t="NHWC"){const r=K(n,"x","depthToSpace","float32"),s=t==="NHWC"?r.shape[1]:r.shape[2],o=t==="NHWC"?r.shape[2]:r.shape[3],i=t==="NHWC"?r.shape[3]:r.shape[1];U(e>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${e}`),U(s*e>=0,()=>`Negative dimension size caused by overflow when multiplying
${s} and ${e} for depthToSpace with input shape
${r.shape}`),U(o*e>=0,()=>`Negative dimension size caused by overflow when multiplying
${o} and ${e} for depthToSpace with input shape
${r.shape}`),U(i%(e*e)===0,()=>`Dimension size must be evenly divisible by ${e*e} but is ${i} for depthToSpace with input shape ${r.shape}`);const a={x:r},l={blockSize:e,dataFormat:t};return ae.runKernel(_S,a,l)}const DV=he({depthToSpace_:_V});function OV(n,e,t,r,s="NHWC",o=[1,1],i){const a=K(n,"x","depthwiseConv2d","float32"),l=K(e,"filter","depthwiseConv2d","float32");let c=a,d=!1;a.rank===3&&(d=!0,c=ce(a,[1,a.shape[0],a.shape[1],a.shape[2]])),U(c.rank===4,()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${c.rank}.`),U(l.rank===4,()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${l.rank}.`);const p=s==="NHWC"?c.shape[3]:c.shape[1];U(p===l.shape[2],()=>`Error in depthwiseConv2d: number of input channels (${p}) must match the inChannels dimension in filter ${l.shape[2]}.`),Ts("depthwiseConv2d",r,i);const m={x:c,filter:l},y={strides:t,pad:r,dataFormat:s,dilations:o,dimRoundingMode:i},v=ae.runKernel(_1,m,y);return d?ce(v,[v.shape[1],v.shape[2],v.shape[3]]):v}const fk=he({depthwiseConv2d_:OV});function FV(n,e,t,r,s=[1,1],o="NHWC"){const i=K(n,"x","dilation2d"),a=K(e,"filter","dilation2d");U(i.rank===3||i.rank===4,()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${i.rank}.`),U(a.rank===3,()=>`Error in dilation2d: filter must be rank 3, but got rank ${a.rank}.`),U(o==="NHWC",()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${o}`);let l=i,c=!1;i.rank===3&&(l=ce(i,[1,i.shape[0],i.shape[1],i.shape[2]]),c=!0),U(l.shape[3]===a.shape[2],()=>`Error in dilation2d: input and filter must have the same depth: ${l.shape[3]} vs ${a.shape[2]}`);const d={x:l,filter:a},p={strides:t,pad:r,dilations:s},m=ae.runKernel(D1,d,p);return c?ce(m,[m.shape[1],m.shape[2],m.shape[3]]):m}const PV=he({dilation2d_:FV});function uf(n,e){const t=n.length,r=[];for(let s=0;s<t;s++){const o=t-1-s,i=n[o]||1;(e[e.length-1-s]||1)>1&&i===1&&r.unshift(o)}return r}function ar(n,e){const t=[];for(let r=0;r<e.length;r++){const s=n[n.length-r-1],o=e.length-r-1,i=e[o];(s==null||s===1&&i>1)&&t.unshift(o)}return t}function gt(n,e){const t=Math.max(n.length,e.length),r=new Array(t);for(let s=0;s<t;s++){let o=n[n.length-s-1];o==null&&(o=1);let i=e[e.length-s-1];if(i==null&&(i=1),o===1)r[t-s-1]=i;else if(i===1)r[t-s-1]=o;else if(o!==i){const a=`Operands could not be broadcast together with shapes ${n} and ${e}.`;throw Error(a)}else r[t-s-1]=o}return r}function LV(n,e){let t=K(n,"a","equal","string_or_numeric"),r=K(e,"b","equal","string_or_numeric");[t,r]=Un(t,r),gt(t.shape,r.shape);const s={a:t,b:r};return ae.runKernel(O1,s)}const ga=he({equal_:LV});function MV(n,e,t){const r=K(e,"a","where"),s=K(t,"b","where"),o=K(n,"condition","where","bool"),i=gt(gt(o.shape,r.shape),s.shape),a=Nm(o,i),l=Nm(r,i),c=Nm(s,i),d={condition:a,t:l,e:c};return ae.runKernel(cv,d)}const us=he({where_:MV});function zV(n){const t={x:K(n,"x","zerosLike")};return ae.runKernel(yv,t)}const Mt=he({zerosLike_:zV});function BV(n,e){let t=K(n,"a","div"),r=K(e,"b","div");[t,r]=Un(t,r);const s=st(t,r),o=Mt(s),i=ga(r,o);return us(i,o,s)}const UV=he({divNoNan_:BV});function WV(n,e){const t=K(n,"t1","dot"),r=K(e,"t2","dot");U((t.rank===1||t.rank===2)&&(r.rank===1||r.rank===2),()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${t.rank} and ${r.rank}.`);const s=t.rank===1?t.size:t.shape[1],o=r.rank===1?r.size:r.shape[0];if(U(s===o,()=>`Error in dot: inner dimensions of inputs must match, but got ${s} and ${o}.`),t.rank===1&&r.rank===1){const i=ce(t,[1,-1]),a=ce(r,[-1,1]),l=qt(i,a);return ce(l,[])}else if(t.rank===1&&r.rank===2){const i=ce(t,[1,-1]),a=ce(r,[r.shape[0],r.shape[1]]),l=qt(i,a);return ce(l,[l.size])}else if(t.rank===2&&r.rank===1){const i=ce(r,[-1,1]),a=qt(t,i);return ce(a,[a.size])}else{const i=ce(r,[r.shape[0],r.shape[1]]);return qt(t,i)}}const VV=he({dot_:WV});function GV(n,...e){const t=e.map((s,o)=>K(s,`tensors${o}`,"einsum")),r={equation:n};return ae.runKernel(FS,t,r)}const mm=he({einsum_:GV});function jV(n){const t={x:K(n,"x","elu","float32")};return ae.runKernel(mg,t)}const Sv=he({elu_:jV});function HV(n){let e=K(n,"x","erf");U(e.dtype==="int32"||e.dtype==="float32",()=>"Input dtype must be `int32` or `float32`."),e.dtype==="int32"&&(e=Ge(e,"float32"));const t={x:e};return ae.runKernel(gg,t)}const SR=he({erf_:HV});function pk(n,e){for(let t=0;t<n.length;++t)if(n[n.length-t-1]!==e-1-t)return!1;return!0}function kR(n,e,t){const r=n.length+e.length,s=[];let o=0,i=0;for(let a=0;a<r;a++)t.indexOf(a)===-1?s.push(n[o++]):s.push(e[i++]);return s}function yr(n,e){const t=[],r=n.length;for(let o=0;o<r;o++)e.indexOf(o)===-1&&t.push(n[o]);const s=e.map(o=>n[o]);return[t,s]}function Yn(n,e){const t=e.map(r=>1);return kR(n,t,e)}function Dr(n,e,t){U(pk(e,t),()=>`${n} supports only inner-most axes for now. Got axes ${e} and rank-${t} input.`)}function En(n,e){if(pk(n,e))return null;const t=[];for(let r=0;r<e;++r)n.indexOf(r)===-1&&t.push(r);return n.forEach(r=>t.push(r)),t}function yu(n){return n.map((e,t)=>[t,e]).sort((e,t)=>e[1]-t[1]).map(e=>e[0])}function Wn(n,e){const t=[];for(let r=e-n;r<e;++r)t.push(r);return t}function qV(n,e=null,t=!1){const s={x:K(n,"x","max")},o={reductionIndices:e,keepDims:t};return ae.runKernel(H1,s,o)}const Si=he({max_:qV});function KV(n,e=null,t=!1){const s={x:K(n,"x","min")},o={axis:e,keepDims:t};return ae.runKernel(Y1,s,o)}const Wy=he({min_:KV});function XV(n,e){let t=K(n,"base","pow"),r=K(e,"exp","pow");[t,r]=Un(t,r);const s={a:t,b:r};return ae.runKernel(_g,s)}const Jc=he({pow_:XV});function Kt(n,e){if((qo(n)&&e!=="string"||Array.isArray(n))&&e!=="complex64")throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if(e==="string"&&qo(n)&&!(n instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return Jg(n,[],[],e)}function YV(n){const t={x:K(n,"x","sqrt","float32")};return ae.runKernel(Gg,t)}const jr=he({sqrt_:YV});function QV(n){const e=K(n,"x","square"),t={};return ae.runKernel("Square",{x:e},t)}const bn=he({square_:QV});function JV(n,e=null,t=!1){let r=K(n,"x","sum");r.dtype==="bool"&&(r=Ge(r,"int32"));const s={x:r},o={axis:e,keepDims:t};return ae.runKernel(dv,s,o)}const rt=he({sum_:JV});function ZV(n,e="euclidean",t=null,r=!1){n=K(n,"x","norm");const s=IR(n,e,t);let o=s.shape;if(r){const i=Tt(t,n.shape);o=Yn(s.shape,i)}return ce(s,o)}function IR(n,e,t=null){if(n.rank===0)return os(n);if(n.rank!==1&&t===null)return IR(ce(n,[-1]),e,t);if(n.rank===1||typeof t=="number"||Array.isArray(t)&&t.length===1){if(e===1)return rt(os(n),t);if(e===1/0)return Si(os(n),t);if(e===-1/0)return Wy(os(n),t);if(e==="euclidean"||e===2)return jr(rt(Jc(os(n),Kt(2,"int32")),t));throw new Error(`Error in norm: invalid ord value: ${e}`)}if(Array.isArray(t)&&t.length===2){if(e===1)return Si(rt(os(n),t[0]),t[1]-1);if(e===1/0)return Si(rt(os(n),t[1]),t[0]);if(e===-1/0)return Wy(rt(os(n),t[1]),t[0]);if(e==="fro"||e==="euclidean")return jr(rt(bn(n),t));throw new Error(`Error in norm: invalid ord value: ${e}`)}throw new Error(`Error in norm: invalid axis: ${t}`)}const kv=he({norm_:ZV});function eG(n,e=null,t=!1){return kv(n,"euclidean",e,t)}const tG=he({euclideanNorm_:eG});function nG(n){const t={x:K(n,"x","exp")};return ae.runKernel(xg,t)}const xa=he({exp_:nG});function rG(n,e=0){const t=K(n,"x","expandDims","string_or_numeric");U(e<=t.rank,()=>"Axis must be <= rank of the tensor");const r={input:t},s={dim:e};return ae.runKernel(F1,r,s)}const Ss=he({expandDims_:rG});function sG(n){const t={x:K(n,"x","expm1")};return ae.runKernel(yg,t)}const oG=he({expm1_:sG});function iG(n,e){const t=K(n,"x","tile","string_or_numeric");U(t.rank===e.length,()=>`Error in transpose: rank of input ${t.rank} must match length of reps ${e}.`);const r={x:t},s={reps:e};return ae.runKernel(Xg,r,s)}const bi=he({tile_:iG});function aG(n,e,t,r="float32"){e==null&&(e=n);const s=Nt([n,e],r),o=n<=e?n:e;for(let a=0;a<o;++a)s.set(1,a,a);const i=ce(s.toTensor(),[n,e]);if(t==null)return i;if(t.length===1)return bi(Ss(i,0),[t[0],1,1]);if(t.length===2)return bi(Ss(Ss(i,0),0),[t[0],t[1],1,1]);if(t.length===3)return bi(Ss(Ss(Ss(i,0),0),0),[t[0],t[1],t[2],1,1]);throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${t.length}D.`)}const $R=he({eye_:aG});function lG(n){const t={x:K(n,"x","floor","float32")};return ae.runKernel(vg,t)}const Iv=he({floor_:lG});function uG(n,e,t=0,r=0){const s=K(n,"x","gather"),o=K(e,"indices","gather","int32"),i={x:s,indices:o},a={axis:t,batchDims:r};return ae.runKernel(L1,i,a)}const mk=he({gather_:uG});function cG(n,e){let t=K(n,"a","greater","string_or_numeric"),r=K(e,"b","greater","string_or_numeric");[t,r]=Un(t,r),gt(t.shape,r.shape);const s={a:t,b:r};return ae.runKernel(M1,s)}const bo=he({greater_:cG});function hG(n,e){let t=K(n,"a","greaterEqual","string_or_numeric"),r=K(e,"b","greaterEqual","string_or_numeric");[t,r]=Un(t,r),gt(t.shape,r.shape);const s={a:t,b:r};return ae.runKernel(bg,s)}const lh=he({greaterEqual_:hG});function dG(n){const t={input:K(n,"input","imag")};return ae.runKernel(US,t)}const gk=he({imag_:dG});function fG(n){const t={x:K(n,"x","isFinite")};return ae.runKernel(Sg,t)}const pG=he({isFinite_:fG});function mG(n){const t={x:K(n,"x","isInf")};return ae.runKernel(kg,t)}const gG=he({isInf_:mG});function xG(n){const t={x:K(n,"x","isNaN")};return ae.runKernel(Ig,t)}const yG=he({isNaN_:xG});function vG(n,e=.2){const r={x:K(n,"x","leakyRelu")},s={alpha:e};return ae.runKernel(z1,r,s)}const xk=he({leakyRelu_:vG});function wG(n,e){let t=K(n,"a","less","string_or_numeric"),r=K(e,"b","less","string_or_numeric");[t,r]=Un(t,r),gt(t.shape,r.shape);const s={a:t,b:r};return ae.runKernel(B1,s)}const Vy=he({less_:wG});function bG(n,e){let t=K(n,"a","lessEqual","string_or_numeric"),r=K(e,"b","lessEqual","string_or_numeric");[t,r]=Un(t,r),gt(t.shape,r.shape);const s={a:t,b:r};return ae.runKernel(U1,s)}const $f=he({lessEqual_:bG});function CG(n,e=5,t=1,r=1,s=.5){const o=K(n,"x","localResponseNormalization");U(o.rank===4||o.rank===3,()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got
rank ${o.rank}.`),U(of(e),()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${e}.`);let i=o,a=!1;o.rank===3&&(a=!0,i=ce(o,[1,o.shape[0],o.shape[1],o.shape[2]]));const l={x:i},c={depthRadius:e,bias:t,alpha:r,beta:s},d=ae.runKernel(j1,l,c);return a?ce(d,[d.shape[1],d.shape[2],d.shape[3]]):d}const SG=he({localResponseNormalization_:CG});function kG(n){const t={x:K(n,"x","log","float32")};return ae.runKernel($g,t)}const ya=he({log_:kG});function IG(n){const t={x:K(n,"x","log1p")};return ae.runKernel(Ng,t)}const NR=he({log1p_:IG});function $G(n,e){U(oC(n),()=>"The f passed in variableGrads(f) must be a function"),U(e==null||Array.isArray(e)&&e.every(c=>c instanceof By),()=>"The varList passed in variableGrads(f, varList) must be an array of variables");const t=e!=null;if(!t){e=[];for(const c in ae.registeredVariables)e.push(ae.registeredVariables[c])}const r=t?e.filter(c=>!c.trainable):null,s=e.length;e=e.filter(c=>c.trainable),U(e.length>0,()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${s} variables is trainable.`);const o=!0,{value:i,grads:a}=ae.gradients(n,e,null,o);U(a.some(c=>c!=null),()=>"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."),U(i.rank===0,()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${i.rank} tensor`);const l={};return e.forEach((c,d)=>{a[d]!=null&&(l[c.name]=a[d])}),r?.forEach(c=>l[c.name]=null),{value:i,grads:l}}function cf(n){return ae.customGrad(n)}function NG(n){const t={x:K(n,"x","neg")};return ae.runKernel(J1,t)}const zn=he({neg_:NG});function TG(n){const t={x:K(n,"x","softplus")};return ae.runKernel(Vg,t)}const ex=he({softplus_:TG});function EG(n){const e=K(n,"x","logSigmoid");return cf(r=>({value:zn(ex(zn(r))),gradFunc:i=>ne(i,If(zn(r)))}))(e)}const RG=he({logSigmoid_:EG});function AG(n,e){let t=K(n,"a","sub"),r=K(e,"b","sub");[t,r]=Un(t,r);const s={a:t,b:r};return ae.runKernel(Hg,s)}const ut=he({sub_:AG});function _G(n,e=-1){const t=K(n,"logits","logSoftmax");if(e===-1&&(e=t.rank-1),e!==t.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${t.rank} and axis was ${e}`);return cf((s,o)=>{const a=Si(s,e,!0),l=ut(s,a),c=ut(Ge(l,"float32"),ya(rt(xa(l),e,!0)));return o([c]),{value:c,gradFunc:(p,m)=>{const[y]=m,v=!0,b=xa(y);return ut(p,ne(rt(p,e,v),b))}}})(t)}const TR=he({logSoftmax_:_G});function DG(n,e=null,t=!1){const r=K(n,"x","logSumExp"),s=Tt(e,r.shape),o=Si(r,s,!0),i=ut(r,o),a=xa(i),l=rt(a,s),c=ya(l),d=Pe(ce(o,c.shape),c);if(t){const p=Yn(d.shape,s);return ce(d,p)}return d}const ER=he({logSumExp_:DG});function OG(n,e){const t=K(n,"a","logicalAnd","bool"),r=K(e,"b","logicalAnd","bool");gt(t.shape,r.shape);const s={a:t,b:r};return ae.runKernel(W1,s)}const rl=he({logicalAnd_:OG});function FG(n){const t={x:K(n,"x","logicalNot","bool")};return ae.runKernel(V1,t)}const yk=he({logicalNot_:FG});function PG(n,e){const t=K(n,"a","logicalOr","bool"),r=K(e,"b","logicalOr","bool");gt(t.shape,r.shape);const s={a:t,b:r};return ae.runKernel(G1,s)}const RR=he({logicalOr_:PG});function LG(n,e){const t=K(n,"a","logicalXor","bool"),r=K(e,"b","logicalXor","bool");return gt(t.shape,r.shape),rl(RR(n,e),yk(rl(n,e)))}const MG=he({logicalXor_:LG});function zG(n,e,t,r,s){const o=K(n,"x","maxPool"),i=1;let a=o,l=!1;o.rank===3&&(l=!0,a=ce(o,[1,o.shape[0],o.shape[1],o.shape[2]])),U(a.rank===4,()=>`Error in maxPool: input must be rank 4 but got rank ${a.rank}.`),U(Hr(t,i),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${t} and dilations '${i}'`),Ts("maxPool",r,s);const c={x:a},d={filterSize:e,strides:t,pad:r,dimRoundingMode:s},p=ae.runKernel(q1,c,d);return l?ce(p,[p.shape[1],p.shape[2],p.shape[3]]):p}const vk=he({maxPool_:zG});function BG(n,e=[1,1,1],t,r,s,o="NDHWC"){const i=K(n,"x","maxPool3d");let a=i,l=!1;i.rank===4&&(l=!0,a=ce(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),U(a.rank===5,()=>`Error in maxPool3d: x must be rank 5 but got rank ${a.rank}.`),U(o==="NDHWC",()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${o}`),Ts("maxPool3d",r,s);const c={x:a},d={filterSize:e,strides:t,pad:r,dimRoundingMode:s,dataFormat:o},p=ae.runKernel(K1,c,d);return l?ce(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}const UG=he({maxPool3d_:BG});function WG(n,e){let t=K(n,"a","maximum"),r=K(e,"b","maximum");[t,r]=Un(t,r),t.dtype==="bool"&&(t=Ge(t,"int32"),r=Ge(r,"int32")),gt(t.shape,r.shape);const s={a:t,b:r};return ae.runKernel(Tg,s)}const vu=he({maximum_:WG});function VG(n,e=null,t=!1){const s={x:K(n,"x","mean")},o={axis:e,keepDims:t};return ae.runKernel(X1,s,o)}const Xn=he({mean_:VG});function gr(n,e="float32"){if(al(n),e==="complex64"){const r=gr(n,"float32"),s=gr(n,"float32");return Hc(r,s)}const t=Gr(Se(n),e);return ae.makeTensor(t,n,e)}function wu(n,e="float32"){if(al(n),e==="complex64"){const r=wu(n,"float32"),s=gr(n,"float32");return Hc(r,s)}const t=mS(Se(n),e);return ae.makeTensor(t,n,e)}function GG(n,e){let t=K(n,"a","minimum"),r=K(e,"b","minimum");[t,r]=Un(t,r),t.dtype==="bool"&&(t=Ge(t,"int32"),r=Ge(r,"int32")),gt(t.shape,r.shape);const s={a:t,b:r};return ae.runKernel(Eg,s)}const zm=he({minimum_:GG});function jG(n,e,t){U(t==="reflect"||t==="symmetric",()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${t}.`);const r=K(n,"x","mirrorPad");if(r.rank===0)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");U(e.length===r.rank,()=>`Padding doesn't match input. Must be ${r.rank}. Got ${e.length}.`);const s=t==="reflect"?1:0;for(let a=0;a<r.rank;a++)U(e[a].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),U(e[a][0]>=0&&e[a][0]<=r.shape[a]-s&&e[a][1]>=0&&e[a][1]<=r.shape[a]-s,()=>`Padding in dimension ${a} cannot be greater than or equal to ${r.shape[a]-s} or less than 0 for input of shape ${r.shape}`);const o={paddings:e,mode:t},i={x:r};return ae.runKernel(Q1,i,o)}const HG=he({mirrorPad_:jG});function qG(n,e){let t=K(n,"a","mod"),r=K(e,"b","mod");[t,r]=Un(t,r);const s={a:t,b:r};return ae.runKernel(Rg,s)}const KG=he({mod_:qG});function XG(n,e=null,t=!1){n=K(n,"x","moments");const r=Tt(e,n.shape),s=Xn(n,r,t);let o=s.shape;t||(o=Yn(s.shape,r));const i=bn(ut(Ge(n,"float32"),ce(s,o))),a=Xn(i,r,t);return{mean:s,variance:a}}const wk=he({moments_:XG});function YG(n,e){let t=K(n,"a","notEqual","string_or_numeric"),r=K(e,"b","notEqual","string_or_numeric");[t,r]=Un(t,r),gt(t.shape,r.shape);const s={a:t,b:r};return ae.runKernel(Z1,s)}const Gy=he({notEqual_:YG});function QG(n,e,t=1,r=0,s="int32"){if(e<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${e}`);const i={indices:K(n,"indices","oneHot","int32")},a={dtype:s,depth:e,onValue:t,offValue:r};return ae.runKernel(tv,i,a)}const AR=he({oneHot_:QG});function JG(n){const t={x:K(n,"x","onesLike")};return ae.runKernel(ev,t)}const Ko=he({onesLike_:JG});function ZG(n,e,t=0){const r=K(n,"x","pad");if(r.rank===0)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const s={paddings:e,constantValue:t},o={x:r};return ae.runKernel(rv,o,s)}const bk=he({pad_:ZG});function ej(n,e,t){const r=K(n,"x","spaceToBatchND");U(r.rank>=1+e.length,()=>`input rank ${r.rank} should be > than [blockShape] ${e.length}`),U(t.length===e.length,()=>`paddings.shape[0] ${t.length} must be equal to [blockShape] ${e.length}`),U(r.shape.reduce((i,a,l)=>l>0&&l<=e.length?i&&(a+t[l-1][0]+t[l-1][1])%e[l-1]===0:i,!0),()=>`input spatial dimensions ${r.shape.slice(1)} with paddings ${t.toString()} must be divisible by blockShapes ${e.toString()}`);const s={x:r},o={blockShape:e,paddings:t};return ae.runKernel(fv,s,o)}const Ck=he({spaceToBatchND_:ej});function tj(n,e,t,r,s,o,i){s==null&&(s=[1,1]),o==null&&(o=1),r===0&&(r="valid");const a=K(n,"x","maxPool");let l=a,c=!1;a.rank===3&&(c=!0,l=ce(a,[1,a.shape[0],a.shape[1],a.shape[2]])),U(Hr(o,s),()=>`Error in pool: Either strides or dilations must be 1. Got strides ${o} and dilations '${s}'`);const d=Xo(l.shape,e,o,s,r),p=[d.dilationHeight,d.dilationWidth];let m;r==="same"?m=rj([d.filterHeight,d.filterWidth],p):m=[[0,0],[0,0]];const y=p[0]===1&&p[1]===1,[v,b]=nj([d.inHeight,d.inWidth],p,m),w=y?r:"valid",k=y?l:Ck(l,p,v),N=(t==="avg"?()=>uk(k,e,o,w,i):()=>vk(k,e,o,w,i))(),T=y?N:ck(N,p,b);return c?ce(T,[T.shape[1],T.shape[2],T.shape[3]]):T}function nj(n,e,t){const r=t.map(d=>d[0]),s=t.map(d=>d[1]),o=n.concat(r,s),i=e.map((d,p)=>(d-o[p]%d)%d),a=s.map((d,p)=>d+i[p]),l=e.map((d,p)=>[r[p],a[p]]),c=e.map((d,p)=>[0,i[p]]);return[l,c]}function rj(n,e){const r=n.map((i,a)=>i+(i-1)*(e[a]-1)).map(i=>i-1),s=r.map(i=>Math.floor(i/2)),o=r.map((i,a)=>i-s[a]);return r.map((i,a)=>[s[a],o[a]])}const sj=he({pool_:tj});function oj(n,e){const t=K(n,"x","prelu"),r=K(e,"alpha","prelu"),s={x:t,alpha:r};return ae.runKernel(sv,s)}const Sk=he({prelu_:oj});function ij(n,e=null,t=!1){let r=K(n,"x","prod");r.dtype==="bool"&&(r=Ge(r,"int32"));const s={x:r},o={axis:e,keepDims:t};return ae.runKernel(ov,s,o)}const aj=he({prod_:ij});var wy={exports:{}},lj=wy.exports,BN;function uj(){return BN||(BN=1,(function(n){(function(e,t,r){function s(l){var c=this,d=a();c.next=function(){var p=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=p-(c.c=p|0)},c.c=1,c.s0=d(" "),c.s1=d(" "),c.s2=d(" "),c.s0-=d(l),c.s0<0&&(c.s0+=1),c.s1-=d(l),c.s1<0&&(c.s1+=1),c.s2-=d(l),c.s2<0&&(c.s2+=1),d=null}function o(l,c){return c.c=l.c,c.s0=l.s0,c.s1=l.s1,c.s2=l.s2,c}function i(l,c){var d=new s(l),p=c&&c.state,m=d.next;return m.int32=function(){return d.next()*4294967296|0},m.double=function(){return m()+(m()*2097152|0)*11102230246251565e-32},m.quick=m,p&&(typeof p=="object"&&o(p,d),m.state=function(){return o(d,{})}),m}function a(){var l=4022871197,c=function(d){d=String(d);for(var p=0;p<d.length;p++){l+=d.charCodeAt(p);var m=.02519603282416938*l;l=m>>>0,m-=l,m*=l,l=m>>>0,m-=l,l+=m*4294967296}return(l>>>0)*23283064365386963e-26};return c}t&&t.exports?t.exports=i:this.alea=i})(lj,n)})(wy)),wy.exports}var by={exports:{}},cj=by.exports,UN;function hj(){return UN||(UN=1,(function(n){(function(e,t,r){function s(a){var l=this,c="";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var p=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^p^p>>>8},a===(a|0)?l.x=a:c+=a;for(var d=0;d<c.length+64;d++)l.x^=c.charCodeAt(d)|0,l.next()}function o(a,l){return l.x=a.x,l.y=a.y,l.z=a.z,l.w=a.w,l}function i(a,l){var c=new s(a),d=l&&l.state,p=function(){return(c.next()>>>0)/4294967296};return p.double=function(){do var m=c.next()>>>11,y=(c.next()>>>0)/4294967296,v=(m+y)/(1<<21);while(v===0);return v},p.int32=c.next,p.quick=p,d&&(typeof d=="object"&&o(d,c),p.state=function(){return o(c,{})}),p}t&&t.exports?t.exports=i:this.xor128=i})(cj,n)})(by)),by.exports}var Cy={exports:{}},dj=Cy.exports,WN;function fj(){return WN||(WN=1,(function(n){(function(e,t,r){function s(a){var l=this,c="";l.next=function(){var p=l.x^l.x>>>2;return l.x=l.y,l.y=l.z,l.z=l.w,l.w=l.v,(l.d=l.d+362437|0)+(l.v=l.v^l.v<<4^(p^p<<1))|0},l.x=0,l.y=0,l.z=0,l.w=0,l.v=0,a===(a|0)?l.x=a:c+=a;for(var d=0;d<c.length+64;d++)l.x^=c.charCodeAt(d)|0,d==c.length&&(l.d=l.x<<10^l.x>>>4),l.next()}function o(a,l){return l.x=a.x,l.y=a.y,l.z=a.z,l.w=a.w,l.v=a.v,l.d=a.d,l}function i(a,l){var c=new s(a),d=l&&l.state,p=function(){return(c.next()>>>0)/4294967296};return p.double=function(){do var m=c.next()>>>11,y=(c.next()>>>0)/4294967296,v=(m+y)/(1<<21);while(v===0);return v},p.int32=c.next,p.quick=p,d&&(typeof d=="object"&&o(d,c),p.state=function(){return o(c,{})}),p}t&&t.exports?t.exports=i:this.xorwow=i})(dj,n)})(Cy)),Cy.exports}var Sy={exports:{}},pj=Sy.exports,VN;function mj(){return VN||(VN=1,(function(n){(function(e,t,r){function s(a){var l=this;l.next=function(){var d=l.x,p=l.i,m,y;return m=d[p],m^=m>>>7,y=m^m<<24,m=d[p+1&7],y^=m^m>>>10,m=d[p+3&7],y^=m^m>>>3,m=d[p+4&7],y^=m^m<<7,m=d[p+7&7],m=m^m<<13,y^=m^m<<9,d[p]=y,l.i=p+1&7,y};function c(d,p){var m,y=[];if(p===(p|0))y[0]=p;else for(p=""+p,m=0;m<p.length;++m)y[m&7]=y[m&7]<<15^p.charCodeAt(m)+y[m+1&7]<<13;for(;y.length<8;)y.push(0);for(m=0;m<8&&y[m]===0;++m);for(m==8?y[7]=-1:y[m],d.x=y,d.i=0,m=256;m>0;--m)d.next()}c(l,a)}function o(a,l){return l.x=a.x.slice(),l.i=a.i,l}function i(a,l){a==null&&(a=+new Date);var c=new s(a),d=l&&l.state,p=function(){return(c.next()>>>0)/4294967296};return p.double=function(){do var m=c.next()>>>11,y=(c.next()>>>0)/4294967296,v=(m+y)/(1<<21);while(v===0);return v},p.int32=c.next,p.quick=p,d&&(d.x&&o(d,c),p.state=function(){return o(c,{})}),p}t&&t.exports?t.exports=i:this.xorshift7=i})(pj,n)})(Sy)),Sy.exports}var ky={exports:{}},gj=ky.exports,GN;function xj(){return GN||(GN=1,(function(n){(function(e,t,r){function s(a){var l=this;l.next=function(){var d=l.w,p=l.X,m=l.i,y,v;return l.w=d=d+1640531527|0,v=p[m+34&127],y=p[m=m+1&127],v^=v<<13,y^=y<<17,v^=v>>>15,y^=y>>>12,v=p[m]=v^y,l.i=m,v+(d^d>>>16)|0};function c(d,p){var m,y,v,b,w,k=[],I=128;for(p===(p|0)?(y=p,p=null):(p=p+"\0",y=0,I=Math.max(I,p.length)),v=0,b=-32;b<I;++b)p&&(y^=p.charCodeAt((b+32)%p.length)),b===0&&(w=y),y^=y<<10,y^=y>>>15,y^=y<<4,y^=y>>>13,b>=0&&(w=w+1640531527|0,m=k[b&127]^=y+w,v=m==0?v+1:0);for(v>=128&&(k[(p&&p.length||0)&127]=-1),v=127,b=512;b>0;--b)y=k[v+34&127],m=k[v=v+1&127],y^=y<<13,m^=m<<17,y^=y>>>15,m^=m>>>12,k[v]=y^m;d.w=w,d.X=k,d.i=v}c(l,a)}function o(a,l){return l.i=a.i,l.w=a.w,l.X=a.X.slice(),l}function i(a,l){a==null&&(a=+new Date);var c=new s(a),d=l&&l.state,p=function(){return(c.next()>>>0)/4294967296};return p.double=function(){do var m=c.next()>>>11,y=(c.next()>>>0)/4294967296,v=(m+y)/(1<<21);while(v===0);return v},p.int32=c.next,p.quick=p,d&&(d.X&&o(d,c),p.state=function(){return o(c,{})}),p}t&&t.exports?t.exports=i:this.xor4096=i})(gj,n)})(ky)),ky.exports}var Iy={exports:{}},yj=Iy.exports,jN;function vj(){return jN||(jN=1,(function(n){(function(e,t,r){function s(a){var l=this,c="";l.next=function(){var p=l.b,m=l.c,y=l.d,v=l.a;return p=p<<25^p>>>7^m,m=m-y|0,y=y<<24^y>>>8^v,v=v-p|0,l.b=p=p<<20^p>>>12^m,l.c=m=m-y|0,l.d=y<<16^m>>>16^v,l.a=v-p|0},l.a=0,l.b=0,l.c=-1640531527,l.d=1367130551,a===Math.floor(a)?(l.a=a/4294967296|0,l.b=a|0):c+=a;for(var d=0;d<c.length+20;d++)l.b^=c.charCodeAt(d)|0,l.next()}function o(a,l){return l.a=a.a,l.b=a.b,l.c=a.c,l.d=a.d,l}function i(a,l){var c=new s(a),d=l&&l.state,p=function(){return(c.next()>>>0)/4294967296};return p.double=function(){do var m=c.next()>>>11,y=(c.next()>>>0)/4294967296,v=(m+y)/(1<<21);while(v===0);return v},p.int32=c.next,p.quick=p,d&&(typeof d=="object"&&o(d,c),p.state=function(){return o(c,{})}),p}t&&t.exports?t.exports=i:this.tychei=i})(yj,n)})(Iy)),Iy.exports}var $y={exports:{}};const wj={},bj=Object.freeze(Object.defineProperty({__proto__:null,default:wj},Symbol.toStringTag,{value:"Module"})),Cj=D3(bj);var Sj=$y.exports,HN;function kj(){return HN||(HN=1,(function(n){(function(e,t,r){var s=256,o=6,i=52,a="random",l=r.pow(s,o),c=r.pow(2,i),d=c*2,p=s-1,m;function y(T,A,O){var P=[];A=A==!0?{entropy:!0}:A||{};var B=k(w(A.entropy?[T,N(t)]:T??I(),3),P),z=new v(P),L=function(){for(var _=z.g(o),H=l,Y=0;_<c;)_=(_+Y)*s,H*=s,Y=z.g(1);for(;_>=d;)_/=2,H/=2,Y>>>=1;return(_+Y)/H};return L.int32=function(){return z.g(4)|0},L.quick=function(){return z.g(4)/4294967296},L.double=L,k(N(z.S),t),(A.pass||O||function(_,H,Y,re){return re&&(re.S&&b(re,z),_.state=function(){return b(z,{})}),Y?(r[a]=_,H):_})(L,B,"global"in A?A.global:this==r,A.state)}function v(T){var A,O=T.length,P=this,B=0,z=P.i=P.j=0,L=P.S=[];for(O||(T=[O++]);B<s;)L[B]=B++;for(B=0;B<s;B++)L[B]=L[z=p&z+T[B%O]+(A=L[B])],L[z]=A;(P.g=function(_){for(var H,Y=0,re=P.i,te=P.j,le=P.S;_--;)H=le[re=p&re+1],Y=Y*s+le[p&(le[re]=le[te=p&te+H])+(le[te]=H)];return P.i=re,P.j=te,Y})(s)}function b(T,A){return A.i=T.i,A.j=T.j,A.S=T.S.slice(),A}function w(T,A){var O=[],P=typeof T,B;if(A&&P=="object")for(B in T)try{O.push(w(T[B],A-1))}catch{}return O.length?O:P=="string"?T:T+"\0"}function k(T,A){for(var O=T+"",P,B=0;B<O.length;)A[p&B]=p&(P^=A[p&B]*19)+O.charCodeAt(B++);return N(A)}function I(){try{var T;return m&&(T=m.randomBytes)?T=T(s):(T=new Uint8Array(s),(e.crypto||e.msCrypto).getRandomValues(T)),N(T)}catch{var A=e.navigator,O=A&&A.plugins;return[+new Date,e,O,e.screen,N(t)]}}function N(T){return String.fromCharCode.apply(0,T)}if(k(r.random(),t),n.exports){n.exports=y;try{m=Cj}catch{}}else r["seed"+a]=y})(typeof self<"u"?self:Sj,[],Math)})($y)),$y.exports}var $b,qN;function Ij(){if(qN)return $b;qN=1;var n=uj(),e=hj(),t=fj(),r=mj(),s=xj(),o=vj(),i=kj();return i.alea=n,i.xor128=e,i.xorwow=t,i.xorshift7=r,i.xor4096=s,i.tychei=o,$b=i,$b}var kk=Ij();class _R{constructor(e,t,r,s,o){this.mean=e,this.stdDev=t,this.dtype=r,this.nextVal=NaN,this.truncated=s,this.truncated&&(this.upper=this.mean+this.stdDev*2,this.lower=this.mean-this.stdDev*2);const i=o||Math.random();this.random=kk.alea(i.toString())}nextValue(){if(!isNaN(this.nextVal)){const s=this.nextVal;return this.nextVal=NaN,s}let e,t,r=!1;for(;!r;){let s,o,i;do s=2*this.random()-1,o=2*this.random()-1,i=s*s+o*o;while(i>=1||i===0);const a=Math.sqrt(-2*Math.log(i)/i);e=this.mean+this.stdDev*s*a,t=this.mean+this.stdDev*o*a,(!this.truncated||this.isValidTruncated(e))&&(r=!0)}return(!this.truncated||this.isValidTruncated(t))&&(this.nextVal=this.convertValue(t)),this.convertValue(e)}convertValue(e){return this.dtype==null||this.dtype==="float32"?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}}class $j{constructor(e=0,t=1,r,s){if(this.canReturnFloat=()=>this.dtype==null||this.dtype==="float32",this.min=e,this.range=t-e,this.dtype=r,s==null&&(s=Math.random()),typeof s=="number"&&(s=s.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=kk.alea(s)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}}function Nj(n,e=0,t=1,r,s){if(al(n),r!=null&&r==="bool")throw new Error(`Unsupported data type ${r}`);const o=new _R(e,t,r,!1,s),i=Nt(n,r);for(let a=0;a<i.values.length;a++)i.values[a]=o.nextValue();return i.toTensor()}const Tj=he({randomNormal_:Nj});function Ej(n,e=0,t=1,r="float32",s){al(n);const o=Nt(n,r),i=new $j(e,t,null,s);for(let a=0;a<o.values.length;a++)o.values[a]=i.nextValue();return o.toTensor()}const tx=he({randomUniform_:Ej});function Bm(n,e,t=1,r="float32"){if(t===0)throw new Error("Cannot have a step of zero");const s={start:n,stop:e,step:t,dtype:r};return ae.runKernel(KS,{},s)}function Rj(n){const t={input:K(n,"input","real")};return ae.runKernel(XS,t)}const jy=he({real_:Rj});function Aj(n){const t={x:K(n,"x","reciprocal")};return ae.runKernel(Dg,t)}const _j=he({reciprocal_:Aj});function Dj(n){const t={x:K(n,"x","relu")};return ae.runKernel(Og,t)}const uh=he({relu_:Dj});function Oj(n){const t={x:K(n,"x","relu6")};return ae.runKernel(Fg,t)}const DR=he({relu6_:Oj});function Fj(n,e){const r={x:K(n,"x","reverse")},s={dims:e};return ae.runKernel(uv,r,s)}const Zc=he({reverse_:Fj});function Pj(n){const t={x:K(n,"x","round")};return ae.runKernel(Pg,t)}const OR=he({round_:Pj});function Lj(n){const t={x:K(n,"x","rsqrt","float32")};return ae.runKernel(Lg,t)}const FR=he({rsqrt_:Lj});function Mj(n){const t={x:K(n,"x","selu")};return ae.runKernel(Mg,t)}const PR=he({selu_:Mj});function zj(n,e,t,r,s,o=[1,1],i="NHWC"){const a=K(n,"x","separableConv2d"),l=K(e,"depthwiseFilter","separableConv2d"),c=K(t,"pointwiseFilter","separableConv2d");let d=a,p=!1;if(a.rank===3&&(p=!0,d=ce(a,[1,a.shape[0],a.shape[1],a.shape[2]])),i==="NCHW")throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");U(d.rank===4,()=>`Error in separableConv2d: input must be rank 4, but got rank ${d.rank}.`),U(l.rank===4,()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${l.rank}.`),U(c.rank===4,()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${l.rank}.`),U(c.shape[0]===1,()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${c.shape[0]}.`),U(c.shape[1]===1,()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${c.shape[1]}.`);const m=l.shape[2],y=l.shape[3];U(c.shape[2]===m*y,()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${m*y}, but got ${c.shape[2]}.`);const v=fk(d,l,r,s,i,o),w=Qc(v,c,1,"valid",i);return p?ce(w,[w.shape[1],w.shape[2],w.shape[3]]):w}const LR=he({separableConv2d_:zj});function Bj(n){const t={x:K(n,"x","sign")};return ae.runKernel(Ug,t)}const Uj=he({sign_:Bj});function Wj(n){const t={x:K(n,"x","sin","float32")};return ae.runKernel(zg,t)}const MR=he({sin_:Wj});function Vj(n){const t={x:K(n,"x","sinh")};return ae.runKernel(Bg,t)}const zR=he({sinh_:Vj});function Gj(n,e,t){const r=K(n,"x","slice1d");return U(r.rank===1,()=>`slice1d expects a rank-1 tensor, but got a rank-${r.rank} tensor`),mn(r,[e],[t])}const Ik=he({slice1d_:Gj});function jj(n,e,t){const r=K(n,"x","slice2d");return U(r.rank===2,()=>`slice2d expects a rank-2 tensor, but got a rank-${r.rank} tensor`),mn(r,e,t)}const BR=he({slice2d_:jj});function Hj(n,e,t){const r=K(n,"x","slice3d");return U(r.rank===3,()=>`slice3d expects a rank-3 tensor, but got a rank-${r.rank} tensor`),mn(r,e,t)}const $k=he({slice3d_:Hj});function qj(n,e,t){const r=K(n,"x","slice4d");return U(r.rank===4,()=>`slice4d expects a rank-4 tensor, but got a rank-${r.rank} tensor`),mn(r,e,t)}const Hy=he({slice4d_:qj});function Kj(n,e=-1){const t=K(n,"logits","softmax","float32");if(e===-1&&(e=t.rank-1),e!==t.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${t.rank} and dim was ${e}`);const r={logits:t},s={dim:e};return ae.runKernel(mv,r,s)}const Nk=he({softmax_:Kj});function Xj(n){U(n.dtype==="complex64",()=>`The dtype for tf.spectral.fft() must be complex64 but got ${n.dtype}.`);const e={input:n};return ae.runKernel(LS,e)}const UR=he({fft_:Xj});function Yj(n){U(n.dtype==="complex64",()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${n.dtype}.`);const e={input:n};return ae.runKernel(BS,e)}const SC=he({ifft_:Yj});function Qj(n){const e=n.shape[n.shape.length-1],t=n.size/e;let r;if(e<=2){const s=ce(n,[t,e]);r=SC(s)}else{const s=[t,2*(e-1)],o=ce(jy(n),[t,e]),i=ce(gk(n),[t,e]),a=Zc(mn(o,[0,1],[t,e-2]),1),l=ne(Zc(mn(i,[0,1],[t,e-2]),1),Kt(-1)),c=Is([o,a],1),d=Is([i,l],1),p=ce(Hc(c,d),[s[0],s[1]]);r=SC(p)}if(r=jy(r),n.rank===3&&n.shape[0]!==0){const s=r,o=n.shape[0];r=ce(r,[o,r.shape[0]/o,r.shape[1]]),s.dispose()}return r}const Jj=he({irfft_:Qj});function Zj(n,e,t=0){const s={x:K(n,"x","split")},o={numOrSizeSplits:e,axis:t};return ae.runKernel(pv,s,o)}const yo=he({split_:Zj});function eH(n,e){U(n.dtype==="float32",()=>`The dtype for rfft() must be real value but got ${n.dtype}`);let t=n.shape[n.shape.length-1];const r=n.size/t;let s;if(e!=null&&e<t){const v=n.shape.map(w=>0),b=n.shape.map(w=>w);b[n.shape.length-1]=e,s=mn(n,v,b),t=e}else if(e!=null&&e>t){const v=n.shape.map(b=>b);v[n.shape.length-1]=e-t,s=Is([n,gr(v)],n.shape.length-1),t=e}else s=n;const o=Mt(s),i=ce(Hc(s,o),[r,t]),a=UR(i),l=Math.floor(t/2)+1,c=jy(a),d=gk(a),p=yo(c,[l,t-l],c.shape.length-1),m=yo(d,[l,t-l],d.shape.length-1),y=s.shape.slice();return y[s.shape.length-1]=l,ce(Hc(p[0],m[0]),y)}const tH=he({rfft_:eH});function nH(n,e){let t=K(n,"a","squaredDifference"),r=K(e,"b","squaredDifference");[t,r]=Un(t,r),gt(t.shape,r.shape);const s={a:t,b:r},o={};return ae.runKernel(jg,s,o)}const rH=he({squaredDifference_:nH});function sH(n,e){const t=K(n,"x","squeeze","string_or_numeric");return ce(t,pu(t.shape,e).newShape)}const nx=he({squeeze_:sH});function oH(n,e=0){const t=lR(n,"tensors","stack","string_or_numeric");U(t.length>=1,()=>"Pass at least one tensor to tf.stack"),t.length>0&&U(e<=t[0].rank,()=>"Axis must be <= rank of the tensor");const r=t,s={axis:e};return ae.runKernel(nv,r,s)}const sl=he({stack_:oH});function iH(n,e=0){const r={x:K(n,"x","step")},s={alpha:e};return ae.runKernel(Yg,r,s)}const rx=he({step_:iH});function aH(n,e,t,r,s=0,o=0,i=0,a=0,l=0){const d={x:K(n,"x","stridedSlice","string_or_numeric")},p={begin:e,end:t,strides:r,beginMask:s,endMask:o,ellipsisMask:i,newAxisMask:a,shrinkAxisMask:l};return ae.runKernel(ek,d,p)}const lH=he({stridedSlice_:aH});function uH(n){const t={x:K(n,"x","tan","float32")};return ae.runKernel(qg,t)}const cH=he({tan_:uH});function qs(n,e){pS(n);const t=Qg(n,e);if(t.length!==1)throw new Error("tensor1d() requires values to be a flat/TypedArray");return Jg(n,null,t,e)}function Nb(n,e,t){if(pS(n),e!=null&&e.length!==2)throw new Error("tensor2d() requires shape to have two numbers");const r=Qg(n,t);if(r.length!==2&&r.length!==1)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(r.length===1&&e==null)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return Jg(n,e,r,t)}function hH(n,e,t){if(pS(n),e!=null&&e.length!==3)throw new Error("tensor3d() requires shape to have three numbers");const r=Qg(n,t);if(r.length!==3&&r.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(r.length===1&&e==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return Jg(n,e,r,t)}function WR(n,e,t){const r=e.rank>1?e.shape[e.rank-1]:1,s=e.rank>1?e.rank-1:1,o=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${t.shape}, indices.shape: ${e.shape}, shape: ${n}, sliceDim: ${r}, and batchDim: ${s}.`;if(t.rank<s)throw new Error(o+` update.rank < ${s}. `);if(n.length<r+(t.rank-s))throw new Error(o+` Output shape length < ${r+(t.rank-s)}`);if(t.rank!==s+n.length-r)throw new Error(o+` update.rank != ${s+n.length-r}`);for(let i=0;i<s;++i)if(t.shape[i]!==e.shape[i])throw new Error(o+` updates.shape[${i}] (${t.shape[i]}) != indices.shape[${i}] (${e.shape[i]}).`);for(let i=0;i<t.rank-s;++i)if(t.shape[i+s]!==n[i+r])throw new Error(o+` updates.shape[${i+s}] (${t.shape[i+s]}) != shape[${i+s}] (${n[i+s]})`)}function dH(n,e,t){if(e.rank<1)throw new Error(`tf.scatterND() expects the indices to be rank 1 or higher, but the rank was ${e.rank}.`);if(n.rank<1)throw new Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${n.rank}.`);if(e.dtype!=="int32")throw new Error(`The dtype of 'indices' should be int32, but got dtype: ${e.dtype}`);if(t.length<1)throw new Error(`Output rank must be greater or equal to 1, but got shape: ${t}`);if(t.length===0){if(e.size===0)throw new Error(`Indices specified for empty output. indices shape: ${e.shape}`);if(n.size===0)throw new Error(`Updates specified for empty output. updates shape: ${n.shape}`)}WR(t,e,n)}function ch(n,e,t){const r=e.shape.length,s=r>1?e.shape[r-1]:1,o=t.length;let i=1;for(let p=s;p<o;++p)i*=t[p];const a=s<1?1:s,l=Se(e.shape)/a,c=[...tt(t.slice(0,s)),1],d=Se(t);return{sliceRank:s,numUpdates:l,sliceSize:i,strides:c,outputSize:d}}function fH(n,e=1,t=!0){const r=K(n,"x","topk");if(r.rank===0)throw new Error("topk() expects the input to be of rank 1 or higher");const s=r.shape[r.shape.length-1];if(e<0)throw new Error(`'k' passed to topk() must be >= 0 but got ${e}`);if(e>s)throw new Error(`'k' passed to topk() must be <= the last dimension (${s}) but got ${e}`);const o={x:r},i={k:e,sorted:t},[a,l]=ae.runKernel(tk,o,i);return{values:a,indices:l}}const pH=he({topk_:fH});function mH(n,e=0,t=1,r,s){if(al(n),r!=null&&r==="bool")throw new Error("Unsupported data type $ { dtype }");const o=new _R(e,t,r,!0,s),i=Nt(n,r);for(let a=0;a<i.values.length;a++)i.values[a]=o.nextValue();return i.toTensor()}const VR=he({truncatedNormal_:mH});function gH(n,e=0){const t=K(n,"x","unique","string_or_numeric");U(t.rank>0,()=>"The input tensor must be at least 1D");const r={x:t},s={axis:e},[o,i]=ae.runKernel(rk,r,s);return{values:o,indices:i}}const xH=he({unique_:gH});function yH(n,e,t){const r=K(n,"x","unsortedSegmentSum"),s=K(e,"segmentIds","unsortedSegmentSum","int32");U(of(t),()=>"numSegments must be of dtype int");const o={x:r,segmentIds:s},i={numSegments:t};return ae.runKernel(xv,o,i)}const GR=he({unsortedSegmentSum_:yH});function vH(n,e=0){const t=K(n,"x","unstack","string_or_numeric");U(e>=-t.shape.length&&e<t.shape.length,()=>`Axis = ${e} is not in [-${t.shape.length}, ${t.shape.length})`);const r={value:t},s={axis:e};return ae.runKernel(gv,r,s)}const eh=he({unstack_:vH});function wH(n,e=!0,t,r){return ae.makeVariable(n,e,t,r)}function jR(n,e){const t=[];for(let o=0;o<e.length;o++)e[o]&&t.push(o);const r=Nt(n,"int32"),s=Nt([t.length,n.length],"int32");for(let o=0;o<t.length;o++){const i=r.indexToLoc(t[o]),a=o*n.length;s.values.set(i,a)}return s.toTensor()}function bH(n,e,t){const r=K(n,"x","transpose");if(e==null&&(e=r.shape.map((i,a)=>a).reverse()),U(r.rank===e.length,()=>`Error in transpose: rank of input ${r.rank} must match length of perm ${e}.`),e.forEach(i=>{U(i>=0&&i<r.rank,()=>`All entries in 'perm' must be between 0 and ${r.rank-1} but got ${e}`)}),r.rank<=1)return r.clone();const s={x:r},o={perm:e};return r.dtype==="complex64"?me(()=>{let i=jy(r),a=gk(r);return i=ae.runKernel(ef,{x:i},o),a=ae.runKernel(ef,{x:a},o),t&&(a=zn(a)),Hc(i,a)}):ae.runKernel(ef,s,o)}const Lt=he({transpose_:bH});function CH(n,e){if(e==null)return n.shape.slice();if(Xt(n.shape,e))return e;if(n.shape.length===e.length){const t=[];for(let r=0;r<n.shape.length;r++)e[r]==null&&n.shape[r]!=null?t.push(n.shape[r]):t.push(e[r]);return t}return e}function SH(n,e,t,r){const s=K(n,"x","dropout");if(U(s.dtype==="float32",()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${s.dtype} tensor instead.`),U(e>=0&&e<1,()=>`rate must be a float in the range [0, 1), but got ${e}.`),e===0)return n instanceof tr?s.clone():s;const o=CH(s,t),i=1-e,a=st(Iv(Pe(tx(o,0,1,"float32",r),i)),i);return ne(s,a)}const kH=he({dropout_:SH});function IH(n,e,t,r,s,o="NHWC",i){let a=n;n.rank===3&&(a=ce(n,[1,n.shape[0],n.shape[1],n.shape[2]]));let l=e;l.rank===3&&(l=ce(e,[1,e.shape[0],e.shape[1],e.shape[2]])),U(a.rank===4,()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${a.shape}.`),U(l.rank===4,()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${l.shape}.`),U(t.length===4,()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${t}.`);const c=o==="NHWC"?a.shape[3]:a.shape[1],d=o==="NHWC"?l.shape[3]:l.shape[1];U(c===t[2],()=>`Error in conv2dDerFilter: depth of input ${c}) must match input depth in filter (${t[2]}.`),U(d===t[3],()=>`Error in conv2dDerFilter: depth of dy (${d}) must match output depth for filter (${t[3]}).`),Ts("conv2dDerFilter",s,i);const p={x:a,dy:l},m={strides:r,pad:s,dataFormat:o,dimRoundingMode:i,filterShape:t};return ae.runKernel($S,p,m)}const Tk=he({conv2DBackpropFilter_:IH});function Ek(n,e,t){if(t==null||t==="linear")return n;if(t==="relu")return ne(n,rx(e));throw new Error(`Cannot compute gradient for fused activation ${t}.`)}function Rk(n,e){let t=e;const r=ar(n.shape,e.shape);return r.length>0&&(t=rt(t,r)),ce(t,n.shape)}function Ak(n,e,t,r){if(e==="linear")return n;if(e==="relu")return uh(n);if(e==="elu")return Sv(n);if(e==="relu6")return DR(n);if(e==="prelu")return Sk(n,t);if(e==="leakyrelu")return xk(n,r);if(e==="sigmoid")return If(n);throw new Error(`Unknown fused activation ${e}.`)}const _k=(n,e)=>!(n>0)||e==="linear";function $H({x:n,filter:e,strides:t,pad:r,dataFormat:s="NHWC",dilations:o=[1,1],dimRoundingMode:i,bias:a,activation:l="linear",preluActivationWeights:c,leakyreluAlpha:d}){if(l=l||"linear",_k(ae.state.gradientDepth,l)===!1){U(s==="NHWC",()=>`Error in fused conv2d: got dataFormat of ${s} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`);let O=Qc(n,e,t,r,s,o,i);return a!=null&&(O=Pe(O,a)),Ak(O,l,c,d)}const p=K(n,"x","conv2d","float32"),m=K(e,"filter","conv2d","float32");let y=p,v=!1;p.rank===3&&(v=!0,y=ce(p,[1,p.shape[0],p.shape[1],p.shape[2]])),U(y.rank===4,()=>`Error in fused conv2d: input must be rank 4, but got rank ${y.rank}.`),U(m.rank===4,()=>`Error in fused conv2d: filter must be rank 4, but got rank ${m.rank}.`),Ts("fused conv2d",r,i);const b=s==="NHWC"?y.shape[3]:y.shape[1];U(m.shape[2]===b,()=>`Error in conv2d: depth of input (${b}) must match input depth for filter ${m.shape[2]}.`),U(Hr(t,o),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${t} and dilations '${o}'`);const w=_r(y.shape,m.shape,t,o,r,i);let k;a!=null&&(k=K(a,"bias","fused conv2d"),[k]=Un(k,p),s==="NHWC"?gt(w.outShape,k.shape):(U(k.shape.length<=1,()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${k.shape.length}.`),U(k.shape.length===0||k.shape[0]===w.outChannels||k.shape[0]===1,()=>`Error in fused conv2d: bias shape (${k.shape}) is not compatible with the number of output channels (${w.outChannels})`)));let I;if(c!=null){const O=c.shape;if(U(O.length<=1||O.length===3,()=>`Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${O.length}.`),O.length===1)U(O[0]===1||O[0]===w.outChannels,()=>`Error in fused conv2d: PReLU activation weights (${O}) is not compatible with the number of output channels (${w.outChannels}).`);else if(O.length===3)try{gt(O,w.outShape)}catch{const B=`Error in fused conv2d: PReLU activation weights (${O}) is not compatible with the output shape of the conv2d (${w.outShape}).`;throw Error(B)}I=K(c,"prelu weights","fused conv2d")}const N=(O,P)=>{U(s==="NHWC",()=>`Error in gradient of fused conv2D: got dataFormat of ${s} but only NHWC is currently supported.`);const[B,z,L,_]=P,H=Ek(O,L,l);U(Xc(o),()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${o}'`);const Y=hk(z.shape,H,B,t,r),re=Tk(z,H,B.shape,t,r),te=[Y,re];if(_!=null){const le=Rk(_,H);te.push(le)}return te},T={x:y,filter:m,bias:k,preluActivationWeights:I},A={strides:t,pad:r,dataFormat:s,dilations:o,dimRoundingMode:i,activation:l,leakyreluAlpha:d};return a==null?cf((P,B,z)=>{let L=ae.runKernel(My,T,A);return z([B,P,L]),v&&(L=ce(L,[L.shape[1],L.shape[2],L.shape[3]])),{value:L,gradFunc:N}})(y,m):cf((P,B,z,L)=>{let _=ae.runKernel(My,T,A);return L([B,P,_,z]),v&&(_=ce(_,[_.shape[1],_.shape[2],_.shape[3]])),{value:_,gradFunc:N}})(y,m,k)}const NH=he({fusedConv2d_:$H});function TH(n,e,t,r,s,o=[1,1],i){let a=n;n.rank===3&&(a=ce(n,[1,n.shape[0],n.shape[1],n.shape[2]]));let l=e;l.rank===3&&(l=ce(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const c={x:a,dy:l},d={strides:r,pad:s,dimRoundingMode:i,dilations:o,filterShape:t};return ae.runKernel(DS,c,d)}const EH=he({depthwiseConv2dNativeBackpropFilter_:TH});function RH(n,e,t,r,s,o=[1,1],i){let a=e,l=!1;e.rank===3&&(l=!0,a=ce(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const c={dy:a,filter:t},d={strides:r,pad:s,dimRoundingMode:i,dilations:o,inputShape:n},p=ae.runKernel(OS,c,d);return l?ce(p,[p.shape[1],p.shape[2],p.shape[3]]):p}const AH=he({depthwiseConv2dNativeBackpropInput_:RH});function _H({a:n,b:e,transposeA:t=!1,transposeB:r=!1,bias:s,activation:o="linear",preluActivationWeights:i,leakyreluAlpha:a=.2}){if(_k(ae.state.gradientDepth,o)===!1){let _=qt(n,e,t,r);return s!=null&&(_=Pe(_,s)),Ak(_,o,i,a)}let l=K(n,"a","fused matMul"),c=K(e,"b","fused matMul");[l,c]=Un(l,c);const d=t?l.shape[l.rank-2]:l.shape[l.rank-1],p=r?c.shape[c.rank-1]:c.shape[c.rank-2],m=t?l.shape[l.rank-1]:l.shape[l.rank-2],y=r?c.shape[c.rank-2]:c.shape[c.rank-1],v=l.shape.slice(0,-2),b=c.shape.slice(0,-2),w=Se(v),k=Se(b);U(d===p,()=>`Error in fused matMul: inner shapes (${d}) and (${p}) of Tensors with shapes ${l.shape} and ${c.shape} and transposeA=${t} and transposeB=${r} must match.`);const N=gt(l.shape.slice(0,-2),c.shape.slice(0,-2)).concat([m,y]),T=t?ce(l,[w,d,m]):ce(l,[w,m,d]),A=r?ce(c,[k,y,p]):ce(c,[k,p,y]);let O;s!=null&&(O=K(s,"bias","fused matMul"),[O]=Un(O,l),gt(N,O.shape));let P;i!=null&&(P=K(i,"prelu weights","fused matMul"));const B=(_,H)=>{const[Y,re,te,le]=H,de=Ek(ce(_,te.shape),te,o);let j,ie;if(!t&&!r?(j=qt(de,re,!1,!0),ie=qt(Y,de,!0,!1)):!t&&r?(j=qt(de,re,!1,!1),ie=qt(de,Y,!0,!1)):t&&!r?(j=qt(re,de,!1,!0),ie=qt(Y,de,!1,!1)):(j=qt(re,de,!0,!0),ie=qt(de,Y,!0,!0)),s!=null){const se=Rk(le,de);return[j,ie,se]}else return[j,ie]},z={a:T,b:A,bias:O,preluActivationWeights:P},L={transposeA:t,transposeB:r,activation:o,leakyreluAlpha:a};return s==null?cf((H,Y,re)=>{const te=ae.runKernel(Ly,z,L);return re([H,Y,te]),{value:ce(te,N),gradFunc:B}})(T,A):cf((H,Y,re,te)=>{const le=ae.runKernel(Ly,z,L);return te([H,Y,le,re]),{value:ce(le,N),gradFunc:B}})(T,A,O)}const KN=he({fusedMatMul_:_H});function DH(n,e,t,r,s="bilinear",o=0){const i=K(n,"image","cropAndResize"),a=K(e,"boxes","cropAndResize","float32"),l=K(t,"boxInd","cropAndResize","int32"),c=a.shape[0];U(i.rank===4,()=>`Error in cropAndResize: image must be rank 4,but got rank ${i.rank}.`),U(a.rank===2&&a.shape[1]===4,()=>`Error in cropAndResize: boxes must be have size [${c},4] but had shape ${a.shape}.`),U(l.rank===1&&l.shape[0]===c,()=>`Error in cropAndResize: boxInd must be have size [${c}] but had shape ${a.shape}.`),U(r.length===2,()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`),U(r[0]>=1&&r[1]>=1,()=>`cropSize must be atleast [1,1], but was ${r}`),U(s==="bilinear"||s==="nearest",()=>`method must be bilinear or nearest, but was ${s}`);const d={image:i,boxes:a,boxInd:l},p={method:s,extrapolationValue:o,cropSize:r};return ae.runKernel(RS,d,p)}const OH=he({cropAndResize_:DH});function FH(n){const e=K(n,"image","flipLeftRight","float32");U(e.rank===4,()=>`Error in flipLeftRight: image must be rank 4,but got rank ${e.rank}.`);const t={image:e};return ae.runKernel(zS,t,{})}const PH=he({flipLeftRight_:FH});function LH(n){const e=K(n,"image","grayscaleToRGB"),t=e.rank-1,r=e.shape[t];U(e.rank>=2,()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${e.rank}.`),U(r===1,()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${r}.`);const s=new Array(e.rank);return s.fill(1,0,t),s[t]=3,bi(e,s)}const MH=he({grayscaleToRGB_:LH});function zH(n){const e=K(n,"image","RGBToGrayscale"),t=e.rank-1,r=e.shape[t];U(e.rank>=2,()=>`Error in RGBToGrayscale: images must be at least rank 2, but got rank ${e.rank}.`),U(r===3,()=>`Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${r}.`);const s=e.dtype,o=Ge(e,"float32"),i=qs([.2989,.587,.114]);let a;switch(e.rank){case 2:a=mm("ij,j->i",o,i);break;case 3:a=mm("ijk,k->ij",o,i);break;case 4:a=mm("ijkl,l->ijk",o,i);break;case 5:a=mm("ijklm,m->ijkl",o,i);break;case 6:a=mm("ijklmn,n->ijklm",o,i);break;default:throw new Error("Not a valid tensor rank.")}return a=Ss(a,-1),Ge(a,s)}const BH=he({rgbToGrayscale_:zH});function UH(n,e,t=0,r=.5){const s=K(n,"image","rotateWithOffset","float32");U(s.rank===4,()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${s.rank}.`);const o={image:s},i={radians:e,fillValue:t,center:r};return ae.runKernel(sk,o,i)}const WH=he({rotateWithOffset_:UH});function Nf(n,e,t,r,s,o){r==null&&(r=.5),s==null&&(s=Number.NEGATIVE_INFINITY),o==null&&(o=0);const i=n.shape[0];return t=Math.min(t,i),U(0<=r&&r<=1,()=>`iouThreshold must be in [0, 1], but was '${r}'`),U(n.rank===2,()=>`boxes must be a 2D tensor, but was of rank '${n.rank}'`),U(n.shape[1]===4,()=>`boxes must have 4 columns, but 2nd dimension was ${n.shape[1]}`),U(e.rank===1,()=>"scores must be a 1D tensor"),U(e.shape[0]===i,()=>`scores has incompatible shape with boxes. Expected ${i}, but was ${e.shape[0]}`),U(0<=o&&o<=1,()=>`softNmsSigma must be in [0, 1], but was '${o}'`),{maxOutputSize:t,iouThreshold:r,scoreThreshold:s,softNmsSigma:o}}function VH(n,e,t,r=.5,s=Number.NEGATIVE_INFINITY){const o=K(n,"boxes","nonMaxSuppression","float32"),i=K(e,"scores","nonMaxSuppression","float32"),a=Nf(o,i,t,r,s);t=a.maxOutputSize,r=a.iouThreshold,s=a.scoreThreshold;const l={maxOutputSize:t,iouThreshold:r,scoreThreshold:s};return ae.runKernel(jS,{boxes:o,scores:i},l)}const GH=he({nonMaxSuppression_:VH});function jH(n,e,t){const r=HH(n,e,t),s=r<0?-(r+1):r;n.splice(s,0,e)}function HH(n,e,t){return KH(n,e,t||qH)}function qH(n,e){return n>e?1:n<e?-1:0}function KH(n,e,t){let r=0,s=n.length,o=0,i=!1;for(;r<s;){o=r+(s-r>>>1);const a=t(e,n[o]);a>0?r=o+1:(s=o,i=!a)}return i?r:-r-1}function Dk(n,e,t,r,s){return Pk(n,e,t,r,s,0)}function Ok(n,e,t,r,s,o){return Pk(n,e,t,r,s,0,!1,o,!0)}function Fk(n,e,t,r,s,o){return Pk(n,e,t,r,s,o,!0)}function Pk(n,e,t,r,s,o,i=!1,a=!1,l=!1){const c=[];for(let w=0;w<e.length;w++)e[w]>s&&c.push({score:e[w],boxIndex:w,suppressBeginIndex:0});c.sort(XN);const d=o>0?-.5/o:0,p=[],m=[];for(;p.length<t&&c.length>0;){const w=c.pop(),{score:k,boxIndex:I,suppressBeginIndex:N}=w;if(k<s)break;let T=!1;for(let A=p.length-1;A>=N;--A){const O=XH(n,I,p[A]);if(O>=r){T=!0;break}if(w.score=w.score*YH(r,d,O),w.score<=s)break}w.suppressBeginIndex=p.length,T||(w.score===k?(p.push(I),m.push(w.score)):w.score>s&&jH(c,w,XN))}const y=p.length,v=t-y;a&&v>0&&(p.push(...new Array(v).fill(0)),m.push(...new Array(v).fill(0)));const b={selectedIndices:p};return i&&(b.selectedScores=m),l&&(b.validOutputs=y),b}function XH(n,e,t){const r=n.subarray(e*4,e*4+4),s=n.subarray(t*4,t*4+4),o=Math.min(r[0],r[2]),i=Math.min(r[1],r[3]),a=Math.max(r[0],r[2]),l=Math.max(r[1],r[3]),c=Math.min(s[0],s[2]),d=Math.min(s[1],s[3]),p=Math.max(s[0],s[2]),m=Math.max(s[1],s[3]),y=(a-o)*(l-i),v=(p-c)*(m-d);if(y<=0||v<=0)return 0;const b=Math.max(o,c),w=Math.max(i,d),k=Math.min(a,p),I=Math.min(l,m),N=Math.max(k-b,0)*Math.max(I-w,0);return N/(y+v-N)}function YH(n,e,t){const r=Math.exp(e*t*t);return t<=n?r:0}function XN(n,e){return n.score-e.score||n.score===e.score&&e.boxIndex-n.boxIndex}async function QH(n,e,t,r=.5,s=Number.NEGATIVE_INFINITY){const o=K(n,"boxes","nonMaxSuppressionAsync"),i=K(e,"scores","nonMaxSuppressionAsync"),a=Nf(o,i,t,r,s);t=a.maxOutputSize,r=a.iouThreshold,s=a.scoreThreshold;const l=await Promise.all([o.data(),i.data()]),c=l[0],d=l[1],{selectedIndices:p}=Dk(c,d,t,r,s);return o!==n&&o.dispose(),i!==e&&i.dispose(),qs(p,"int32")}const JH=QH;function ZH(n,e,t,r=.5,s=Number.NEGATIVE_INFINITY,o=0){const i=K(n,"boxes","nonMaxSuppression"),a=K(e,"scores","nonMaxSuppression"),l=Nf(i,a,t,r,s,o);t=l.maxOutputSize,r=l.iouThreshold,s=l.scoreThreshold,o=l.softNmsSigma;const c={boxes:i,scores:a},d={maxOutputSize:t,iouThreshold:r,scoreThreshold:s,softNmsSigma:o},p=ae.runKernel(qS,c,d);return{selectedIndices:p[0],selectedScores:p[1]}}const e5=he({nonMaxSuppressionWithScore_:ZH});async function t5(n,e,t,r=.5,s=Number.NEGATIVE_INFINITY,o=0){const i=K(n,"boxes","nonMaxSuppressionAsync"),a=K(e,"scores","nonMaxSuppressionAsync"),l=Nf(i,a,t,r,s,o);t=l.maxOutputSize,r=l.iouThreshold,s=l.scoreThreshold,o=l.softNmsSigma;const c=await Promise.all([i.data(),a.data()]),d=c[0],p=c[1],{selectedIndices:m,selectedScores:y}=Fk(d,p,t,r,s,o);return i!==n&&i.dispose(),a!==e&&a.dispose(),{selectedIndices:qs(m,"int32"),selectedScores:qs(y)}}const n5=t5;function r5(n,e,t,r=.5,s=Number.NEGATIVE_INFINITY,o=!1){const i=K(n,"boxes","nonMaxSuppression"),a=K(e,"scores","nonMaxSuppression"),l=Nf(i,a,t,r,s,null),c=l.maxOutputSize,d=l.iouThreshold,p=l.scoreThreshold,m={boxes:i,scores:a},y={maxOutputSize:c,iouThreshold:d,scoreThreshold:p,padToMaxOutputSize:o},v=ae.runKernel(HS,m,y);return{selectedIndices:v[0],validOutputs:v[1]}}const s5=he({nonMaxSuppressionPadded_:r5});async function o5(n,e,t,r=.5,s=Number.NEGATIVE_INFINITY,o=!1){const i=K(n,"boxes","nonMaxSuppressionAsync"),a=K(e,"scores","nonMaxSuppressionAsync"),l=Nf(i,a,t,r,s,null),c=l.maxOutputSize,d=l.iouThreshold,p=l.scoreThreshold,[m,y]=await Promise.all([i.data(),a.data()]),{selectedIndices:v,validOutputs:b}=Ok(m,y,c,d,p,o);return i!==n&&i.dispose(),a!==e&&a.dispose(),{selectedIndices:qs(v,"int32"),validOutputs:Kt(b,"int32")}}const i5=o5;function a5(n,e,t=!1,r=!1){const s=K(n,"images","resizeBilinear");U(s.rank===3||s.rank===4,()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${s.rank}.`),U(e.length===2,()=>`Error in resizeBilinear: new shape must 2D, but got shape ${e}.`),U(r===!1||t===!1,()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");let o=s,i=!1;s.rank===3&&(i=!0,o=ce(s,[1,s.shape[0],s.shape[1],s.shape[2]]));const a={images:o},l={alignCorners:t,halfPixelCenters:r,size:e},c=ae.runKernel(lv,a,l);return i?ce(c,[c.shape[1],c.shape[2],c.shape[3]]):c}const HR=he({resizeBilinear_:a5});function l5(n,e,t=!1,r=!1){const s=K(n,"images","resizeNearestNeighbor");U(s.rank===3||s.rank===4,()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${s.rank}.`),U(e.length===2,()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${e}.`),U(s.dtype==="float32"||s.dtype==="int32",()=>"`images` must have `int32` or `float32` as dtype"),U(r===!1||t===!1,()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");let o=s,i=!1;s.rank===3&&(i=!0,o=ce(s,[1,s.shape[0],s.shape[1],s.shape[2]]));const a={images:o},l={alignCorners:t,halfPixelCenters:r,size:e},c=ae.runKernel(av,a,l);return i?ce(c,[c.shape[1],c.shape[2],c.shape[3]]):c}const qR=he({resizeNearestNeighbor_:l5});function u5(n,e="binary",t=!1,r=.5){const s=K(n,"image","threshold"),o=.2989,i=.587,a=.114,l=s.shape[0]*s.shape[1];let c=ne(qs([r]),255),d,p,m,y;if(U(s.rank===3,()=>`Error in threshold: image must be rank 3,but got rank ${s.rank}.`),U(s.shape[2]===3||s.shape[2]===1,()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${s.shape[2]}.`),U(s.dtype==="int32"||s.dtype==="float32",()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${s.dtype}.`),U(e==="otsu"||e==="binary",()=>`Method must be binary or otsu, but was ${e}`),s.shape[2]===3){[d,p,m]=yo(s,[1,1,1],-1);const w=ne(d,o),k=ne(p,i),I=ne(m,a);y=Pe(Pe(w,k),I)}else y=n;if(e==="otsu"){const w=oV(Ge(OR(y),"int32"),$m([]),256);c=c5(w,l)}const v=t?$f(y,c):bo(y,c);return Ge(ne(v,255),"int32")}function c5(n,e){let t=qs([-1]),r=qs([0]),s=qs([0]),o,i,a,l,c,d;for(let p=0;p<n.size-1;p++){o=mn(n,0,p+1),i=mn(n,p+1),c=st(rt(o),e),d=st(rt(i),e);const m=rt(ne(o,Bm(0,o.size)));a=st(m,rt(o));const y=Cv(i.shape,o.size),v=Pe(Bm(0,i.size),y),b=ne(i,v);l=st(rt(b),rt(i));const w=ut(a,l),k=ut(a,l),I=ne(c,d);s=ne(ne(I,w),k);const N=bo(s,r);r=us(N,s,r),t=us(N,qs([p]),t)}return t}const h5=he({threshold_:u5});function d5(n,e,t="nearest",r="constant",s=0,o){const i=K(n,"image","transform","float32"),a=K(e,"transforms","transform","float32");U(i.rank===4,()=>`Error in transform: image must be rank 4,but got rank ${i.rank}.`),U(a.rank===2&&(a.shape[0]===i.shape[0]||a.shape[0]===1)&&a.shape[1]===8,()=>"Error in transform: Input transform should be batch x 8 or 1 x 8"),U(o==null||o.length===2,()=>`Error in transform: outputShape must be [height, width] or null, but got ${o}.`);const l={image:i,transforms:a},c={interpolation:t,fillMode:r,fillValue:s,outputShape:o};return ae.runKernel(nk,l,c)}const f5=he({transform_:d5});function p5(n,e,t){const r=K(n,"a","bandPart");U(r.rank>=2,()=>`bandPart(): Rank must be at least 2, got ${r.rank}.`);const s=r.shape,[o,i]=r.shape.slice(-2);let a,l;typeof e=="number"?(U(e%1===0,()=>`bandPart(): numLower must be an integer, got ${e}.`),U(e<=o,()=>`bandPart(): numLower (${e}) must not be greater than the number of rows (${o}).`),a=K(e<0?o:e,"numLower","bandPart")):(U(e.dtype==="int32",()=>"bandPart(): numLower's dtype must be an int32."),a=us(Vy(e,0),o,zm(e,o))),typeof t=="number"?(U(t%1===0,()=>`bandPart(): numUpper must be an integer, got ${t}.`),U(t<=i,()=>`bandPart(): numUpper (${t}) must not be greater than the number of columns (${i}).`),l=K(t<0?i:t,"numUpper","bandPart")):(U(t.dtype==="int32",()=>"bandPart(): numUpper's dtype must be an int32."),l=us(Vy(t,0),i,zm(t,i)));const c=ce(Bm(0,o,1,"int32"),[-1,1]),d=Bm(0,i,1,"int32"),p=ut(c,d),m=rl($f(p,a),lh(p,zn(l))),y=gr([o,i],r.dtype);return ce(sl(eh(ce(r,[-1,o,i])).map(v=>us(m,v,y))),s)}const m5=he({bandPart_:p5});function g5(n){let e;if(Array.isArray(n)){e=!1,U(n!=null&&n.length>0,()=>"Gram-Schmidt process: input must not be null, undefined, or empty");const s=n[0].shape[0];for(let o=1;o<n.length;++o)U(n[o].shape[0]===s,()=>`Gram-Schmidt: Non-unique lengths found in the input vectors: (${n[o].shape[0]} vs. ${s})`)}else e=!0,n=yo(n,n.shape[0],0).map(s=>nx(s,[0]));U(n.length<=n[0].shape[0],()=>`Gram-Schmidt: Number of vectors (${n.length}) exceeds number of dimensions (${n[0].shape[0]}).`);const t=[],r=n;for(let s=0;s<n.length;++s)t.push(ae.tidy(()=>{let o=r[s];if(s>0)for(let i=0;i<s;++i){const a=ne(rt(ne(t[i],o)),t[i]);o=ut(o,a)}return st(o,kv(o,"euclidean"))}));return e?sl(t,0):t}const x5=he({gramSchmidt_:g5});function y5(n,e=!1){if(U(n.rank>=2,()=>`qr() requires input tensor to have a rank >= 2, but got rank ${n.rank}`),n.rank===2)return YN(n,e);{const t=n.shape.slice(0,n.shape.length-2).reduce((l,c)=>l*c),r=eh(ce(n,[t,n.shape[n.shape.length-2],n.shape[n.shape.length-1]]),0),s=[],o=[];r.forEach(l=>{const[c,d]=YN(l,e);s.push(c),o.push(d)});const i=ce(sl(s,0),n.shape),a=ce(sl(o,0),n.shape);return[i,a]}}function YN(n,e=!1){return ae.tidy(()=>{U(n.shape.length===2,()=>`qr2d() requires a 2D Tensor, but got a ${n.shape.length}D Tensor.`);const t=n.shape[0],r=n.shape[1];let s=$R(t),o=Lc(n);const i=Nb([[1]],[1,1]);let a=Lc(i);const l=t>=r?r:t;for(let c=0;c<l;++c){const d=o,p=a,m=s;[a,o,s]=ae.tidy(()=>{const y=mn(o,[c,c],[t-c,1]),v=kv(y),b=mn(o,[c,c],[1,1]),w=us(bo(b,0),Nb([[-1]]),Nb([[1]])),k=ut(b,ne(w,v)),I=st(y,k);I.shape[0]===1?a=Lc(i):a=Is([i,mn(I,[1,0],[I.shape[0]-1,I.shape[1]])],0);const N=zn(st(qt(w,k),v)),T=mn(o,[c,0],[t-c,r]),A=ne(N,a),O=Lt(a);if(c===0)o=ut(T,qt(A,qt(O,T)));else{const z=ut(T,qt(A,qt(O,T)));o=Is([mn(o,[0,0],[c,r]),z],0)}const P=Lt(A),B=mn(s,[0,c],[t,s.shape[1]-c]);if(c===0)s=ut(B,qt(qt(B,a),P));else{const z=ut(B,qt(qt(B,a),P));s=Is([mn(s,[0,0],[t,c]),z],1)}return[a,o,s]}),kt([d,p,m])}return!e&&t>r&&(s=mn(s,[0,0],[t,r]),o=mn(o,[0,0],[r,r])),[s,o]})}const v5=he({qr_:y5});const nl={flipLeftRight:PH,grayscaleToRGB:MH,resizeNearestNeighbor:qR,resizeBilinear:HR,rgbToGrayscale:BH,rotateWithOffset:WH,cropAndResize:OH,nonMaxSuppression:GH,nonMaxSuppressionAsync:JH,nonMaxSuppressionWithScore:e5,nonMaxSuppressionWithScoreAsync:n5,nonMaxSuppressionPadded:s5,nonMaxSuppressionPaddedAsync:i5,threshold:h5,transform:f5},w5={bandPart:m5,gramSchmidt:x5,qr:v5};const b5=new Map,C5=new Map;class Tf{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}}class Go{constructor(){this.classNameMap={}}static getMap(){return Go.instance==null&&(Go.instance=new Go),Go.instance}static register(e){Go.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function _e(n,e,t){U(n.className!=null,()=>"Class being registered does not have the static className property defined."),U(typeof n.className=="string",()=>"className is required to be a string, but got type "+typeof n.className),U(n.className.length>0,()=>"Class being registered has an empty-string as its className, which is disallowed."),typeof e>"u"&&(e="Custom"),typeof t>"u"&&(t=n.className);const r=t,s=e+">"+r;return Go.register(n),b5.set(s,n),C5.set(n,s),n}class bu extends Tf{minimize(e,t=!1,r){const{value:s,grads:o}=this.computeGradients(e,r);if(r!=null){const i=r.map(a=>({name:a.name,tensor:o[a.name]}));this.applyGradients(i)}else this.applyGradients(o);return kt(o),t?s:(s.dispose(),null)}get iterations(){return this.iterations_==null&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,t){return $G(e,t)}dispose(){this.iterations_!=null&&kt(this.iterations_)}async saveIterations(){return this.iterations_==null&&(this.iterations_=0),{name:"iter",tensor:Kt(this.iterations_,"int32")}}async getWeights(){throw new Error("getWeights() is not implemented for this optimizer yet.")}async setWeights(e){throw new Error(`setWeights() is not implemented for this optimizer class ${this.getClassName()}`)}async extractIterations(e){return this.iterations_=(await e[0].tensor.data())[0],e.slice(1)}}Object.defineProperty(bu,Symbol.hasInstance,{value:n=>n.minimize!=null&&n.computeGradients!=null&&n.applyGradients!=null});class KR extends bu{static get className(){return"Adadelta"}constructor(e,t,r=null){super(),this.learningRate=e,this.rho=t,this.epsilon=r,this.accumulatedGrads=[],this.accumulatedUpdates=[],r==null&&(this.epsilon=ae.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map(r=>r.name):Object.keys(e)).forEach((r,s)=>{const o=ae.registeredVariables[r],i=!1;this.accumulatedGrads[s]==null&&(this.accumulatedGrads[s]={originalName:`${r}/accum_grad`,variable:me(()=>Mt(o).variable(i))}),this.accumulatedUpdates[s]==null&&(this.accumulatedUpdates[s]={originalName:`${r}/accum_var`,variable:me(()=>Mt(o).variable(i))});const a=Array.isArray(e)?e[s].tensor:e[r];if(a==null)return;const l=this.accumulatedGrads[s].variable,c=this.accumulatedUpdates[s].variable;me(()=>{const d=Pe(ne(l,this.rho),ne(bn(a),1-this.rho)),p=ne(st(jr(Pe(c,this.epsilon)),jr(Pe(l,this.epsilon))),a),m=Pe(ne(c,this.rho),ne(bn(p),1-this.rho));l.assign(d),c.assign(m);const y=Pe(ne(p,-this.learningRate),o);o.assign(y)})}),this.incrementIterations()}dispose(){this.accumulatedUpdates!=null&&(kt(this.accumulatedGrads.map(e=>e.variable)),kt(this.accumulatedUpdates.map(e=>e.variable)))}async getWeights(){const e=[...this.accumulatedGrads,...this.accumulatedUpdates];return[await this.saveIterations()].concat(e.map(t=>({name:t.originalName,tensor:t.variable})))}async setWeights(e){e=await this.extractIterations(e);const t=e.length/2,r=!1;this.accumulatedGrads=e.slice(0,t).map(s=>({originalName:s.name,variable:s.tensor.variable(r)})),this.accumulatedUpdates=e.slice(t,t*2).map(s=>({originalName:s.name,variable:s.tensor.variable(r)}))}getConfig(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.rho,t.epsilon)}}class XR extends bu{static get className(){return"Adagrad"}constructor(e,t=.1){super(),this.learningRate=e,this.initialAccumulatorValue=t,this.accumulatedGrads=[]}applyGradients(e){(Array.isArray(e)?e.map(r=>r.name):Object.keys(e)).forEach((r,s)=>{const o=ae.registeredVariables[r];this.accumulatedGrads[s]==null&&(this.accumulatedGrads[s]={originalName:`${r}/accumulator`,variable:me(()=>Cv(o.shape,this.initialAccumulatorValue).variable(!1))});const i=Array.isArray(e)?e[s].tensor:e[r];if(i==null)return;const a=this.accumulatedGrads[s].variable;me(()=>{const l=Pe(a,bn(i));a.assign(l);const c=Pe(ne(st(i,jr(Pe(l,ae.backend.epsilon()))),-this.learningRate),o);o.assign(c)})}),this.incrementIterations()}dispose(){this.accumulatedGrads!=null&&kt(this.accumulatedGrads.map(e=>e.variable))}async getWeights(){return[await this.saveIterations()].concat(this.accumulatedGrads.map(e=>({name:e.originalName,tensor:e.variable})))}async setWeights(e){e=await this.extractIterations(e);const t=!1;this.accumulatedGrads=e.map(r=>({originalName:r.name,variable:r.tensor.variable(t)}))}getConfig(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}}static fromConfig(e,t){return new e(t.learningRate,t.initialAccumulatorValue)}}class YR extends bu{static get className(){return"Adam"}constructor(e,t,r,s=null){super(),this.learningRate=e,this.beta1=t,this.beta2=r,this.epsilon=s,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],me(()=>{this.accBeta1=Kt(t).variable(),this.accBeta2=Kt(r).variable()}),s==null&&(this.epsilon=ae.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map(r=>r.name):Object.keys(e);me(()=>{const r=ut(1,this.accBeta1),s=ut(1,this.accBeta2);t.forEach((o,i)=>{const a=ae.registeredVariables[o],l=!1;this.accumulatedFirstMoment[i]==null&&(this.accumulatedFirstMoment[i]={originalName:`${o}/m`,variable:me(()=>Mt(a).variable(l))}),this.accumulatedSecondMoment[i]==null&&(this.accumulatedSecondMoment[i]={originalName:`${o}/v`,variable:me(()=>Mt(a).variable(l))});const c=Array.isArray(e)?e[i].tensor:e[o];if(c==null)return;const d=this.accumulatedFirstMoment[i].variable,p=this.accumulatedSecondMoment[i].variable,m=Pe(ne(d,this.beta1),ne(c,1-this.beta1)),y=Pe(ne(p,this.beta2),ne(bn(c),1-this.beta2)),v=st(m,r),b=st(y,s);d.assign(m),p.assign(y);const w=Pe(ne(st(v,Pe(jr(b),this.epsilon)),-this.learningRate),a);a.assign(w)}),this.accBeta1.assign(ne(this.accBeta1,this.beta1)),this.accBeta2.assign(ne(this.accBeta2,this.beta2))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),this.accumulatedFirstMoment!=null&&kt(this.accumulatedFirstMoment.map(e=>e.variable)),this.accumulatedSecondMoment!=null&&kt(this.accumulatedSecondMoment.map(e=>e.variable))}async getWeights(){const e=[...this.accumulatedFirstMoment,...this.accumulatedSecondMoment];return[await this.saveIterations()].concat(e.map(t=>({name:t.originalName,tensor:t.variable})))}async setWeights(e){e=await this.extractIterations(e),me(()=>{this.accBeta1.assign(Jc(this.beta1,this.iterations_+1)),this.accBeta2.assign(Jc(this.beta2,this.iterations_+1))});const t=e.length/2,r=!1;this.accumulatedFirstMoment=e.slice(0,t).map(s=>({originalName:s.name,variable:s.tensor.variable(r)})),this.accumulatedSecondMoment=e.slice(t,t*2).map(s=>({originalName:s.name,variable:s.tensor.variable(r)}))}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon)}}class QR extends bu{static get className(){return"Adamax"}constructor(e,t,r,s=null,o=0){super(),this.learningRate=e,this.beta1=t,this.beta2=r,this.epsilon=s,this.decay=o,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],me(()=>{this.iteration=Kt(0).variable(),this.accBeta1=Kt(t).variable()}),s==null&&(this.epsilon=ae.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map(r=>r.name):Object.keys(e);me(()=>{const r=ut(1,this.accBeta1),s=st(-this.learningRate,Pe(ne(this.iteration,this.decay),1));t.forEach((o,i)=>{const a=ae.registeredVariables[o],l=!1;this.accumulatedFirstMoment[i]==null&&(this.accumulatedFirstMoment[i]={originalName:`${o}/m`,variable:Mt(a).variable(l)}),this.accumulatedWeightedInfNorm[i]==null&&(this.accumulatedWeightedInfNorm[i]={originalName:`${o}/v`,variable:Mt(a).variable(l)});const c=Array.isArray(e)?e[i].tensor:e[o];if(c==null)return;const d=this.accumulatedFirstMoment[i].variable,p=this.accumulatedWeightedInfNorm[i].variable,m=Pe(ne(d,this.beta1),ne(c,1-this.beta1)),y=ne(p,this.beta2),v=os(c),b=vu(y,v);d.assign(m),p.assign(b);const w=Pe(ne(st(s,r),st(m,Pe(b,this.epsilon))),a);a.assign(w)}),this.iteration.assign(Pe(this.iteration,1)),this.accBeta1.assign(ne(this.accBeta1,this.beta1))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),this.accumulatedFirstMoment!=null&&kt(this.accumulatedFirstMoment.map(e=>e.variable)),this.accumulatedWeightedInfNorm!=null&&kt(this.accumulatedWeightedInfNorm.map(e=>e.variable))}async getWeights(){throw new Error("getWeights() is not implemented for Adamax yet.")}async setWeights(e){throw new Error("setWeights() is not implemented for Adamax yet.")}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon,t.decay)}}class Lk extends bu{static get className(){return"SGD"}constructor(e){super(),this.learningRate=e,this.setLearningRate(e)}applyGradients(e){(Array.isArray(e)?e.map(r=>r.name):Object.keys(e)).forEach((r,s)=>{const o=Array.isArray(e)?e[s].tensor:e[r];if(o==null)return;const i=ae.registeredVariables[r];me(()=>{const a=Pe(ne(this.c,o),i);i.assign(a)})}),this.incrementIterations()}setLearningRate(e){this.learningRate=e,this.c!=null&&this.c.dispose(),this.c=ha(Kt(-e))}dispose(){this.c.dispose()}async getWeights(){return[await this.saveIterations()]}async setWeights(e){if(e=await this.extractIterations(e),e.length!==0)throw new Error("SGD optimizer does not have settable weights.")}getConfig(){return{learningRate:this.learningRate}}static fromConfig(e,t){return new e(t.learningRate)}}class JR extends Lk{static get className(){return"Momentum"}constructor(e,t,r=!1){super(e),this.learningRate=e,this.momentum=t,this.useNesterov=r,this.accumulations=[],this.m=Kt(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map(r=>r.name):Object.keys(e)).forEach((r,s)=>{const o=ae.registeredVariables[r];this.accumulations[s]==null&&(this.accumulations[s]={originalName:`${r}/momentum`,variable:me(()=>Mt(o).variable(!1))});const i=this.accumulations[s].variable,a=Array.isArray(e)?e[s].tensor:e[r];a!=null&&me(()=>{let l;const c=Pe(ne(this.m,i),a);this.useNesterov?l=Pe(ne(this.c,Pe(a,ne(c,this.m))),o):l=Pe(ne(this.c,c),o),i.assign(c),o.assign(l)})}),this.incrementIterations()}dispose(){this.m.dispose(),this.accumulations!=null&&kt(this.accumulations.map(e=>e.variable))}setMomentum(e){this.momentum=e}async getWeights(){return[await this.saveIterations()].concat(this.accumulations.map(e=>({name:e.originalName,tensor:e.variable})))}async setWeights(e){e=await this.extractIterations(e);const t=!1;this.accumulations=e.map(r=>({originalName:r.name,variable:r.tensor.variable(t)}))}getConfig(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}}static fromConfig(e,t){return new e(t.learningRate,t.momentum,t.useNesterov)}}class ZR extends bu{static get className(){return"RMSProp"}constructor(e,t=.9,r=0,s=null,o=!1){if(super(),this.learningRate=e,this.decay=t,this.momentum=r,this.epsilon=s,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=o,s==null&&(this.epsilon=ae.backend.epsilon()),e==null)throw new Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(e){(Array.isArray(e)?e.map(r=>r.name):Object.keys(e)).forEach((r,s)=>{const o=ae.registeredVariables[r],i=!1;this.accumulatedMeanSquares[s]==null&&(this.accumulatedMeanSquares[s]={originalName:`${r}/rms`,variable:me(()=>Mt(o).variable(i))}),this.accumulatedMoments[s]==null&&(this.accumulatedMoments[s]={originalName:`${r}/momentum`,variable:me(()=>Mt(o).variable(i))}),this.accumulatedMeanGrads[s]==null&&this.centered&&(this.accumulatedMeanGrads[s]={originalName:`${r}/mg`,variable:me(()=>Mt(o).variable(i))});const a=Array.isArray(e)?e[s].tensor:e[r];if(a==null)return;const l=this.accumulatedMeanSquares[s].variable,c=this.accumulatedMoments[s].variable;me(()=>{const d=Pe(ne(l,this.decay),ne(bn(a),1-this.decay));if(this.centered){const p=this.accumulatedMeanGrads[s].variable,m=Pe(ne(p,this.decay),ne(a,1-this.decay)),y=st(ne(a,this.learningRate),jr(ut(d,Pe(bn(m),this.epsilon)))),v=Pe(ne(c,this.momentum),y);l.assign(d),p.assign(m),c.assign(v);const b=ut(o,v);o.assign(b)}else{const p=Pe(ne(l,this.decay),ne(bn(a),1-this.decay)),m=Pe(ne(c,this.momentum),st(ne(a,this.learningRate),jr(Pe(p,this.epsilon))));l.assign(p),c.assign(m);const y=ut(o,m);o.assign(y)}})}),this.incrementIterations()}dispose(){this.accumulatedMeanSquares!=null&&kt(this.accumulatedMeanSquares.map(e=>e.variable)),this.accumulatedMeanGrads!=null&&this.centered&&kt(this.accumulatedMeanGrads.map(e=>e.variable)),this.accumulatedMoments!=null&&kt(this.accumulatedMoments.map(e=>e.variable))}async getWeights(){const e=[...this.accumulatedMeanSquares,...this.accumulatedMoments];return this.centered&&e.push(...this.accumulatedMeanGrads),[await this.saveIterations()].concat(e.map(t=>({name:t.originalName,tensor:t.variable})))}async setWeights(e){e=await this.extractIterations(e);const t=this.centered?e.length/3:e.length/2,r=!1;this.accumulatedMeanSquares=e.slice(0,t).map(s=>({originalName:s.name,variable:s.tensor.variable(r)})),this.accumulatedMoments=e.slice(t,t*2).map(s=>({originalName:s.name,variable:s.tensor.variable(r)})),this.centered&&(this.accumulatedMeanGrads=e.slice(t*2,t*3).map(s=>({originalName:s.name,variable:s.tensor.variable(r)})))}getConfig(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}}static fromConfig(e,t){return new e(t.learningRate,t.decay,t.momentum,t.epsilon,t.centered)}}const S5=[KR,XR,YR,QR,JR,ZR,Lk];function k5(){for(const n of S5)_e(n)}function QN(n,e,t,r){i(n),t=t??0,r=r??1,a(t,r);let s=0;const o=l=>(l.then(c=>{const d=t+ ++s/n.length*(r-t);return e(d),c}),l);function i(l){U(l!=null&&Array.isArray(l)&&l.length>0,()=>"promises must be a none empty array")}function a(l,c){U(l>=0&&l<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${l}`),U(c>=0&&c<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${c}`),U(c>=l,()=>`startFraction must be no more than endFraction, but got startFraction ${l} and endFraction ${c}`)}return Promise.all(n.map(o))}async function I5(n,e){e==null&&(e={});const t=e.fetchFunc==null?ye().platform.fetch:e.fetchFunc,r=n.map(p=>t(p,e.requestInit,{isBinary:!0})),a=(e.onProgress==null?await Promise.all(r):await QN(r,e.onProgress,0,.5)).map(p=>p.arrayBuffer());return e.onProgress==null?await Promise.all(a):await QN(a,e.onProgress,.5,1)}function $5(n,e){var t;const r=e.fetchFunc==null?ye().platform.fetch:e.fetchFunc;let s=0,o;return(t=e.onProgress)===null||t===void 0||t.call(e,0),new ReadableStream({pull:async i=>{for(var a;s<n.length;){o||(o=(await r(n[s],e.requestInit,{isBinary:!0})).body.getReader());const{done:l,value:c}=await o.read();if(l){s++,o=void 0,(a=e.onProgress)===null||a===void 0||a.call(e,s/n.length);continue}i.enqueue(c);return}i.close()}})}const N5="application/octet-stream",T5="application/json";class Mk{constructor(e,t){if(this.DEFAULT_METHOD="POST",t==null&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.weightUrlConverter=t.weightUrlConverter,t.fetchFunc!=null?(U(typeof t.fetchFunc=="function",()=>"Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"),this.fetch=t.fetchFunc):this.fetch=ye().platform.fetch,U(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&U(e.length===2,()=>`URL paths for http must have a length of 2, (actual length is ${e.length}).`),this.path=e,t.requestInit!=null&&t.requestInit.body!=null)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=t.requestInit||{},this.loadOptions=t}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");const t=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);t.body=new FormData;const r=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],s=zU(e,r);if(t.body.append("model.json",new Blob([JSON.stringify(s)],{type:T5}),"model.json"),e.weightData!=null){const i=gu.join(e.weightData);t.body.append("model.weights.bin",new Blob([i],{type:N5}),"model.weights.bin")}const o=await this.fetch(this.path,t);if(o.ok)return{modelArtifactsInfo:ak(e),responses:[o]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${o.status}.`)}async loadModelJSON(){const e=await this.fetch(this.path,this.requestInit);if(!e.ok)throw new Error(`Request to ${this.path} failed with status code ${e.status}. Please verify this URL points to the model JSON of the model to load.`);let t;try{t=await e.json()}catch{let i=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?i+=" Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository.":i+=" Please make sure the server is serving valid JSON for this request.",new Error(i)}const r=t.modelTopology,s=t.weightsManifest;if(r==null&&s==null)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return t}async load(){if(this.loadOptions.streamWeights)return this.loadStream();const e=await this.loadModelJSON();return UU(e,t=>this.loadWeights(t))}async loadStream(){const e=await this.loadModelJSON(),t=await this.getWeightUrls(e.weightsManifest),r=LN(e.weightsManifest),s=()=>$5(t,this.loadOptions);return Object.assign(Object.assign({},e),{weightSpecs:r,getWeightStream:s})}async getWeightUrls(e){const t=Array.isArray(this.path)?this.path[1]:this.path,[r,s]=E5(t),o=this.weightPathPrefix||r,i=[],a=[];for(const l of e)for(const c of l.paths)this.weightUrlConverter!=null?a.push(this.weightUrlConverter(c)):i.push(o+c+s);return this.weightUrlConverter&&i.push(...await Promise.all(a)),i}async loadWeights(e){const t=await this.getWeightUrls(e),r=LN(e),s=await I5(t,this.loadOptions);return[r,s]}}Mk.URL_SCHEME_REGEX=/^https?:\/\//;function E5(n){const e=n.lastIndexOf("/"),t=n.lastIndexOf("?"),r=n.substring(0,e),s=t>e?n.substring(t):"";return[r+"/",s]}function JN(n){return n.match(Mk.URL_SCHEME_REGEX)!=null}const eA=(n,e)=>{if(typeof fetch>"u"&&(e==null||e.fetchFunc==null))return null;{let t=!0;if(Array.isArray(n)?t=n.every(r=>JN(r)):t=JN(n),t)return tA(n,e)}return null};pr.registerSaveRouter(eA);pr.registerLoadRouter(eA);function tA(n,e){return new Mk(n,e)}function R5(n,e){return tA(n,e)}let Ic;function A5(n,e=3){if(e>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(n==null)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");let t=!1,r=!1,s=!1,o=!1,i=!1,a=!1;if(n.data instanceof Uint8Array)t=!0;else if(typeof ImageData<"u"&&n instanceof ImageData)r=!0;else if(typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement)s=!0;else if(typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement)o=!0;else if(n.getContext!=null)i=!0;else if(typeof ImageBitmap<"u"&&n instanceof ImageBitmap)a=!0;else throw new Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${n.constructor.name}`);if(hC(uC,ae.backendName)!=null){const v={pixels:n},b={numChannels:e};return ae.runKernel(uC,v,b)}const[c,d]=s?[n.videoWidth,n.videoHeight]:[n.width,n.height];let p;if(i)p=n.getContext("2d").getImageData(0,0,c,d).data;else if(r||t)p=n.data;else if(o||s||a){if(Ic==null)if(typeof document>"u")if(typeof OffscreenCanvas<"u"&&typeof OffscreenCanvasRenderingContext2D<"u")Ic=new OffscreenCanvas(1,1).getContext("2d");else throw new Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported.");else Ic=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});Ic.canvas.width=c,Ic.canvas.height=d,Ic.drawImage(n,0,0,c,d),p=Ic.getImageData(0,0,c,d).data}let m;if(e===4)m=new Int32Array(p);else{const v=c*d;m=new Int32Array(v*e);for(let b=0;b<v;b++)for(let w=0;w<e;++w)m[b*e+w]=p[b*4+w]}return hH(m,[d,c,e],"int32")}const _5=he({fromPixels_:A5});function zk(n,e){const t=n.shape.length,r=e.shape.length;if(t<1)throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${t}.`);if(r<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${r}.`);if(e.dtype!=="int32")throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${e.dtype}.`);if(e.shape[r-1]>t)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${e.shape[r-1]} vs. ${t}`);if(Se(n.shape)===0)throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${n.shape}.`);const s=e.shape,o=s[s.length-1];let i=1;for(let p=0;p<s.length-1;++p)i*=s[p];const a=n.shape,l=s.slice();l.pop();let c=1;for(let p=o;p<t;++p)c*=a[p],l.push(a[p]);const d=[...tt(n.shape).map(p=>p/c),1].slice(0,o);return[l,i,c,d]}const kC=-2,D5=-1;function Bk(n,e,t){const r=n.shape.length;U(r===e.length,()=>`Error in slice${r}D: Length of begin ${e} must match the rank of the array (${r}).`),U(r===t.length,()=>`Error in slice${r}D: Length of size ${t} must match the rank of the array (${r}).`);for(let s=0;s<r;++s)U(e[s]+t[s]<=n.shape[s],()=>`Error in slice${r}D: begin[${s}] + size[${s}] (${e[s]+t[s]}) would overflow input.shape[${s}] (${n.shape[s]})`)}function O5(n){const e=[];let t=0;for(;n>0;)n&1&&e.push(t),n/=2,t++;return e}function Uk(n,e,t){const r=[];for(let s=0;s<n.length;s++)r[s]=Math.ceil((e[s]-n[s])/t[s]);return r}function nA(n,e,t,r){const s=[...n];for(let o=s.length;o<r.length;o++)s.push(1);for(let o=0;o<t;o++)o===0?s[e]=1:(s.splice(e,0,1),s.pop());return s}function rA(n,e,t){return t<=n?t:t-(e-1)}function sA(n,e){const t=[];for(let r=0;r<n;r++)t.push(e+r);return t}function F5(n,e,t,r,s,o,i,a,l){const c=n.length;let d=new Array(c),p=new Array(c),m=new Array(c);if(e.length&&t>0){const y=e[0],v=t+1;d=oA(i,y,v,r,n),p=iA(a,y,v,s,n),m=nA(o,y,v,n)}else for(let y=0;y<c;y++)d[y]=lA(i,r,o,n,y,l),p[y]=uA(a,s,o,n,y,l),m[y]=aA(o,y,l);return{begin:d,end:p,strides:m}}function oA(n,e,t,r,s){const o=[...s],i=sA(t,e);for(let a=0;a<o.length;a++)if(i.indexOf(a)>-1)o[a]=0;else{const l=rA(e,t,a);let c=r[l];n&1<<l&&(c=0),o[a]=c}return o}function iA(n,e,t,r,s){const o=[...s],i=sA(t,e);for(let a=0;a<o.length;a++)if(i.indexOf(a)>-1)o[a]=Number.MAX_SAFE_INTEGER;else{const l=rA(e,t,a);let c=r[l];n&1<<l&&(c=Number.MAX_SAFE_INTEGER),o[a]=c}for(let a=0;a<o.length;a++){const l=s[a];o[a]<0&&(o[a]+=l),o[a]=Gc(0,o[a],s[a])}return o}function aA(n,e,t){let r=n[e];return(t&1<<e||r==null)&&(r=1),r}function lA(n,e,t,r,s,o){let i=e[s];const a=t[s]||1;(n&1<<s||o&1<<s||i==null)&&(a>0?i=Number.MIN_SAFE_INTEGER:i=Number.MAX_SAFE_INTEGER);const l=r[s];return i<0&&(i+=l),i=Gc(0,i,l-1),i}function uA(n,e,t,r,s,o){let i=e[s];const a=t[s]||1;(n&1<<s||o&1<<s||i==null)&&(a>0?i=Number.MAX_SAFE_INTEGER:i=Number.MIN_SAFE_INTEGER);const l=r[s];return i<0&&(i+=l),a>0?i=Gc(0,i,l):i=Gc(-1,i,l-1),i}function Wk(n,e,t){let r=t.length;for(let s=0;s<t.length;s++)if(t[s]>1){r=s;break}for(let s=r+1;s<t.length;s++)if(e[s]>0||t[s]!==n[s])return!1;return!0}function Vk(n,e){let t=n.length>0?n[n.length-1]:1;for(let r=0;r<n.length-1;r++)t+=n[r]*e[r];return t}function $v(n,e,t){let r;const s=n.shape.length;typeof e=="number"?r=[e,...new Array(s-1).fill(0)]:e.length<s?r=e.concat(new Array(s-e.length).fill(0)):r=e.slice(),r.forEach(i=>{U(i!==-1,()=>"slice() does not support negative begin indexing.")});let o;return t==null?o=new Array(s).fill(-1):typeof t=="number"?o=[t,...new Array(s-1).fill(-1)]:t.length<s?o=t.concat(new Array(s-t.length).fill(-1)):o=t,o=o.map((i,a)=>i>=0?i:(U(i===-1,()=>`Negative size values should be exactly -1 but got ${i} for the slice() size at index ${a}.`),n.shape[a]-r[a])),[r,o]}function Gk(n,e,t,r,s,o,i,a,l){let c;if(r==null?(c=new Array(e.length),c.fill(1)):c=r,i!=null&&(i&i-1)!==0)throw new Error("Multiple ellipses in slice is not allowed.");let d=!1;const p={dims:c.length,numAddAxisAfterEllipsis:0,begin:e.slice(),end:t.slice(),strides:c.slice(),beginMask:s,endMask:o,ellipsisMask:i,newAxisMask:a,shrinkAxisMask:l};for(let N=0;N<p.dims;N++)d&&(1<<N&a)!==0&&p.numAddAxisAfterEllipsis++,1<<N&i&&(d=!0);d||(p.ellipsisMask|=1<<p.dims,p.dims++);const m={dims:n.length,beginMask:0,endMask:0,beginValid:!1,endValid:!1};P5(p,m);let y=!0,v=!0,b=!0;const w=[],k=[];for(let N=0;N<n.length;++N){if(m.strides[N]===0)throw Error(`strides[${N}] must be non-zero`);const T=!!(m.shrinkAxisMask&1<<N),A=n[N];if(A===-1){w.push(T?1:-1);continue}const O=[m.beginMask&1<<N,m.endMask&1<<N],P=[m.strides[N]>0?0:-1,m.strides[N]>0?A:A-1];if(T&&m.strides[N]<=0)throw Error("only stride 1 allowed on non-range indexing.");b=b&&m.strides[N]===1;const B=!!(m.beginMask&1<<N&&m.endMask&1<<N);if(m.beginValid&&m.endValid){if(T){const H=m.begin[N]<0?A+m.begin[N]:m.begin[N];if(m.begin[N]=H,m.end[N]=m.begin[N]+1,H<0||H>=A)throw Error(`slice index ${m.begin[N]} of dimension ${N} out of bounds.`)}else m.begin[N]=ZN(m.begin[N],0,m.strides[N],A,O,P),m.end[N]=ZN(m.end[N],1,m.strides[N],A,O,P);const _=m.strides[N]===1&&m.begin[N]===0&&m.end[N]===A;y=y&&_,v=v&&(N===0&&m.strides[N]===1||_)}else y=y&&m.strides[N]===1&&B,v=v&&(N===0&&m.strides[N]===1||B);let z,L=!1;if(m.beginValid&&m.endValid?(z=m.end[N]-m.begin[N],L=!0):T?(z=1,L=!0):B&&A>=0&&(m.strides[N]<0?z=-A:z=A,L=!0),L){let _;z===0||z<0!=m.strides[N]<0?_=0:_=Math.trunc(z/m.strides[N])+(z%m.strides[N]!==0?1:0),w.push(_)}else w.push(-1)}for(let N=0;N<m.finalShapeGatherIndices.length;++N){const T=m.finalShapeGatherIndices[N];T>=0?k.push(w[T]):T===kC&&k.push(1)}return{finalShapeSparse:k.filter((N,T)=>m.finalShapeGatherIndices[T]!==kC),finalShape:k,isIdentity:y,sliceDim0:v,isSimpleSlice:b,begin:m.begin,end:m.end,strides:m.strides}}function P5(n,e){e.beginMask=0,e.endMask=0,e.shrinkAxisMask=0;let t=0;e.beginValid=n.begin!=null,e.endValid=n.end!=null,e.begin=new Array(e.dims),e.end=new Array(e.dims),e.strides=new Array(e.dims),e.finalShapeGatherIndices=[],e.finalShapeGatherIndicesSparse=[],e.inputShapeGatherIndicesSparse=new Array(e.dims);for(let r=0;r<n.dims;r++)if(1<<r&n.ellipsisMask){const s=Math.min(e.dims-(n.dims-r)+1+n.numAddAxisAfterEllipsis,e.dims);for(;t<s;t++)e.begin[t]=0,e.end[t]=0,e.strides[t]=1,e.beginMask|=1<<t,e.endMask|=1<<t,e.finalShapeGatherIndices.push(t),e.finalShapeGatherIndicesSparse.push(-1),e.inputShapeGatherIndicesSparse[t]=r}else if(1<<r&n.newAxisMask)e.finalShapeGatherIndices.push(kC),e.finalShapeGatherIndicesSparse.push(-1);else{if(t===e.begin.length)throw Error(`Index out of range using input dim ${t}; input has only ${e.dims} dims, ${e.begin.length}.`);n.begin!=null&&(e.begin[t]=n.begin[r]),n.end!=null&&(e.end[t]=n.end[r]),e.strides[t]=n.strides[r],n.beginMask&1<<r&&(e.beginMask|=1<<t),n.endMask&1<<r&&(e.endMask|=1<<t),n.shrinkAxisMask&1<<r?(e.finalShapeGatherIndices.push(D5),e.finalShapeGatherIndicesSparse.push(-1),e.shrinkAxisMask|=1<<t):(e.finalShapeGatherIndices.push(t),e.finalShapeGatherIndicesSparse.push(r)),e.inputShapeGatherIndicesSparse[t]=r,t++}}function ZN(n,e,t,r,s,o){if(s[e])return t>0?o[e]:o[e+1&1];{const i=n<0?r+n:n;return i<o[0]?o[0]:i>o[1]?o[1]:i}}const L5=Object.freeze(Object.defineProperty({__proto__:null,assertParamsValid:Bk,computeFlatOffset:Vk,computeOutShape:Uk,getNormalizedAxes:F5,isSliceContinous:Wk,maskToAxes:O5,parseSliceParams:$v,sliceInfo:Gk,startForAxis:lA,startIndicesWithElidedDims:oA,stopForAxis:uA,stopIndicesWithElidedDims:iA,stridesForAxis:aA,stridesWithElidedDims:nA},Symbol.toStringTag,{value:"Module"}));class M5{static sgd(e){return new Lk(e)}static momentum(e,t,r=!1){return new JR(e,t,r)}static rmsprop(e,t=.9,r=0,s=null,o=!1){return new ZR(e,t,r,s,o)}static adam(e=.001,t=.9,r=.999,s=null){return new YR(e,t,r,s)}static adadelta(e=.001,t=.95,r=null){return new KR(e,t,r)}static adamax(e=.002,t=.9,r=.999,s=null,o=0){return new QR(e,t,r,s,o)}static adagrad(e,t=.1){return new XR(e,t)}}const Wd=M5;const z5=typeof requestAnimationFrame<"u"?requestAnimationFrame:typeof setImmediate<"u"?setImmediate:n=>n();function cA(){return new Promise(n=>z5(()=>n()))}function jk(n,e){const t=n[0].length;n.forEach((s,o)=>{U(s.length===t,()=>`Error in concat${t}D: rank of tensors[${o}] must be the same as the rank of the rest (${t})`)}),U(e>=0&&e<t,()=>`Error in concat${t}D: axis must be between 0 and ${t-1}.`);const r=n[0];n.forEach((s,o)=>{for(let i=0;i<t;i++)U(i===e||s[i]===r[i],()=>`Error in concat${t}D: Shape of tensors[${o}] (${s}) does not match the shape of the rest (${r}) along the non-concatenated axis ${o}.`)})}function da(n,e){const t=n[0].slice();for(let r=1;r<n.length;r++)t[e]+=n[r][e];return t}var vi;(function(n){n[n.FIRST_DIM_SIZE=0]="FIRST_DIM_SIZE",n[n.VALUE_ROWIDS=1]="VALUE_ROWIDS",n[n.ROW_LENGTHS=2]="ROW_LENGTHS",n[n.ROW_SPLITS=3]="ROW_SPLITS",n[n.ROW_LIMITS=4]="ROW_LIMITS",n[n.ROW_STARTS=5]="ROW_STARTS"})(vi||(vi={}));function hA(n,e,t){let r=new Array;if(t==null&&e==null)return r;if(e==null)for(;r.length<n+t.length;)r.push(-1);else r=e.slice();if(t==null)return r;if(n+t.length!==r.length)throw new Error(`rt input.shape and shape=${e} are incompatible: rt input.rank = ${n+t.length}, but shape.rank = ${r.length}`);for(let s=1;s<t.length;++s){const o=t[s],i=r[r.length-t.length+s],a=r[i];if(o>=0)if(a>=0){if(a!==o)throw new Error(`rt input.shape and shape=${e} are incompatible: rt input.shape[${s+n}] = ${o} but shape[${s+n}] = ${a}`)}else r[i]=o}return r}function dA(n){const e={FIRST_DIM_SIZE:vi.FIRST_DIM_SIZE,VALUE_ROWIDS:vi.VALUE_ROWIDS,ROW_LENGTHS:vi.ROW_LENGTHS,ROW_SPLITS:vi.ROW_SPLITS,ROW_LIMITS:vi.ROW_LIMITS,ROW_STARTS:vi.ROW_STARTS},t=[];for(const r of n)if(r in e)t.push(e[r]);else break;return t}function fA(n){return n.length===0?0:n[0]===vi.FIRST_DIM_SIZE?n.length-1:n.length}function pA(n,e){if(n==null||e==null)return;const t=n.length,r=e.length;if(t>=r)throw new Error(`defaultValue.shape=${n} and ragged tensor flatValues.shape=${e}, are incompatible: defaultValue.rank = ${t} must be less than ragged tensor input flatValues.rank = ${r})`);for(let s=0;s<Math.min(t,r-1);++s){const o=n[s],i=e[s+1];if(o>=0&&i>=0&&o!==1&&o!==i)throw new Error(`defaultValue.shape=${n}, and ragged tensor input flatValues.shape=${e} are incompatible: defaultValue.shape[${s-n.length}] = ${o} but ragged tensor input.flatValues.shape[${s-n.length}] = ${i}`)}}const Hk=30;function Nv(n){return n<=Hk?n:iC(n,Math.floor(Math.sqrt(n)))}function qk(n,e,t){const r=t*(typeof n=="number"?n:n[0]),s=e*(typeof n=="number"?n:n[1]);return[r,s]}function sx(n,e,t,r=!0){let s=[];if(r)s=s.concat(e.slice(0)),s.push(n[0]/t),s=s.concat(n.slice(1));else{s=s.concat(n[0]);const o=e.length;for(let i=0;i<o;++i)s=s.concat([n[i+1]/e[i],e[i]]);s=s.concat(n.slice(o+1))}return s}function ox(n,e,t=!0){const r=[];if(t){r.push(e);for(let s=e+1;s<n;++s)s<=2*e?(r.push(s),r.push(s-(e+1))):r.push(s)}else{const s=[],o=[];for(let i=1;i<n;++i)i>=e*2+1||i%2===1?o.push(i):s.push(i);r.push(...s),r.push(0),r.push(...o)}return r}function ix(n,e,t,r=!0){const s=[];r?s.push(n[0]/t):s.push(n[0]*t);for(let o=1;o<n.length;++o)o<=e.length?r?s.push(e[o-1]*n[o]):s.push(n[o]/e[o-1]):s.push(n[o]);return s}function Kk(n,e){const t=[0];for(let r=0;r<e;++r)t.push(n[r][0]);return t}function Xk(n,e,t){const r=n.slice(0,1);for(let s=0;s<t;++s)r.push(n[s+1]-e[s][0]-e[s][1]);return r}const Tv=1.7580993408473768,Ev=1.0507009873554805;const Yk=.3275911,Qk=.254829592,Jk=-.284496736,Zk=1.421413741,eI=-1.453152027,tI=1.061405429;function ol(n,e){if(n.length!==e.length)throw new Error(`Cannot merge real and imag arrays of different lengths. real:${n.length}, imag: ${e.length}.`);const t=new Float32Array(n.length*2);for(let r=0;r<t.length;r+=2)t[r]=n[r/2],t[r+1]=e[r/2];return t}function mA(n){const e=new Float32Array(n.length/2),t=new Float32Array(n.length/2);for(let r=0;r<n.length;r+=2)e[r/2]=n[r],t[r/2]=n[r+1];return{real:e,imag:t}}function gA(n){const e=Math.ceil(n.length/4),t=new Float32Array(e),r=new Float32Array(e);for(let s=0;s<n.length;s+=4)t[Math.floor(s/4)]=n[s],r[Math.floor(s/4)]=n[s+1];return{real:t,imag:r}}function xA(n){const e=Math.floor(n.length/4),t=new Float32Array(e),r=new Float32Array(e);for(let s=2;s<n.length;s+=4)t[Math.floor(s/4)]=n[s],r[Math.floor(s/4)]=n[s+1];return{real:t,imag:r}}function nI(n,e){const t=n[e*2],r=n[e*2+1];return{real:t,imag:r}}function yA(n,e,t,r){n[r*2]=e,n[r*2+1]=t}function vA(n,e){const t=new Float32Array(n/2),r=new Float32Array(n/2);for(let s=0;s<Math.ceil(n/2);s++){const o=(e?2:-2)*Math.PI*(s/n);t[s]=Math.cos(o),r[s]=Math.sin(o)}return{real:t,imag:r}}function wA(n,e,t){const r=(t?2:-2)*Math.PI*(n/e),s=Math.cos(r),o=Math.sin(r);return{real:s,imag:o}}const Tb="->",B5=/->/g,e2=",",t2="...";function rI(n,e){n=n.replace(/\s/g,"");const t=(n.length-n.replace(B5,"").length)/Tb.length;if(t<1)throw new Error("Equations without an arrow are not supported.");if(t>1)throw new Error(`Equation must contain exactly one arrow ("${Tb}").`);const[r,s]=n.split(Tb);U(r.indexOf(t2)===-1,()=>`The ellipsis notation ("${t2}") is not supported yet.`);const o=r.split(e2),i=o.length;if(e!==i)throw new Error(`Expected ${i} input tensors, received ${e}`);if(i>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const a=[];for(let m=0;m<s.length;++m){const y=s[m];if(!o.some(v=>v.indexOf(y)!==-1))throw new Error(`Output subscripts contain the label ${y} not present in the input subscripts.`);a.indexOf(y)===-1&&a.push(y)}for(let m=0;m<r.length;++m){const y=r[m];a.indexOf(y)===-1&&y!==e2&&a.push(y)}const l=new Array(o.length);for(let m=0;m<i;++m){if(new Set(o[m].split("")).size!==o[m].length)throw new Error(`Found duplicate axes in input component ${o[m]}. Support for duplicate axes in input is not implemented yet.`);l[m]=[];for(let y=0;y<o[m].length;++y)l[m].push(a.indexOf(o[m][y]))}const c=a.length,d=s.length,p=[];for(let m=d;m<c;++m)p.push(m);return{allDims:a,summedDims:p,idDims:l}}function sI(n,e){let t=new Array(n);t.fill(-1);for(let s=0;s<e.length;++s)t[e[s]]=s;const r=[];for(let s=0;s<n;++s)t[s]===-1&&r.push(s);return t=t.filter(s=>s!==-1),{permutationIndices:t,expandDims:r}}function oI(n,e,t){const r=new Array(n);for(let s=0;s<t.length;++s){const o=t[s].shape;for(let i=0;i<e[s].length;++i)r[e[s][i]]===void 0?r[e[s][i]]=o[i]:U(r[e[s][i]]===o[i],()=>`Expected dimension ${r[e[s][i]]} at axis ${i} of input shaped ${JSON.stringify(o)}, but got dimension ${o[i]}`)}}function iI(n,e){const t=n,r=[];let s=0;n.length===0&&t.push(-1),s=n.length+1;for(let i=0;i<s;++i)r.push([]);const o=[];for(let i=0;i<t.length;++i){const a=t[i],l=U5(e,a);for(const c of l)o.indexOf(c)===-1&&(r[i].push(c),o.push(c))}return{path:t,steps:r}}function aI(n){return n.every((e,t)=>e===t)}function U5(n,e){const t=[];for(let r=0;r<n.length;++r)(n[r].length===0||n[r].indexOf(e)!==-1||e===-1)&&t.push(r);return t}function lI(n,e,t=0){let r=[];if(typeof e=="number")U(n.shape[t]%e===0,()=>"Number of splits must evenly divide the axis."),r=new Array(e).fill(n.shape[t]/e);else{const s=e.reduce((i,a)=>(a===-1&&(i+=1),i),0);U(s<=1,()=>"There should be only one negative value in split array.");const o=e.indexOf(-1);if(o!==-1){const i=e.reduce((a,l)=>l>0?a+l:a);e[o]=n.shape[t]-i}U(n.shape[t]===e.reduce((i,a)=>i+a),()=>"The sum of sizes must match the size of the axis dimension."),r=e}return r}function bA(n){return`Received SparseTensor with denseShape[0] = 0 but
indices.shape[0] = ${n}`}function CA(n,e){return`indices(${n}, 0) is invalid: ${e} < 0`}function SA(n,e,t){return`indices(${n}, 0) is invalid: ${e} >= ${t}`}function kA(n,e){return`only one output dimension may be -1, not both ${n} and ${e}`}function IA(n,e){return`size ${n} must be non-negative, not ${e}`}function $A(){return"reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero"}function NA(n,e){const t=Se(n),r=Se(e);return`Input to reshape is a SparseTensor with ${t}
dense values, but the requested shape requires a multiple of ${r}. inputShape=${n} outputShape= ${e}`}function TA(n,e){const t=Se(n),r=Se(e);return`Input to reshape is a tensor with ${t} dense values, but the requested shape has ${r}. inputShape=${n} outputShape=${e}`}function IC(){return"segment ids must be >= 0"}function EA(){return"segment ids are not increasing"}function RA(n,e){return`Segment id ${n} out of range [0, ${e}), possibly because segmentIds input is not sorted.`}function AA(n,e,t){return`Bad: indices[${n}] == ${e} out of range [0, ${t})`}function _A(n,e){let t=!1,r;for(n<=Hk?(r=n,t=!0):r=iC(n,Math.floor(Math.sqrt(n)));!t;)r>e||r===n?t=!0:r=iC(n,r+1);return r}function DA(n,e,t){const r=[],s=n.length;for(let o=0;o<s;o++)o!==e?r.push(n[o]):r.push(t);return r}function uI(n,e,t,r){const s=e.shape.length,o=n.shape.length;if(r!==0&&(r<-s||r>s))throw new Error(`Expect batchDims in the range of [-${s}, ${s}], but got ${r}`);if(r<0&&(r+=s),r>o)throw new Error(`batchDims (${r}) must be less than rank(x) (
${o}).`);if(t<r)throw new Error(`batchDims (${r}) must be less than or equal to axis (${t}).`);for(let p=0;p<r;++p)if(n.shape[p]!==e.shape[p])throw new Error(`x.shape[${p}]: ${n.shape[p]} should be equal to indices.shape[${p}]: ${e.shape[p]}.`);const i=n.shape[t],a=[];let l=1,c=1,d=1;for(let p=0;p<r;++p)a.push(n.shape[p]),l*=n.shape[p];for(let p=r;p<t;p++)a.push(n.shape[p]),c*=n.shape[p];for(let p=r;p<s;p++)a.push(e.shape[p]);for(let p=t+1;p<o;p++)a.push(n.shape[p]),d*=n.shape[p];return{batchSize:l,sliceSize:d,outerSize:c,dimSize:i,outputShape:a}}const W5=Object.freeze(Object.defineProperty({__proto__:null,collectGatherOpShapeInfo:uI,computeOutShape:DA,segOpComputeOptimalWindowSize:_A},Symbol.toStringTag,{value:"Module"}));function il(n){try{return n.map(e=>au(e))}catch(e){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function OA(n){return n.map(e=>su(e))}const V5=Object.freeze(Object.defineProperty({__proto__:null,ERF_A1:Qk,ERF_A2:Jk,ERF_A3:Zk,ERF_A4:eI,ERF_A5:tI,ERF_P:Yk,PARALLELIZE_THRESHOLD:Hk,get RowPartitionType(){return vi},SELU_SCALE:Ev,SELU_SCALEALPHA:Tv,applyActivation:Ak,assertAndGetBroadcastShape:gt,assertAxesAreInnerMostDims:Dr,assertParamsConsistent:jk,assignToTypedArray:yA,axesAreInnerMostDims:pk,calculateShapes:ch,checkEinsumDimSizes:oI,checkPadOnDimRoundingMode:Ts,combineLocations:kR,combineRaggedTensorToTensorShapes:hA,complexWithEvenIndex:gA,complexWithOddIndex:xA,computeConv2DInfo:_r,computeConv3DInfo:xu,computeDefaultPad:lk,computeDilation2DInfo:Zg,computeOptimalWindowSize:Nv,computeOutAndReduceShapes:yr,computeOutShape:da,computePool2DInfo:Xo,computePool3DInfo:ll,convertConv2DDataFormat:ul,decodeEinsumEquation:rI,eitherStridesOrDilationsAreOne:Hr,expandShapeToKeepDim:Yn,exponent:wA,exponents:vA,fromStringArrayToUint8:OA,fromUint8ToStringArray:il,getAxesPermutation:En,getBroadcastDims:uf,getComplexWithIndex:nI,getEinsumComputePath:iI,getEinsumPermutation:sI,getFusedBiasGradient:Rk,getFusedDyActivation:Ek,getImageCenter:qk,getInnerMostAxes:Wn,getPermuted:ox,getRaggedRank:fA,getReductionAxes:ar,getReshaped:sx,getReshapedPermuted:ix,getRowPartitionTypesHelper:dA,getSliceBeginCoords:Kk,getSliceSize:Xk,getSparseFillEmptyRowsIndicesDenseShapeMismatch:bA,getSparseFillEmptyRowsNegativeIndexErrorMessage:CA,getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:SA,getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:$A,getSparseReshapeInputOutputMismatchErrorMessage:TA,getSparseReshapeInputOutputMultipleErrorMessage:NA,getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:kA,getSparseReshapeNegativeOutputDimErrorMessage:IA,getSparseSegmentReductionIndicesOutOfRangeErrorMessage:AA,getSparseSegmentReductionNegativeSegmentIdsErrorMessage:IC,getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:EA,getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:RA,getUndoAxesPermutation:yu,isIdentityPermutation:aI,log:sU,mergeRealAndImagArrays:ol,prepareAndValidate:zk,prepareSplitSize:lI,segment_util:W5,shouldFuse:_k,slice_util:L5,splitRealAndImagArrays:mA,stridesOrDilationsArePositive:Yc,tupleValuesAreOne:Xc,upcastType:Ys,validateDefaultValueShape:pA,validateInput:dH,validateUpdateShape:WR,warn:go},Symbol.toStringTag,{value:"Module"}));k5();const FA={kernelName:v1,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>ne(n,rx(Ge(t,"float32"),-1))}}};const G5={kernelName:ng,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>{const r=bn(Ge(t,"float32")),s=jr(ut(Kt(1),r));return zn(st(n,s))}}}};const j5={kernelName:rg,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>{const r=jr(ut(bn(Ge(t,"float32")),1));return st(n,r)}}}};const H5={kernelName:kf,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,r]=e,s=gt(t.shape,r.shape);return{a:()=>{let a=n;const l=ar(t.shape,s);return l.length>0&&(a=rt(a,l)),ce(a,t.shape)},b:()=>{let a=n;const l=ar(r.shape,s);return l.length>0&&(a=rt(a,l)),ce(a,r.shape)}}}};const q5={kernelName:yS,saveAllInputs:!0,gradFunc:(n,e)=>{const t={};return e.forEach((r,s)=>{t[s]=()=>n.clone()}),t}};const K5={kernelName:w1,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>Mt(t)}}};const X5={kernelName:b1,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>Mt(t)}}};const Y5={kernelName:sg,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>st(n,jr(ut(Kt(1),bn(Ge(t,"float32")))))}}};const Q5={kernelName:og,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>{const r=jr(Pe(Kt(1),bn(Ge(t,"float32"))));return st(n,r)}}}};const J5={kernelName:lg,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,r]=e,s=gt(t.shape,r.shape);return{a:()=>{const a=Pe(bn(t),bn(r));let l=ne(n,st(r,a));const c=ar(t.shape,s);return c.length>0&&(l=rt(l,c)),ce(l,t.shape)},b:()=>{const a=Pe(bn(t),bn(r));let l=zn(ne(n,st(t,a)));const c=ar(r.shape,s);return c.length>0&&(l=rt(l,c)),ce(l,r.shape)}}}};const Z5={kernelName:ig,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>st(n,Pe(bn(Ge(t,"float32")),1))}}};const e6={kernelName:ag,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>st(n,ut(Kt(1),bn(Ge(t,"float32"))))}}};function t6(n,e,t,r,s,o){const i=K(n,"dy","avgPool3dGrad"),a=K(e,"input","avgPool3dGrad");let l=i,c=a,d=!1;a.rank===4&&(d=!0,l=ce(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]]),c=ce(a,[1,a.shape[0],a.shape[1],a.shape[2],a.shape[3]])),U(l.rank===5,()=>`Error in avgPool3dGrad: dy must be rank 5 but got rank ${l.rank}.`),U(c.rank===5,()=>`Error in avgPool3dGrad: input must be rank 5 but got rank ${c.rank}.`),Ts("avgPool3dGrad",s,o);const p={dy:l,input:c},m={filterSize:t,strides:r,pad:s,dimRoundingMode:o},y=ae.runKernel(CS,p,m);return d?ce(y,[y.shape[1],y.shape[2],y.shape[3],y.shape[4]]):y}const n6=he({avgPool3dGrad_:t6});const r6={kernelName:S1,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[r]=e,{filterSize:s,strides:o,pad:i,dimRoundingMode:a}=t;return{x:()=>n6(n,r,s,o,i,a)}}};function s6(n,e,t,r,s){const o=K(n,"dy","avgPoolGrad"),i=K(e,"input","avgPoolGrad");U(i.rank===o.rank,()=>`Rank of input (${i.rank}) does not match rank of dy (${o.rank})`);let a=i,l=o,c=!1;i.rank===3&&(c=!0,a=ce(i,[1,i.shape[0],i.shape[1],i.shape[2]]),l=ce(o,[1,o.shape[0],o.shape[1],o.shape[2]])),U(l.rank===4,()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${l.rank}.`),U(a.rank===4,()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${a.rank}.`);const d={dy:l,input:a},p={filterSize:t,strides:r,pad:s},m=ae.runKernel(bS,d,p);return c?ce(m,[m.shape[1],m.shape[2],m.shape[3]]):m}const o6=he({avgPoolGrad_:s6});const i6={kernelName:C1,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[r]=e,{filterSize:s,strides:o,pad:i}=t;return{x:()=>o6(n,r,s,o,i)}}};const a6={kernelName:k1,inputsToSave:["a","b"],gradFunc:(n,e,t)=>{const[r,s]=e,{transposeA:o,transposeB:i}=t;return!o&&!i?{a:()=>qt(n,s,!1,!0),b:()=>qt(r,n,!0,!1)}:!o&&i?{a:()=>qt(n,s,!1,!1),b:()=>qt(n,r,!0,!1)}:o&&!i?{a:()=>qt(s,n,!1,!0),b:()=>qt(r,n,!1,!1)}:{a:()=>qt(s,n,!0,!0),b:()=>qt(n,r,!0,!0)}}};const l6={kernelName:I1,gradFunc:(n,e,t)=>{const{blockShape:r,crops:s}=t;return{x:()=>Ck(n,r,s)}}};const u6={kernelName:tU,gradFunc:(n,e,t)=>{const r=t,s=r.inputShape,o=r.shape,i=Array.from(o);for(let l=s.length-1;l>=0;l--)if(s[l]===o[l])i[l]=1;else if(s[l]!==1)throw new Error(`broadcastTo(): [${s}] cannot be broadcast to [${o}].`);const a=[];for(let l=0;l<i.length;l++)i[l]>1&&a.push(l);return{x:()=>rt(n,a,!0)}}};const c6={kernelName:ug,gradFunc:n=>({x:()=>n.clone()})};const h6={kernelName:cg,gradFunc:n=>({x:()=>Mt(n)})};const d6={kernelName:hg,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[r]=e,{clipValueMin:s,clipValueMax:o}=t;return{x:()=>us(rl(lh(r,s),$f(r,o)),n,Mt(n))}}};const f6={kernelName:$1,inputsToSave:["x"],gradFunc:FA.gradFunc};const p6={kernelName:N1,saveAllInputs:!0,gradFunc:(n,e,t)=>{const r=e.map(l=>l.shape),{axis:s}=t,o=Tt(s,e[0].shape)[0],i=r.map(l=>l[o]);return yo(n,i,o).map(l=>()=>l)}};const m6={kernelName:T1,inputsToSave:["x","filter"],gradFunc:(n,e,t)=>{const[r,s]=e,{dilations:o,strides:i,pad:a,dataFormat:l}=t;return U(Xc(o),()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${o}'`),{x:()=>hk(r.shape,n,s,i,a,l),filter:()=>Tk(r,n,s.shape,i,a,l)}}};const g6={kernelName:E1,inputsToSave:["dy","filter"],gradFunc:(n,e,t)=>{const[r,s]=e,{strides:o,pad:i,dataFormat:a,dimRoundingMode:l}=t;return{dy:()=>Qc(n,s,o,i,a,1,l),filter:()=>Tk(n,r,s.shape,o,i,a,l)}}};function x6(n,e,t,r,s){let o=n;n.rank===4&&(o=ce(n,[1,n.shape[0],n.shape[1],n.shape[2],n.shape[3]]));let i=e;i.rank===4&&(i=ce(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]])),U(o.rank===5,()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${o.shape}.`),U(i.rank===5,()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${i.shape}.`),U(t.length===5,()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${t}.`),U(o.shape[4]===t[3],()=>`Error in conv3dDerFilter: depth of input ${o.shape[4]}) must match input depth in filter (${t[3]}.`),U(i.shape[4]===t[4],()=>`Error in conv3dDerFilter: depth of dy (${i.shape[4]}) must match output depth for filter (${t[4]}).`);const a={x:o,dy:i},l={strides:r,pad:s,filterShape:t};return ae.runKernel(NS,a,l)}const y6=he({conv3DBackpropFilter_:x6});const v6={kernelName:R1,inputsToSave:["x","filter"],gradFunc:(n,e,t)=>{const{dilations:r,strides:s,pad:o}=t;U(Xc(r),()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${r}'`);const[i,a]=e;return{x:()=>wR(i.shape,n,a,s,o),filter:()=>y6(i,n,a.shape,s,o)}}};const w6={kernelName:dg,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>ne(zn(MR(Ge(t,"float32"))),n)}}};const b6={kernelName:fg,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>ne(zR(Ge(t,"float32")),n)}}};const C6={kernelName:A1,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[r]=e,{axis:s,exclusive:o,reverse:i}=t;return{x:()=>{const a=En([s],r.rank);let l=CR(n,s,o,!i);return a!=null&&(l=Lt(l,a)),l}}}};const S6={kernelName:_1,inputsToSave:["x","filter"],gradFunc:(n,e,t)=>{const{dilations:r,strides:s,pad:o,dimRoundingMode:i}=t,a=r??[1,1];U(Xc(a),()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${a}'`);const[l,c]=e;return U(l.rank===4,()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${l.rank}.`),U(c.rank===4,()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${c.rank}.`),U(l.shape[3]===c.shape[2],()=>`Error in gradient of depthwiseConv2d: number of input channels (${l.shape[3]}) must match the inChannels dimension in filter ${c.shape[2]}.`),U(Hr(s,a),()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${s} and dilations '${a}'.`),Ts("depthwiseConv2d",o,i),{x:()=>AH(l.shape,n,c,s,o,a,i),filter:()=>EH(l,n,c.shape,s,o,a,i)}}};const k6={kernelName:D1,inputsToSave:["x","filter"],gradFunc:(n,e,t)=>{const[r,s]=e,o={x:r,filter:s,dy:n},i={x:r,filter:s,dy:n};return{x:()=>ae.runKernel(aC,o,t),filter:()=>ae.runKernel(lC,i,t)}}};const I6={kernelName:mg,outputsToSave:[!0],gradFunc:(n,e)=>{const[t]=e,r={dy:n,y:t};return{x:()=>ae.runKernel(PS,r)}}};const $6={kernelName:gg,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e,r=ne(xa(zn(bn(t))),2/Math.sqrt(Math.PI));return{x:()=>ne(n,r)}}};const N6={kernelName:xg,outputsToSave:[!0],gradFunc:(n,e)=>{const[t]=e;return{x:()=>ne(n,t)}}};const T6={kernelName:F1,inputsToSave:["input"],gradFunc:(n,e)=>{const[t]=e;return{input:()=>ce(n,t.shape)}}};const E6={kernelName:yg,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>ne(n,xa(t))}}};const R6={kernelName:vg,gradFunc:n=>({x:()=>Mt(n)})};const A6={kernelName:wg,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,r]=e,s=gt(t.shape,r.shape);return{a:()=>{const a=st(n,Ge(r,"float32")),l=ar(t.shape,s);return l.length>0?ce(rt(a,l),t.shape):a},b:()=>{let a=ne(n,Ge(t,"float32"));const l=ar(r.shape,s);l.length>0&&(a=ce(rt(a,l),r.shape));const c=bn(r);return zn(st(a,Ge(c,"float32")))}}}};const _6={kernelName:P1,inputsToSave:["x","mean","variance","scale"],gradFunc:(n,e,t)=>{const{varianceEpsilon:r}=t,[s,o,i,a]=e,l=a??Kt(1),c=ar(o.shape,s.shape),d=[];if(o.rank===1){for(let T=0;T<s.shape.length-1;++T)d.push(s.shape[T]);d.push(1)}const p=ut(s,o),m=ne(n,l),y=FR(Pe(i,Kt(r))),v=ne(ne(ne(y,y),y),Kt(-.5));return{x:()=>o.rank===1?ce(ne(ne(n,bi(ce(y,[1,1,1,o.shape[0]]),d)),l),s.shape):ce(ne(ne(n,y),l),s.shape),mean:()=>{let T=ne(ne(y,Kt(-1)),m);return o.rank===1&&(T=rt(T,c)),ce(T,o.shape)},variance:()=>{let T=ne(ne(v,p),m);return o.rank===1&&(T=rt(T,c)),ce(T,o.shape)},scale:()=>{const T=ne(p,y);let A=ne(n,T);return o.rank===1&&(A=rt(A,c)),ce(A,o.shape)},offset:()=>{let T=n;return o.rank===1&&(T=rt(T,c)),ce(T,o.shape)}}}};const D6={kernelName:L1,inputsToSave:["x","indices"],gradFunc:(n,e,t)=>{const[r,s]=e,{axis:o,batchDims:i}=t,a=Tt(o,r.shape)[0],l=(c,d,p)=>()=>{const m=c.shape,y=d.size,v=m.slice(0,a),b=v.length,w=m.slice(o,m.length).slice(1),k=w.length,I=n2(0,b),N=n2(b+1,b+1+k),T=r2([v,[y],w]),A=ce(p,T),O=ce(d,[y]),P=r2([[b],I,N]),B=Lt(A,P);let z=GR(B,O,c.shape[a]);const L=yu(P);return z=Lt(z,L),z};if(i===1){const c=r.shape[0],d=r.split(c,0);return{x:()=>sl(d.map((y,v)=>l(y,s.slice(v,1),n.slice(v,1))())).reshape(r.shape),indices:()=>s}}else return{x:l(r,s,n),indices:()=>s}}};function n2(n,e){const t=[];for(let r=n;r<e;++r)t.push(r);return t}function r2(n){const e=[];for(let t=0;t<n.length;++t)for(let r=0;r<n[t].length;++r)e.push(n[t][r]);return e}const O6={kernelName:bg,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,r]=e;return{a:()=>Mt(t),b:()=>Mt(r)}}};const F6={kernelName:Cg,gradFunc:n=>({x:()=>Ge(n,"float32")})};const P6={kernelName:Sg,gradFunc:n=>({x:()=>Mt(n)})};const L6={kernelName:kg,gradFunc:n=>({x:()=>Mt(n)})};const M6={kernelName:Ig,gradFunc:n=>({x:()=>Mt(n)})};const z6={kernelName:z1,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[r]=e,{alpha:s}=t,o=bo(r,0);return{x:()=>us(o,n,ne(n,s))}}};const B6={kernelName:Ng,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>st(n,Pe(t,1))}}};const U6={kernelName:$g,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>st(n,Ge(t,"float32"))}}};const W6={kernelName:rU,inputsToSave:[],outputsToSave:[!0],gradFunc:(n,e,t)=>{const[r]=e,{axis:s}=t;return{logits:()=>{const i=xa(r);return ut(n,ne(rt(n,s,!0),i))}}}};function V6(n,e,t,r=5,s=1,o=1,i=.5){const a={x:n,y:e,dy:t},l={depthRadius:r,bias:s,alpha:o,beta:i};return ae.runKernel(WS,a,l)}const G6=he({localResponseNormalizationBackprop_:V6});const j6={kernelName:j1,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const[r,s]=e,{depthRadius:o,bias:i,alpha:a,beta:l}=t;return{x:()=>G6(r,s,n,o,i,a,l)}}};function PA(n,e,t,r){return e.rank<t.rank&&(e=ce(e,Yn(e.shape,r))),n.rank<t.rank&&(n=ce(n,Yn(n.shape,r))),{x:()=>ne(n,Ge(ga(t,e),n.dtype))}}const s2={kernelName:H1,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const r=t,{reductionIndices:s}=r,o=e[0],i=e[1],a=Tt(s,o.shape),l=PA(n,i,o,a);return{x:()=>l.x()}}};const H6={kernelName:Tg,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,r]=e;return{a:()=>ne(n,Ge(lh(t,r),"float32")),b:()=>ne(n,Ge(Vy(t,r),"float32"))}}};function q6(n,e,t,r,s,o,i){const a=K(n,"dy","maxPool3dGrad"),l=K(e,"input","maxPool3dGrad"),c=K(t,"output","maxPool3dGrad");let d=a,p=l,m=c,y=!1;l.rank===4&&(y=!0,d=ce(a,[1,a.shape[0],a.shape[1],a.shape[2],a.shape[3]]),p=ce(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]]),m=ce(c,[1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]])),U(d.rank===5,()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${d.rank}.`),U(p.rank===5,()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${p.rank}.`),U(m.rank===5,()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${m.rank}.`),Ts("maxPool3dGrad",o,i);const v={dy:d,input:p,output:m},b={filterSize:r,strides:s,pad:o,dimRoundingMode:i},w=ae.runKernel(GS,v,b);return y?ce(w,[w.shape[1],w.shape[2],w.shape[3],w.shape[4]]):w}const K6=he({maxPool3dGrad_:q6});const X6={kernelName:K1,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const[r,s]=e,{filterSize:o,strides:i,pad:a,dimRoundingMode:l}=t;return{x:()=>K6(n,r,s,o,i,a,l)}}};function Y6(n,e,t,r,s,o,i){const a=K(n,"dy","maxPoolGrad"),l=K(e,"input","maxPoolGrad"),c=K(t,"output","maxPoolGrad");U(l.rank===a.rank,()=>`Rank of input (${l.rank}) does not match rank of dy (${a.rank})`),U(a.rank===4,()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${a.rank}.`),U(l.rank===4,()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${l.rank}.`),Ts("maxPoolGrad",o,i);const d={dy:a,input:l,output:c},p={filterSize:r,strides:s,pad:o,dimRoundingMode:i};return ae.runKernel(VS,d,p)}const Q6=he({maxPoolGrad_:Y6});const J6={kernelName:q1,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const[r,s]=e,{filterSize:o,strides:i,pad:a}=t;return{x:()=>Q6(n,r,s,o,i,a)}}};const Z6={kernelName:X1,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[r]=e,{axis:s}=t,o=Tt(s,r.shape),a=yr(r.shape,o)[1],l=Se(a);return{x:()=>{const d=r.shape.slice();o.forEach(y=>{d[y]=1});const p=ce(n,d);return st(ne(p,wu(r.shape,"float32")),l)}}}};const e8={kernelName:Y1,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(n,e,t)=>{const r=t,{axis:s}=r,[o,i]=e,a=Tt(s,o.shape),l=PA(n,i,o,a);return{x:()=>l.x()}}};const t8={kernelName:Eg,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,r]=e;return{a:()=>ne(n,Ge($f(t,r),"float32")),b:()=>ne(n,Ge(bo(t,r),"float32"))}}};const n8={kernelName:Q1,inputsToSave:["x"],gradFunc:(n,e,t)=>{const r=e[0],{paddings:s}=t,o=s.map(i=>i[0]);return{x:()=>mn(n,o,r.shape)}}};const r8={kernelName:Rg,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,r]=e,s=gt(t.shape,r.shape);return{a:()=>{const a=ar(t.shape,s);return a.length>0?ce(rt(n,a),t.shape):n},b:()=>{const a=ne(n,zn(Iv(st(t,r)))),l=ar(r.shape,s);return l.length>0?ce(rt(a,l),r.shape):a}}}};const s8={kernelName:Ag,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,r]=e,s=gt(t.shape,r.shape);return{a:()=>{const a=ne(n,Ge(r,"float32")),l=ar(t.shape,s);return l.length>0?ce(rt(a,l),t.shape):a},b:()=>{const a=ne(n,Ge(t,"float32")),l=ar(r.shape,s);return l.length>0?ce(rt(a,l),r.shape):a}}}};const o8={kernelName:J1,gradFunc:n=>({x:()=>zn(n)})};const i8={kernelName:tv,inputsToSave:["indices"],gradFunc:(n,e)=>{const t=e[0];return{indices:()=>gr(t.shape,"float32")}}};const a8={kernelName:ev,gradFunc:n=>({x:()=>Mt(n)})};const l8={kernelName:nv,saveAllInputs:!0,gradFunc:(n,e,t)=>{const{axis:r}=t;return eh(n,r).map(o=>()=>o)}};const o2={kernelName:rv,inputsToSave:["x"],gradFunc:(n,e,t)=>{const r=e[0],{paddings:s}=t,o=s.map(i=>i[0]);return{x:()=>mn(n,o,r.shape)}}};const u8={kernelName:_g,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(n,e)=>{const[t,r,s]=e,o=t,i=r,a=gt(o.shape,i.shape);return{a:()=>{const d=Ge(i,"float32");let p=ne(n,ne(d,Jc(o,ut(d,Kt(1)))));const m=ar(o.shape,a);return m.length>0&&(p=rt(p,m)),ce(p,o.shape)},b:()=>{const d=bo(o,0),p=us(d,ya(o),Mt(o));let m=ne(n,ne(s,p));const y=ar(i.shape,a);return y.length>0&&(m=rt(m,y)),ce(m,i.shape)}}}};const c8={kernelName:sv,inputsToSave:["x","alpha"],gradFunc:(n,e)=>{const[t,r]=e,s=bo(t,0);return{x:()=>us(s,n,ne(n,r)),alpha:()=>{let o=us(s,Mt(n),ne(n,t));const i=ar(r.shape,n.shape);return i.length>0&&(o=rt(o,i)),ce(o,r.shape)}}}};function h8(n,e,t){const r=n.shape.slice();r[t]=1;const s=ce(e,r),o=CC(n,t,!0,!1),i=CC(n,t,!0,!0),a=ne(o,i);return ne(s,a)}function d8(n,e,t){const r=n.shape.length,s=r-t.length,o=En(t,r);let i=n;o!=null&&(i=Lt(n,o));const a=i.shape.slice(),c=a.splice(r-t.length,t.length).reduce((m,y)=>m*y,1);a.push(c);const d=i.reshape(a);let p=h8(d,e,s);if(p=p.reshape(i.shape),o!=null){const m=yu(o);p=Lt(p,m)}return p}const f8={kernelName:ov,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[r]=e,{axis:s}=t;let o=[];return s==null?o=r.shape.map((i,a)=>a):typeof s=="number"?o=[s]:o=s,{x:()=>d8(r,n,o)}}};const p8={kernelName:pg,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,r]=e,s=gt(t.shape,r.shape);return{a:()=>{const a=st(n,Ge(r,"float32")),l=ar(t.shape,s);return l.length>0?ce(rt(a,l),t.shape):a},b:()=>{let a=ne(n,Ge(t,"float32"));const l=ar(r.shape,s);l.length>0&&(a=ce(rt(a,l),r.shape));const c=bn(r);return zn(st(a,Ge(c,"float32")))}}}};const m8={kernelName:Dg,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>st(n,zn(bn(t)))}}};const g8={kernelName:Fg,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e,r=ne($f(t,6),rx(t));return{x:()=>ne(n,Ge(r,"float32"))}}};const x8={kernelName:Og,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>ne(n,Ge(rx(t),"float32"))}}};const y8={kernelName:iv,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>ce(n,t.shape)}}};const v8={kernelName:lv,inputsToSave:["images"],gradFunc:(n,e,t)=>{const[r]=e,s={dy:n,images:r};return{images:()=>ae.runKernel(QS,s,t)}}};const w8={kernelName:av,inputsToSave:["images"],gradFunc:(n,e,t)=>{const[r]=e,s={dy:n,images:r};return{images:()=>ae.runKernel(YS,s,t)}}};const b8={kernelName:uv,gradFunc:(n,e,t)=>{const{dims:r}=t,s=Tt(r,n.shape);return{x:()=>Zc(n,s)}}};const C8={kernelName:Pg,gradFunc:n=>({x:()=>Mt(n)})};const S8={kernelName:Lg,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>zn(st(n,ne(Jc(t,1.5),2)))}}};const k8={kernelName:cv,inputsToSave:["condition"],gradFunc:(n,e)=>{const[t]=e;return{condition:()=>Ge(Mt(t),"float32"),t:()=>ne(n,Ge(t,n.dtype)),e:()=>ne(n,Ge(yk(t),n.dtype))}}};const I8={kernelName:Mg,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>{const r=bo(t,Kt(0)),s=Kt(Tv),o=Kt(Ev),i=ne(n,o),a=ne(ne(n,s),xa(Ge(t,"float32")));return us(r,i,a)}}}};const $8={kernelName:Wg,outputsToSave:[!0],gradFunc:(n,e)=>{const[t]=e;return{x:()=>ne(n,ne(t,ut(Kt(1),t)))}}};const N8={kernelName:Ug,gradFunc:n=>({x:()=>Mt(n)})};const T8={kernelName:zg,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>ne(dk(Ge(t,"float32")),n)}}};const E8={kernelName:Bg,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>ne(bR(Ge(t,"float32")),n)}}};const R8={kernelName:hv,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[r]=e,{begin:s,size:o}=t,i=r.shape,[a,l]=$v(r,s,o),c=[];for(let d=0;d<n.rank;d++)c.push([a[d],i[d]-a[d]-l[d]]);return{x:()=>bk(n,c)}}};const A8={kernelName:mv,outputsToSave:[!0],gradFunc:(n,e,t)=>{const[r]=e,{dim:s}=t,o=!0,i=ne(n,r);return{logits:()=>ut(i,ne(rt(i,[s],o),r))}}};const _8={kernelName:Vg,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>ne(n,If(t))}}};const i2={kernelName:fv,gradFunc:(n,e,t)=>{const{blockShape:r,paddings:s}=t;return{x:()=>ck(n,r,s)}}};const a2={kernelName:pv,gradFunc:(n,e,t)=>{const{axis:r}=t;return{x:()=>Is(n,r)}}};const D8={kernelName:Gg,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>st(n,ne(jr(Ge(t,"float32")),2))}}};const O8={kernelName:JS,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>ne(n,ne(Ge(t,"float32"),2))}}};const F8={kernelName:jg,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,r]=e,s=Kt(2);return{a:()=>ne(n,ne(s,ut(t,r))),b:()=>ne(n,ne(s,ut(r,t)))}}};const P8={kernelName:Yg,gradFunc:n=>({x:()=>Mt(n)})};const L8={kernelName:Hg,inputsToSave:["a","b"],gradFunc:(n,e)=>{const[t,r]=e,s=gt(t.shape,r.shape);return{a:()=>{let a=n;const l=ar(t.shape,s);return l.length>0&&(a=rt(a,l)),ce(a,t.shape)},b:()=>{let a=n;const l=ar(r.shape,s);return l.length>0&&(a=rt(a,l)),ce(zn(a),r.shape)}}}};const M8={kernelName:dv,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[r]=e,s=r.shape.slice(),{axis:o}=t;Tt(o,r.shape).forEach(c=>{s[c]=1});const a=ce(n,s),l=ne(a,wu(r.shape,"float32"));return{x:()=>l}}};const z8={kernelName:qg,inputsToSave:["x"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>st(n,bn(dk(t)))}}};const B8={kernelName:Kg,outputsToSave:[!0],gradFunc:(n,e)=>{const[t]=e;return{x:()=>ne(ut(Kt(1),bn(t)),n)}}};const U8={kernelName:Xg,inputsToSave:["x"],gradFunc:(n,e,t)=>{const[r]=e,{reps:s}=t;return{x:()=>{let i=Mt(r);if(r.rank===1)for(let a=0;a<s[0];++a)i=Pe(i,mn(n,[a*r.shape[0]],[r.shape[0]]));else if(r.rank===2)for(let a=0;a<s[0];++a)for(let l=0;l<s[1];++l)i=Pe(i,mn(n,[a*r.shape[0],l*r.shape[1]],[r.shape[0],r.shape[1]]));else if(r.rank===3)for(let a=0;a<s[0];++a)for(let l=0;l<s[1];++l)for(let c=0;c<s[2];++c)i=Pe(i,mn(n,[a*r.shape[0],l*r.shape[1],c*r.shape[2]],[r.shape[0],r.shape[1],r.shape[2]]));else if(r.rank===4)for(let a=0;a<s[0];++a)for(let l=0;l<s[1];++l)for(let c=0;c<s[2];++c)for(let d=0;d<s[3];++d)i=Pe(i,mn(n,[a*r.shape[0],l*r.shape[1],c*r.shape[2],d*r.shape[3]],[r.shape[0],r.shape[1],r.shape[2],r.shape[3]]));else throw new Error(`Gradient for tile operation is not implemented for rank-${r.rank} tensors yet.`);return i}}}};const W8={kernelName:ef,gradFunc:(n,e,t)=>{const r=t,{perm:s}=r,o=yu(s);return{x:()=>Lt(n,o)}}};const V8={kernelName:gv,gradFunc:(n,e,t)=>{const r=t,{axis:s}=r;return{value:()=>sl(n,s)}}};const G8={kernelName:xv,inputsToSave:["segmentIds"],gradFunc:(n,e)=>{const[t]=e;return{x:()=>j8(n,t)}}};function j8(n,e){const t=vu(e,Mt(e)),r=mk(n,t);let s=lh(e,Kt(0,"int32"));const o=r.rank-s.rank;for(let a=0;a<o;++a)s=Ss(s,a+1);s=rl(s,wu(r.shape,"bool"));const i=Mt(r);return us(s,r,i)}const H8={kernelName:yv,gradFunc:n=>({x:()=>Mt(n)})};const q8=[FA,G5,j5,H5,q5,K5,X5,Y5,Q5,J5,Z5,e6,r6,i6,a6,l6,u6,c6,h6,d6,f6,p6,g6,m6,v6,w6,b6,C6,S6,k6,p8,I6,$6,N6,T6,E6,A6,R6,_6,D6,O6,F6,P6,L6,M6,z6,B6,U6,W6,j6,s2,s2,H6,X6,J6,Z6,e8,t8,n8,r8,s8,o8,i8,a8,l8,o2,o2,u8,c8,f8,m8,g8,x8,y8,v8,w8,b8,C8,S8,k8,I8,$8,N8,T8,E8,R8,A8,_8,i2,i2,a2,a2,D8,F8,O8,P8,L8,M8,z8,B8,U8,W8,V8,G8,H8];for(const n of q8)oU(n);Ce().prototype.abs=function(){return this.throwIfDisposed(),os(this)};Ce().prototype.acos=function(){return this.throwIfDisposed(),yW(this)};Ce().prototype.acosh=function(){return this.throwIfDisposed(),wW(this)};Ce().prototype.add=function(n){return this.throwIfDisposed(),Pe(this,n)};Ce().prototype.all=function(n,e){return this.throwIfDisposed(),xR(this,n,e)};Ce().prototype.any=function(n,e){return this.throwIfDisposed(),wC(this,n,e)};Ce().prototype.argMax=function(n){return this.throwIfDisposed(),Pm(this,n)};Ce().prototype.argMin=function(n){return this.throwIfDisposed(),IW(this,n)};Ce().prototype.asScalar=function(){return this.throwIfDisposed(),U(this.size===1,()=>"The array must have only 1 element."),ce(this,[])};Ce().prototype.asType=function(n){return this.throwIfDisposed(),Ge(this,n)};Ce().prototype.as1D=function(){return this.throwIfDisposed(),ce(this,[this.size])};Ce().prototype.as2D=function(n,e){return this.throwIfDisposed(),ce(this,[n,e])};Ce().prototype.as3D=function(n,e,t){return this.throwIfDisposed(),ce(this,[n,e,t])};Ce().prototype.as4D=function(n,e,t,r){return this.throwIfDisposed(),ce(this,[n,e,t,r])};Ce().prototype.as5D=function(n,e,t,r,s){return this.throwIfDisposed(),ce(this,[n,e,t,r,s])};Ce().prototype.asin=function(){return this.throwIfDisposed(),NW(this)};Ce().prototype.asinh=function(){return this.throwIfDisposed(),EW(this)};Ce().prototype.atan=function(){return this.throwIfDisposed(),AW(this)};Ce().prototype.atan2=function(n){return this.throwIfDisposed(),DW(this,n)};Ce().prototype.atanh=function(){return this.throwIfDisposed(),FW(this)};Ce().prototype.avgPool=function(n,e,t,r){return this.throwIfDisposed(),uk(this,n,e,t,r)};Ce().prototype.batchToSpaceND=function(n,e){return this.throwIfDisposed(),ck(this,n,e)};Ce().prototype.batchNorm=function(n,e,t,r,s){return this.throwIfDisposed(),bv(this,n,e,t,r,s)};Ce().prototype.broadcastTo=function(n){return this.throwIfDisposed(),Nm(this,n)};Ce().prototype.cast=function(n){return this.throwIfDisposed(),Ge(this,n)};Ce().prototype.ceil=function(){return this.throwIfDisposed(),lV(this)};Ce().prototype.clipByValue=function(n,e){return this.throwIfDisposed(),wo(this,n,e)};Ce().prototype.concat=function(n,e){return this.throwIfDisposed(),n instanceof tr&&(n=[n]),Is([this,...n],e)};Ce().prototype.conv1d=function(n,e,t,r,s,o){return this.throwIfDisposed(),yR(this,n,e,t,r,s,o)};Ce().prototype.conv2dTranspose=function(n,e,t,r,s){return this.throwIfDisposed(),vR(this,n,e,t,r,s)};Ce().prototype.conv2d=function(n,e,t,r,s,o){return this.throwIfDisposed(),Qc(this,n,e,t,r,s,o)};Ce().prototype.cos=function(){return this.throwIfDisposed(),dk(this)};Ce().prototype.cosh=function(){return this.throwIfDisposed(),bR(this)};Ce().prototype.cumprod=function(n,e,t){return this.throwIfDisposed(),CC(this,n,e,t)};Ce().prototype.cumsum=function(n,e,t){return this.throwIfDisposed(),CR(this,n,e,t)};Ce().prototype.depthToSpace=function(n,e){return this.throwIfDisposed(),DV(this,n,e)};Ce().prototype.depthwiseConv2d=function(n,e,t,r,s,o){return this.throwIfDisposed(),fk(this,n,e,t,r,s,o)};Ce().prototype.dilation2d=function(n,e,t,r,s){return this.throwIfDisposed(),PV(this,n,e,t,r,s)};Ce().prototype.divNoNan=function(n){return this.throwIfDisposed(),UV(this,n)};Ce().prototype.div=function(n){return this.throwIfDisposed(),st(this,n)};Ce().prototype.dot=function(n){return this.throwIfDisposed(),VV(this,n)};Ce().prototype.elu=function(){return this.throwIfDisposed(),Sv(this)};Ce().prototype.equal=function(n){return this.throwIfDisposed(),ga(this,n)};Ce().prototype.erf=function(){return this.throwIfDisposed(),SR(this)};Ce().prototype.euclideanNorm=function(n,e){return this.throwIfDisposed(),tG(this,n,e)};Ce().prototype.exp=function(){return this.throwIfDisposed(),xa(this)};Ce().prototype.expandDims=function(n){return this.throwIfDisposed(),Ss(this,n)};Ce().prototype.expm1=function(){return this.throwIfDisposed(),oG(this)};Ce().prototype.fft=function(){return this.throwIfDisposed(),UR(this)};Ce().prototype.flatten=function(){return this.throwIfDisposed(),ce(this,[this.size])};Ce().prototype.floor=function(){return this.throwIfDisposed(),Iv(this)};Ce().prototype.floorDiv=function(n){return this.throwIfDisposed(),gR(this,n)};Ce().prototype.gather=function(n,e,t){return this.throwIfDisposed(),mk(this,n,e,t)};Ce().prototype.greaterEqual=function(n){return this.throwIfDisposed(),lh(this,n)};Ce().prototype.greater=function(n){return this.throwIfDisposed(),bo(this,n)};Ce().prototype.ifft=function(){return this.throwIfDisposed(),SC(this)};Ce().prototype.irfft=function(){return this.throwIfDisposed(),Jj(this)};Ce().prototype.isFinite=function(){return this.throwIfDisposed(),pG(this)};Ce().prototype.isInf=function(){return this.throwIfDisposed(),gG(this)};Ce().prototype.isNaN=function(){return this.throwIfDisposed(),yG(this)};Ce().prototype.leakyRelu=function(n){return this.throwIfDisposed(),xk(this,n)};Ce().prototype.lessEqual=function(n){return this.throwIfDisposed(),$f(this,n)};Ce().prototype.less=function(n){return this.throwIfDisposed(),Vy(this,n)};Ce().prototype.localResponseNormalization=function(n,e,t,r){return this.throwIfDisposed(),SG(this,n,e,t,r)};Ce().prototype.logSigmoid=function(){return this.throwIfDisposed(),RG(this)};Ce().prototype.logSoftmax=function(n){return this.throwIfDisposed(),TR(this,n)};Ce().prototype.logSumExp=function(n,e){return this.throwIfDisposed(),ER(this,n,e)};Ce().prototype.log=function(){return this.throwIfDisposed(),ya(this)};Ce().prototype.log1p=function(){return this.throwIfDisposed(),NR(this)};Ce().prototype.logicalAnd=function(n){return this.throwIfDisposed(),rl(this,n)};Ce().prototype.logicalNot=function(){return this.throwIfDisposed(),yk(this)};Ce().prototype.logicalOr=function(n){return this.throwIfDisposed(),RR(this,n)};Ce().prototype.logicalXor=function(n){return this.throwIfDisposed(),MG(this,n)};Ce().prototype.matMul=function(n,e,t){return this.throwIfDisposed(),qt(this,n,e,t)};Ce().prototype.maxPool=function(n,e,t,r){return this.throwIfDisposed(),vk(this,n,e,t,r)};Ce().prototype.max=function(n,e){return this.throwIfDisposed(),Si(this,n,e)};Ce().prototype.maximum=function(n){return this.throwIfDisposed(),vu(this,n)};Ce().prototype.mean=function(n,e){return this.throwIfDisposed(),Xn(this,n,e)};Ce().prototype.min=function(n,e){return this.throwIfDisposed(),Wy(this,n,e)};Ce().prototype.minimum=function(n){return this.throwIfDisposed(),zm(this,n)};Ce().prototype.mirrorPad=function(n,e){return this.throwIfDisposed(),HG(this,n,e)};Ce().prototype.mod=function(n){return this.throwIfDisposed(),KG(this,n)};Ce().prototype.mul=function(n){return this.throwIfDisposed(),ne(this,n)};Ce().prototype.neg=function(){return this.throwIfDisposed(),zn(this)};Ce().prototype.norm=function(n,e,t){return this.throwIfDisposed(),kv(this,n,e,t)};Ce().prototype.notEqual=function(n){return this.throwIfDisposed(),Gy(this,n)};Ce().prototype.oneHot=function(n,e=1,t=0){return this.throwIfDisposed(),AR(this,n,e,t)};Ce().prototype.onesLike=function(){return this.throwIfDisposed(),Ko(this)};Ce().prototype.pad=function(n,e){return this.throwIfDisposed(),bk(this,n,e)};Ce().prototype.pool=function(n,e,t,r,s,o){return this.throwIfDisposed(),sj(this,n,e,t,r,s,o)};Ce().prototype.pow=function(n){return this.throwIfDisposed(),Jc(this,n)};Ce().prototype.prelu=function(n){return this.throwIfDisposed(),Sk(this,n)};Ce().prototype.prod=function(n,e){return this.throwIfDisposed(),aj(this,n,e)};Ce().prototype.reciprocal=function(){return this.throwIfDisposed(),_j(this)};Ce().prototype.relu=function(){return this.throwIfDisposed(),uh(this)};Ce().prototype.relu6=function(){return this.throwIfDisposed(),DR(this)};Ce().prototype.reshapeAs=function(n){return this.throwIfDisposed(),ce(this,n.shape)};Ce().prototype.reshape=function(n){return this.throwIfDisposed(),ce(this,n)};Ce().prototype.resizeBilinear=function(n,e,t){return this.throwIfDisposed(),HR(this,n,e,t)};Ce().prototype.resizeNearestNeighbor=function(n,e,t){return this.throwIfDisposed(),qR(this,n,e,t)};Ce().prototype.reverse=function(n){return this.throwIfDisposed(),Zc(this,n)};Ce().prototype.rfft=function(){return this.throwIfDisposed(),tH(this)};Ce().prototype.round=function(){return this.throwIfDisposed(),OR(this)};Ce().prototype.rsqrt=function(){return this.throwIfDisposed(),FR(this)};Ce().prototype.selu=function(){return this.throwIfDisposed(),PR(this)};Ce().prototype.separableConv2d=function(n,e,t,r,s,o){return this.throwIfDisposed(),LR(this,n,e,t,r,s,o)};Ce().prototype.sigmoid=function(){return this.throwIfDisposed(),If(this)};Ce().prototype.sign=function(){return this.throwIfDisposed(),Uj(this)};Ce().prototype.sin=function(){return this.throwIfDisposed(),MR(this)};Ce().prototype.sinh=function(){return this.throwIfDisposed(),zR(this)};Ce().prototype.slice=function(n,e){return this.throwIfDisposed(),mn(this,n,e)};Ce().prototype.softmax=function(n){return this.throwIfDisposed(),Nk(this,n)};Ce().prototype.softplus=function(){return this.throwIfDisposed(),ex(this)};Ce().prototype.spaceToBatchND=function(n,e){return this.throwIfDisposed(),Ck(this,n,e)};Ce().prototype.split=function(n,e){return this.throwIfDisposed(),yo(this,n,e)};Ce().prototype.sqrt=function(){return this.throwIfDisposed(),jr(this)};Ce().prototype.square=function(){return this.throwIfDisposed(),bn(this)};Ce().prototype.squaredDifference=function(n){return this.throwIfDisposed(),rH(this,n)};Ce().prototype.squeeze=function(n){return this.throwIfDisposed(),nx(this,n)};Ce().prototype.stack=function(n,e){this.throwIfDisposed();const t=n instanceof tr?[this,n]:[this,...n];return sl(t,e)};Ce().prototype.step=function(n){return this.throwIfDisposed(),rx(this,n)};Ce().prototype.stridedSlice=function(n,e,t,r,s,o,i,a){return this.throwIfDisposed(),lH(this,n,e,t,r,s,o,i,a)};Ce().prototype.sub=function(n){return this.throwIfDisposed(),ut(this,n)};Ce().prototype.sum=function(n,e){return this.throwIfDisposed(),rt(this,n,e)};Ce().prototype.tan=function(){return this.throwIfDisposed(),cH(this)};Ce().prototype.tanh=function(){return this.throwIfDisposed(),wv(this)};Ce().prototype.tile=function(n){return this.throwIfDisposed(),bi(this,n)};Ce().prototype.toBool=function(){return this.throwIfDisposed(),Ge(this,"bool")};Ce().prototype.toFloat=function(){return this.throwIfDisposed(),Ge(this,"float32")};Ce().prototype.toInt=function(){return this.throwIfDisposed(),Ge(this,"int32")};Ce().prototype.topk=function(n,e){return this.throwIfDisposed(),pH(this,n,e)};Ce().prototype.transpose=function(n){return this.throwIfDisposed(),Lt(this,n)};Ce().prototype.unique=function(n){return this.throwIfDisposed(),xH(this,n)};Ce().prototype.unsortedSegmentSum=function(n,e){return this.throwIfDisposed(),GR(this,n,e)};Ce().prototype.unstack=function(n){return this.throwIfDisposed(),eh(this,n)};Ce().prototype.where=function(n,e){return this.throwIfDisposed(),us(n,this,e)};Ce().prototype.zerosLike=function(){return this.throwIfDisposed(),Mt(this)};class sa extends Error{constructor(e){super(e),Object.setPrototypeOf(this,sa.prototype)}}class jo extends Error{constructor(e){super(e),Object.setPrototypeOf(this,jo.prototype)}}class Z extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Z.prototype)}}class wt extends Error{constructor(e){super(e),Object.setPrototypeOf(this,wt.prototype)}}class cI extends Error{constructor(e){super(e),Object.setPrototypeOf(this,cI.prototype)}}class LA{constructor(e){this.maxEntries=e||100,this.cache=new Map}get(e){let t;return this.cache.has(e)&&(t=this.cache.get(e),this.cache.delete(e),this.cache.set(e,t)),t}put(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxEntries){const r=this.cache.keys().next().value;this.cache.delete(r)}this.cache.set(e,t)}getMaxEntries(){return this.maxEntries}setMaxEntries(e){if(e<0)throw new Error(`The maxEntries of LRU caches must be at least 0, but got ${e}.`);if(this.maxEntries>e)for(let t=0;t<this.maxEntries-e;t++){const r=this.cache.keys().next().value;this.cache.delete(r)}this.maxEntries=e}}function th(n,e){if(Array.isArray(n)){let t=[];for(let r=0;r<e;r++)t=t.concat(n);return t}else{const t=new Array(e);return t.fill(n),t}}function oa(n,e){if(!n)throw new cI(e)}function l2(n,e){let t=0;for(const r of n)r===e&&t++;return t}function ks(n){return n.length===1?n[0]:n}function rn(n){return Array.isArray(n)?n:[n]}function el(n){const t=n.replace(/(.)([A-Z][a-z0-9]+)/g,"$1_$2").replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase();return t[0]!=="_"?t:"private"+t}function Ac(n){return n.length<=1||n.indexOf("_")===-1?n:n.replace(/[_]+(\w|$)/g,(e,t)=>t.toUpperCase())}let Uo={};function hI(n){if(n==null)return null;const e={};return e.className=n.getClassName(),e.config=n.getConfig(),e}function $C(n){if(!(n==null||typeof n!="object"))if(Array.isArray(n))n.forEach(e=>$C(e));else{const e=Object.keys(n);for(const t of e){const r=n[t];r!=null&&typeof r=="object"&&(!Array.isArray(r)&&r.type==="ndarray"&&typeof r.value=="number"?n[t]=r.value:$C(r))}}}function ax(n,e={},t={},r="object",s=!1){if(typeof n=="string"){const o=n;let i;if(o in t)i=t[o];else if(o in Uo)i=Uo[o];else if(i=e[o],i==null)throw new Z(`Unknown ${r}: ${n}. This may be due to one of the following reasons:
1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);return i}else{const o=n;if(o.className==null||o.config==null)throw new Z(`${r}: Improper config format: ${JSON.stringify(o)}.
'className' and 'config' must set.`);const i=o.className;let a,l;if(i in t?[a,l]=t[i]:i in Uo?[a,l]=Uo.className:i in e&&([a,l]=e[i]),a==null)throw new Z(`Unknown ${r}: ${i}. This may be due to one of the following reasons:
1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);if(l!=null){const c={};for(const y of Object.keys(Uo))c[y]=Uo[y];for(const y of Object.keys(t))c[y]=t[y];const d=o.config;d.customObjects=c;const p=Object.assign({},Uo);for(const y of Object.keys(t))Uo[y]=t[y];$C(o.config);const m=l(a,o.config,t,s);return Uo=Object.assign({},p),m}else{const c=Object.assign({},Uo);for(const p of Object.keys(t))Uo[p]=t[p];const d=new a(o.config);return Uo=Object.assign({},c),d}}}function K8(n,e){return n<e?-1:n>e?1:0}function sy(n,e){return-1*K8(n,e)}function ou(n){if(n==null)return n;const e=[];for(const t of n)e.indexOf(t)===-1&&e.push(t);return e}function X8(n){if(n==null)throw new Z(`Invalid value in obj: ${JSON.stringify(n)}`);for(const e in n)if(n.hasOwnProperty(e))return!1;return!0}function hh(n,e,t){if(t!=null&&n.indexOf(t)<0)throw new Z(`${t} is not a valid ${e}. Valid values are ${n} or null/undefined.`)}function dI(n,e,t=0,r=1/0){return oa(t>=0),oa(r>=t),Array.isArray(n)&&n.length>=t&&n.length<=r&&n.every(s=>typeof s===e)}function xr(n,e){Array.isArray(n)?(U(n.length>0,()=>`${e} is unexpectedly an empty array.`),n.forEach((t,r)=>xr(t,`element ${r+1} of ${e}`))):U(Number.isInteger(n)&&n>0,()=>`Expected ${e} to be a positive integer, but got ${MA(n)}.`)}function MA(n){return n===null?"null":Array.isArray(n)?"["+n.map(e=>MA(e)).join(",")+"]":typeof n=="string"?`"${n}"`:`${n}`}function Y8(n,e,t){let r=t!=null?t():Cs(),s;return(...i)=>{const a=t!=null?t():Cs();return a-r<e||(r=a,s=n(...i)),s}}function zA(n){return n==="relu"?"relu":n==="linear"?"linear":n==="elu"?"elu":null}let Q8=0;function BA(){return Q8++}const oy={};function Rv(n=""){return n in oy||(oy[n]=0),oy[n]+=1,n+oy[n].toString()}const J8=["channelsFirst","channelsLast"],Z8=["nearest","bilinear"],eq=["valid","same","causal"],tq=["max","avg"],nq=["sum","mul","concat","ave"];const Vd=new Map;function Vn(n){hh(J8,"DataFormat",n)}function rq(n){hh(Z8,"InterpolationFormat",n)}function Co(n){hh(eq,"PaddingMode",n)}function UA(n){hh(tq,"PoolMode",n)}const Tm=[],u2="/";function Mc(n,e){Tm.push(n);try{const t=e();return Tm.pop(),t}catch(t){throw Tm.pop(),t}}function sq(){return Tm.length===0?"":Tm.join(u2)+u2}function WA(n){if(!GA(n))throw new Error("Not a valid tensor name: '"+n+"'");return sq()+n}function VA(n){if(!GA(n))throw new Error("Not a valid tensor name: '"+n+"'");Vd.has(n)||Vd.set(n,0);const e=Vd.get(n);if(Vd.set(n,Vd.get(n)+1),e>0){const t=`${n}_${e}`;return Vd.set(t,1),t}else return n}const oq=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function GA(n){return!!n.match(oq)}function iq(n){return n===parseInt(n.toString(),10)}function iu(n,e,t){e==null&&(e=0),t==null&&(t=n.length);let r=1;for(let s=e;s<t;++s)r*=n[s];return r}function hf(n){if(n.length===0)return Number.NaN;let e=Number.POSITIVE_INFINITY;for(let t=0;t<n.length;t++){const r=n[t];r<e&&(e=r)}return e}function lu(n){if(n.length===0)return Number.NaN;let e=Number.NEGATIVE_INFINITY;for(let t=0;t<n.length;t++){const r=n[t];r>e&&(e=r)}return e}function Ii(n,e){if(e<n)throw new Z(`end (${e}) < begin (${n}) is forbidden.`);const t=[];for(let r=n;r<e;++r)t.push(r);return t}let Eb;function nr(){return Eb==null&&(Eb=AU().epsilon()),Eb}function $i(){return"channelsLast"}function fa(n,e){return Ge(n,e)}function lx(n,e=-1){const t=n.shape.slice();return e<0&&(e=t.length+e+1),t.splice(e,0,1),ce(n,t)}function aq(n,e){return me(()=>{if(n.shape.length!==2)throw new Z(`repeat() expects a rank-2 tensor, but received a rank-${n.shape.length} tensor.`);const t=lx(n,1);return NC(t,[1,e,1])})}function lq(n){const e=[iu(n.shape)];return ce(n,e)}function uq(n){if(n.rank<=1)throw new Z(`batchFlatten requires a minimum rank of 2. Got rank: ${n.rank}.`);const e=[n.shape[0],iu(n.shape,1)];return ce(n,e)}function zc(n,e,t){return me(()=>{switch(n.rank){case 1:return Ik(n,e,t);case 2:return BR(n,[e,0],[t,n.shape[1]]);case 3:return $k(n,[e,0,0],[t,n.shape[1],n.shape[2]]);case 4:return Hy(n,[e,0,0,0],[t,n.shape[1],n.shape[2],n.shape[3]]);case 5:return mn(n,[e,0,0,0,0],[t,n.shape[1],n.shape[2],n.shape[3],n.shape[4]]);case 6:return mn(n,[e,0,0,0,0,0],[t,n.shape[1],n.shape[2],n.shape[3],n.shape[4],n.shape[5]]);default:throw new Z(`sliceAlongFirstAxis() received an unsupported tensor rank: ${n.rank}`)}})}function Rb(n,e,t){return me(()=>{switch(n.rank){case 1:return Ik(n,e,t);case 2:return BR(n,[0,e],[n.shape[0],t]);case 3:return $k(n,[0,0,e],[n.shape[0],n.shape[1],t]);case 4:return Hy(n,[0,0,0,e],[n.shape[0],n.shape[1],n.shape[2],t]);default:throw new Z(`sliceAlongLastAxis() received an unsupported tensor rank: ${n.rank}`)}})}function iy(n,e,t,r){return me(()=>{switch(n.rank){case 1:return Ik(n,e,t);case 2:switch(r){case 1:return zc(n,e,t);case 2:return Rb(n,e,t);default:throw new Z(`The axis is not within the rank of the tensor ${r}`)}case 3:switch(r){case 1:return zc(n,e,t);case 2:return $k(n,[0,e,0],[n.shape[0],t,n.shape[2]]);case 3:return Rb(n,e,t);default:throw new Z(`The axis is not within the rank of the tensor ${r}`)}case 4:switch(r){case 1:return zc(n,e,t);case 2:return Hy(n,[0,e,0,0],[n.shape[0],t,n.shape[2],n.shape[3]]);case 3:return Hy(n,[0,0,e,0],[n.shape[0],n.shape[1],t,n.shape[3]]);case 4:return Rb(n,e,t);default:throw new Z(`The axis is not within the rank of the tensor ${r}`)}default:throw new Z(`sliceAlongLastAxis() received an unsupported tensor rank: ${n.rank}`)}})}function fI(n,e=-1){let t;return e<0&&(t=n[0].rank,t!==0?e=t:e=0),e===n[0].rank&&(e=-1),Is(n,e)}function c2(n,e){switch(n.rank){case 1:return hV([n,e]);case 2:return fV([n,e],0);case 3:return mV([n,e],0);case 4:return xV([n,e],0);default:throw new Z(`concatAlongFirstAxis() received an unsupported tensor rank: ${n.rank}`)}}function NC(n,e){if(Array.isArray(e)||(e=[e]),n.rank!==e.length)throw new Z(`The length of input n (${e.length}) does not match the number of dimensions in input x (${n.rank})`);return bi(n,e)}function Av(n,e=0,t=1,r,s){return Tj(n,e,t,r,s)}function pa(n,e,t,r){if(n.rank<2||e.rank<2)throw new wt(`dot requires both inputs to be rank >= 2 but got x shape = ${n.shape} and y shape = ${e.shape}`);if(e.rank>=3){const s=n.shape.slice(-1)[0],o=e.shape.slice(-2)[0];if(s!==o)throw new wt(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${n.shape} and y shape = ${e.shape}`)}if(n.rank===2&&e.rank===2)return KN({a:n,b:e,transposeA:!1,transposeB:!1,bias:r?TC(n.rank,r,$i()):null,activation:t});{const s=n.shape.slice(),o=s.pop();n=ce(n,[-1,o]);const i=e.shape.slice(),a=i.pop(),l=i.pop(),c=[...i,a],d=Array.from({length:e.rank},(v,b)=>b===0?e.rank-2:b<=e.rank-2?b-1:b);e=ce(Lt(e,d),[l,-1]);const p=[...s,...c];return ce(KN({a:n,b:e,transposeA:!1,transposeB:!1,bias:r?TC(n.rank,r,$i()):null,activation:t}),p)}}function jA(n,e,t){return me(()=>(Array.isArray(e)?e=qs(e,"int32"):e=Ge(e,"int32"),mk(n,e,t)))}function ux(n){return ne(n,n)}function TC(n,e,t){const r=e.shape;if(e.rank!==1&&e.rank!==n)throw new Z(`Unexpected bias dimensions: ${e.rank}; expected it to be 1 or ${n}`);if(n===5){if(t==="channelsFirst")return r.length===1?ce(e,[1,r[0],1,1,1]):ce(e,[1,r[3],r[0],r[1],r[2]]);if(t==="channelsLast")return r.length===1?ce(e,[1,1,1,1,r[0]]):ce(e,[1].concat(r))}else if(n===4){if(t==="channelsFirst")return r.length===1?ce(e,[1,r[0],1,1]):ce(e,[1,r[2],r[0],r[1]]);if(t==="channelsLast")return r.length===1?ce(e,[1,1,1,r[0]]):ce(e,[1].concat(r))}else if(n===3){if(t==="channelsFirst")return r.length===1?ce(e,[1,r[0],1]):ce(e,[1,r[1],r[0]]);if(t==="channelsLast")return r.length===1?ce(e,[1,1,r[0]]):ce(e,[1].concat(r))}else if(n<3)return e;throw new Z(`Unsupported input rank by biasAdd: ${e.rank}`)}function Ei(n,e,t){return me(()=>(t==null&&(t=$i()),Vn(t),Pe(n,TC(n.rank,e,t))))}function cq(n,e=1){if(e!==1)throw new wt(`Support for alpha values other than 1 (${e}) is not implemented yet.`);return Sv(n)}function hq(n){return me(()=>st(n,Pe(os(n),1)))}function HA(n,e,t,r){return me(()=>kH(n,e,t,r))}function dq(n){return me(()=>{const e=Pe(.5,ne(.2,n));return wo(e,0,1)})}function cx(n,e,t=!1){return t?n():e()}const fq=["fanIn","fanOut","fanAvg"],pq=["normal","uniform","truncatedNormal"];function mq(n){hh(fq,"FanMode",n)}function gq(n){hh(pq,"Distribution",n)}class Yo extends Tf{fromConfigUsesCustomObjects(){return!1}getConfig(){return{}}}class qA extends Yo{apply(e,t){return gr(e,t)}}qA.className="Zeros";_e(qA);class pI extends Yo{apply(e,t){return wu(e,t)}}pI.className="Ones";_e(pI);class KA extends Yo{constructor(e){if(super(),typeof e!="object")throw new Z(`Expected argument of type ConstantConfig but got ${e}`);if(e.value===void 0)throw new Z(`config must have value set but got ${e}`);this.value=e.value}apply(e,t){return me(()=>ne(Kt(this.value),wu(e,t)))}getConfig(){return{value:this.value}}}KA.className="Constant";_e(KA);class XA extends Yo{constructor(e){super(),this.DEFAULT_MINVAL=-.05,this.DEFAULT_MAXVAL=.05,this.minval=e.minval||this.DEFAULT_MINVAL,this.maxval=e.maxval||this.DEFAULT_MAXVAL,this.seed=e.seed}apply(e,t){return tx(e,this.minval,this.maxval,t,this.seed)}getConfig(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}}XA.className="RandomUniform";_e(XA);class YA extends Yo{constructor(e){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=e.mean||this.DEFAULT_MEAN,this.stddev=e.stddev||this.DEFAULT_STDDEV,this.seed=e.seed}apply(e,t){if(t=t||"float32",t!=="float32"&&t!=="int32")throw new wt(`randomNormal does not support dType ${t}.`);return Av(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}YA.className="RandomNormal";_e(YA);class QA extends Yo{constructor(e){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=e.mean||this.DEFAULT_MEAN,this.stddev=e.stddev||this.DEFAULT_STDDEV,this.seed=e.seed}apply(e,t){if(t=t||"float32",t!=="float32"&&t!=="int32")throw new wt(`truncatedNormal does not support dType ${t}.`);return VR(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}QA.className="TruncatedNormal";_e(QA);class JA extends Yo{constructor(e){super(),this.gain=e.gain!=null?e.gain:1}apply(e,t){return me(()=>{if(e.length!==2||e[0]!==e[1])throw new Z("Identity matrix initializer can only be used for 2D square matrices.");return ne(this.gain,$R(e[0]))})}getConfig(){return{gain:this.gain}}}JA.className="Identity";_e(JA);function xq(n,e="channelsLast"){let t,r;if(Vn(e),n.length===2)t=n[0],r=n[1];else if([3,4,5].indexOf(n.length)!==-1){if(e==="channelsFirst"){const s=iu(n,2);t=n[1]*s,r=n[0]*s}else if(e==="channelsLast"){const s=iu(n,0,n.length-2);t=n[n.length-2]*s,r=n[n.length-1]*s}}else{const s=iu(n);t=Math.sqrt(s),r=Math.sqrt(s)}return[t,r]}class Qs extends Yo{constructor(e){if(super(),e.scale<0)throw new Z(`scale must be a positive float. Got: ${e.scale}`);this.scale=e.scale==null?1:e.scale,this.mode=e.mode==null?"fanIn":e.mode,mq(this.mode),this.distribution=e.distribution==null?"normal":e.distribution,gq(this.distribution),this.seed=e.seed}apply(e,t){const r=xq(e),s=r[0],o=r[1];let i=this.scale;if(this.mode==="fanIn"?i/=Math.max(1,s):this.mode==="fanOut"?i/=Math.max(1,o):i/=Math.max(1,(s+o)/2),this.distribution==="normal"){const a=Math.sqrt(i);if(t=t||"float32",t!=="float32"&&t!=="int32")throw new wt(`${this.getClassName()} does not support dType ${t}.`);return VR(e,0,a,t,this.seed)}else{const a=Math.sqrt(3*i);return tx(e,-a,a,t,this.seed)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}}Qs.className="VarianceScaling";_e(Qs);class mI extends Qs{constructor(e){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Qs.className}}mI.className="GlorotUniform";_e(mI);class gI extends Qs{constructor(e){super({scale:1,mode:"fanAvg",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Qs.className}}gI.className="GlorotNormal";_e(gI);class xI extends Qs{constructor(e){super({scale:2,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Qs.className}}xI.className="HeNormal";_e(xI);class yI extends Qs{constructor(e){super({scale:2,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Qs.className}}yI.className="HeUniform";_e(yI);class vI extends Qs{constructor(e){super({scale:1,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Qs.className}}vI.className="LeCunNormal";_e(vI);class wI extends Qs{constructor(e){super({scale:1,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Qs.className}}wI.className="LeCunUniform";_e(wI);class ZA extends Yo{constructor(e){super(),this.DEFAULT_GAIN=1,this.ELEMENTS_WARN_SLOW=2e3,this.gain=e.gain==null?this.DEFAULT_GAIN:e.gain,this.seed=e.seed}apply(e,t){return me(()=>{if(e.length<2)throw new wt("Shape must be at least 2D.");if(t!=="int32"&&t!=="float32"&&t!==void 0)throw new TypeError(`Unsupported data type ${t}.`);t=t;const r=Se(e.slice(0,-1)),s=e[e.length-1],o=r*s;o>this.ELEMENTS_WARN_SLOW&&console.warn(`Orthogonal initializer is being called on a matrix with more than ${this.ELEMENTS_WARN_SLOW} (${o}) elements: Slowness may result.`);const i=[Math.max(s,r),Math.min(s,r)],a=Av(i,0,1,t,this.seed),l=w5.qr(a,!1);let c=l[0];const p=l[1].flatten().stridedSlice([0],[Math.min(s,r)*Math.min(s,r)],[Math.min(s,r)+1]);return c=ne(c,p.sign()),r<s&&(c=c.transpose()),ne(Kt(this.gain),c.reshape(e))})}getConfig(){return{gain:this.gain,seed:this.seed}}}ZA.className="Orthogonal";_e(ZA);const h2={constant:"Constant",glorotNormal:"GlorotNormal",glorotUniform:"GlorotUniform",heNormal:"HeNormal",heUniform:"HeUniform",identity:"Identity",leCunNormal:"LeCunNormal",leCunUniform:"LeCunUniform",ones:"Ones",orthogonal:"Orthogonal",randomNormal:"RandomNormal",randomUniform:"RandomUniform",truncatedNormal:"TruncatedNormal",varianceScaling:"VarianceScaling",zeros:"Zeros"};function d2(n,e={}){return ax(n,Go.getMap().classNameMap,e,"initializer")}function Tn(n){return hI(n)}function kn(n){if(typeof n=="string"){const e=n in h2?h2[n]:n;if(e==="GlorotNormal")return new gI;if(e==="GlorotUniform")return new mI;if(e==="HeNormal")return new xI;if(e==="HeUniform")return new yI;if(e==="LeCunNormal")return new vI;if(e==="LeCunUniform")return new wI;{const t={};return t.className=e,t.config={},d2(t)}}else return n instanceof Yo?n:d2(n)}function EC(n){return Array.isArray(n)&&Array.isArray(n[0])}function qy(n){return n.length===0?[]:Array.isArray(n[0])?n:[n]}function ft(n){let e;if(Array.isArray(n)){if(n.length!==1)throw new Z(`Expected Tensor length to be 1; got ${n.length}`);e=n[0]}else e=n;return e}function Gt(n){if(Array.isArray(n)&&Array.isArray(n[0])){if(n.length===1)return n=n,n[0];throw new Z(`Expected exactly 1 Shape; got ${n.length}`)}else return n}function Ky(n){let e=0;for(const t of n)t.shape.length===0?e+=1:e+=t.shape.reduce((r,s)=>r*s);return e}const f2="Variable";class yq{constructor(e,t="float32",r=f2,s=!0,o=null){this.dtype=t??"float32",this.shape=e.shape,this.id=BA(),r=r??f2,this.originalName=WA(r),this.name=VA(this.originalName),this.trainable_=s,this.constraint=o,this.val=wH(e,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(e){return this.assertNotDisposed(),vq(this.val,e),this.val.id!==e.id&&(this.val.assign(e),this.constraint!=null&&this.val.assign(this.constraint.apply(this.val))),this}dispose(){this.assertNotDisposed(),this.val.dispose()}assertNotDisposed(){if(this.val.isDisposed)throw new Error(`LayersVariable ${this.name} is already disposed.`)}get trainable(){return this.trainable_}set trainable(e){this.trainable_=e,this.val.trainable=e}}function vq(n,e){if(n.shape.toString()!==e.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(n.shape)+" vs. "+JSON.stringify(e.shape))}function RC(n){return n.map(e=>e.read())}function bI(n){n.forEach(e=>{e[0].write(e[1])})}class rr{constructor(e){this.dtype=e.dtype,this.shape=e.shape,e.shape!=null?this.ndim=e.shape.length:this.ndim=e.ndim,this.maxNDim=e.maxNDim,this.minNDim=e.minNDim,this.axes=e.axes||{}}}class va{constructor(e,t,r,s,o,i,a){this.dtype=e,this.shape=t,this.sourceLayer=r,this.inputs=s,this.callArgs=o,this.outputTensorIndex=a,this.id=BA(),i!=null&&(this.originalName=WA(i),this.name=VA(this.originalName)),this.rank=t.length}}let wq=0;class _v{constructor(e,t){this.callArgs=t,this.id=wq++,this.outboundLayer=e.outboundLayer,this.inboundLayers=e.inboundLayers,this.nodeIndices=e.nodeIndices,this.tensorIndices=e.tensorIndices,this.inputTensors=e.inputTensors,this.outputTensors=e.outputTensors,this.inputMasks=e.inputMasks,this.outputMasks=e.outputMasks,this.inputShapes=e.inputShapes,this.outputShapes=e.outputShapes;for(const r of e.inboundLayers)r?.outboundNodes.push(this);e.outboundLayer.inboundNodes.push(this)}getConfig(){const e=[];for(const t of this.inboundLayers)t!=null?e.push(t.name):e.push(null);return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:e,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}}}let bq=0;class Et extends Tf{constructor(e={}){super(),this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=bq++,this.activityRegularizer=null,this.inputSpec=null,this.supportsMasking=!1,this._trainableWeights=[],this._nonTrainableWeights=[],this._losses=[],this._updates=[],this._built=!1,this.inboundNodes=[],this.outboundNodes=[];let t=e.name;if(!t){const r=this.getClassName();t=el(r)+"_"+Rv(r)}if(this.name=t,this.trainable_=e.trainable==null?!0:e.trainable,e.inputShape!=null||e.batchInputShape!=null){let r;if(e.batchInputShape!=null)r=e.batchInputShape;else if(e.inputShape!=null){let o=null;e.batchSize!=null&&(o=e.batchSize),r=[o].concat(e.inputShape)}this.batchInputShape=r;let s=e.dtype;s==null&&(s=e.inputDType),s==null&&(s="float32"),this.dtype=s}e.weights!=null?this.initialWeights=e.weights:this.initialWeights=null,this._refCount=null,this.fastWeightInitDuringBuild=!1}static nodeKey(e,t){return e.name+"_ib-"+t.toString()}getNodeAtIndex(e,t){if(this.inboundNodes.length===0)throw new jo(`The layer has never been called and thus has no defined ${t}.`);if(this.inboundNodes.length<=e)throw new Z(`Asked to get ${t} at node ${e}, but the layer has only ${this.inboundNodes.length} inbound nodes.`);return this.inboundNodes[e]}getInputAt(e){return ks(this.getNodeAtIndex(e,"input").inputTensors)}getOutputAt(e){return ks(this.getNodeAtIndex(e,"output").outputTensors)}get input(){if(this.inboundNodes.length>1)throw new sa(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`);if(this.inboundNodes.length===0)throw new sa(`Layer ${this.name} is not connected, no input to return.`);return ks(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(this.inboundNodes.length===0)throw new sa(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new sa(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);return ks(this.getNodeAtIndex(0,"output").outputTensors)}get losses(){return this._losses}calculateLosses(){return this.losses.map(e=>e())}get updates(){return this._updates}get built(){return this._built}set built(e){this._built=e}get trainable(){return this.trainable_}set trainable(e){this._trainableWeights.forEach(t=>t.trainable=e),this.trainable_=e}get trainableWeights(){return this.trainable_?this._trainableWeights.filter(e=>e.trainable):[]}set trainableWeights(e){this._trainableWeights=e}get nonTrainableWeights(){return this.trainable?this._trainableWeights.filter(e=>!e.trainable).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)}set nonTrainableWeights(e){this._nonTrainableWeights=e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}get stateful(){return this._stateful}resetStates(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")}assertInputCompatibility(e){const t=rn(e);if(this.inputSpec==null||this.inputSpec.length===0)return;const r=rn(this.inputSpec);if(t.length!==r.length)throw new Z(`Layer ${this.name} expects ${r.length} inputs, but it received ${t.length} input tensors. Input received: ${e}`);for(let s=0;s<t.length;s++){const o=t[s],i=r[s];if(i==null)continue;const a=o.rank;if(i.ndim!=null&&a!==i.ndim)throw new Z(`Input ${s} is incompatible with layer ${this.name}: expected ndim=${i.ndim}, found ndim=${a}`);if(i.maxNDim!=null&&a>i.maxNDim)throw new Z(`Input ${s} is incompatible with layer ${this.name}: expected max_ndim=${i.maxNDim}, found ndim=${a}`);if(i.minNDim!=null&&a<i.minNDim)throw new Z(`Input ${s} is incompatible with layer ${this.name}: expected min_ndim=${i.minNDim}, found ndim=${a}.`);if(i.dtype!=null&&o.dtype!==i.dtype)throw new Z(`Input ${s} is incompatible with layer ${this.name} : expected dtype=${i.dtype}, found dtype=${o.dtype}.`);if(i.axes){const l=o.shape;for(const c in i.axes){const d=Number(c),p=i.axes[c],m=d>=0?l[d]:l[l.length+d];if(p!=null&&[p,null].indexOf(m)===-1)throw new Z(`Input ${s} is incompatible with layer ${this.name}: expected axis ${d} of input shape to have value ${p} but got shape ${l}.`)}}if(i.shape!=null)for(let l=0;l<i.shape.length;++l){const c=i.shape[l],d=o.shape[l];if(c!=null&&d!=null&&c!==d)throw new Z(`Input ${s} is incompatible with layer ${this.name}: expected shape=${i.shape}, found shape=${o.shape}.`)}}}call(e,t){return e}invokeCallHook(e,t){this._callHook!=null&&this._callHook(e,t)}setCallHook(e){this._callHook=e}clearCallHook(){this._callHook=null}apply(e,t){t=t||{},this.assertNotDisposed();const r=rn(e),s=kq(e),o=Iq(e);if(s===o)throw new Z("Arguments to apply() must be all SymbolicTensors or all Tensors");return Mc(this.name,()=>{if(!this.built){this.assertInputCompatibility(e);const i=[];for(const a of rn(e))i.push(a.shape);this.build(ks(i)),this.built=!0,this.initialWeights&&this.setWeights(this.initialWeights),this._refCount===null&&o&&(this._refCount=1)}if(this.assertInputCompatibility(e),o){let i=this.call(e,t);this.supportsMasking&&this.setMaskMetadata(e,i);const a=rn(i),l=[];for(let c of a)r.indexOf(c)!==-1&&(c=c.clone()),l.push(c);if(i=ks(l),this.activityRegularizer!=null)throw new wt("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return i}else{const i=Cq(e),a=this.computeOutputShape(i);let l;const c=Sq(e);if(this.warnOnIncompatibleInputShape(Array.isArray(e)?i[0]:i),a!=null&&a.length>0&&Array.isArray(a[0])?l=a.map((d,p)=>new va(c,d,this,rn(e),t,this.name,p)):l=new va(c,a,this,rn(e),t,this.name),this.addInboundNode(e,l,null,null,i,a,t),this._refCount++,this.activityRegularizer!=null)throw new wt("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return l}})}warnOnIncompatibleInputShape(e){if(this.batchInputShape!=null)if(e.length!==this.batchInputShape.length)console.warn(`The rank of the input tensor provided (shape: ${JSON.stringify(e)}) does not match that of the batchInputShape (${JSON.stringify(this.batchInputShape)}) of the layer ${this.name}`);else{let t=!1;this.batchInputShape.forEach((r,s)=>{r!=null&&e[s]!=null&&e[s]!==r&&(t=!0)}),t&&console.warn(`The shape of the input tensor (${JSON.stringify(e)}) does not match the expectation of layer ${this.name}: ${JSON.stringify(this.batchInputShape)}`)}}get outputShape(){if(this.inboundNodes==null||this.inboundNodes.length===0)throw new sa(`The layer ${this.name} has never been called and thus has no defined output shape.`);const e=[];for(const t of this.inboundNodes){const r=JSON.stringify(t.outputShapes);e.indexOf(r)===-1&&e.push(r)}if(e.length===1){const t=this.inboundNodes[0].outputShapes;return Array.isArray(t)&&Array.isArray(t[0])&&t.length===1?t[0]:t}else throw new sa(`The layer ${this.name} has multiple inbound nodes with different output shapes. Hence the notion of "output shape" is ill-defined for the layer.`)}countParams(){if(!this.built)throw new jo(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return Ky(this.weights)}build(e){this.built=!0}getWeights(e=!1){return RC(e?this.trainableWeights:this.weights)}setWeights(e){me(()=>{const t=this.weights;if(t.length!==e.length)throw new Z(`You called setWeights(weights) on layer "${this.name}" with a weight list of length ${e.length}, but the layer was expecting ${t.length} weights. Provided weights: ${e}...`);if(t.length===0)return;const r=[],s=RC(t);for(let o=0;o<s.length;++o){const i=s[o],a=t[o],l=e[o];if(!Xt(i.shape,l.shape))throw new Z(`Layer weight shape ${i.shape} not compatible with provided weight shape ${l.shape}`);r.push([a,l])}bI(r)})}addWeight(e,t,r,s,o,i,a,l){if(this._addedWeightNames.indexOf(e)!==-1)throw new Z(`Duplicate weight name ${e} for layer ${this.name}`);this._addedWeightNames.push(e),r==null&&(r="float32"),this.fastWeightInitDuringBuild&&(s=l!=null?l():kn("zeros"));const c=s.apply(t,r),d=new yq(c,r,e,i,a);return c.dispose(),o!=null&&this.addLoss(()=>o.apply(d.read())),i==null&&(i=!0),i?this._trainableWeights.push(d):this._nonTrainableWeights.push(d),d}setFastWeightInitDuringBuild(e){this.fastWeightInitDuringBuild=e}addLoss(e){e==null||Array.isArray(e)&&e.length===0||(e=rn(e),this._losses!==void 0&&this._losses!==null&&this.losses.push(...e))}computeOutputShape(e){return e}computeMask(e,t){if(!this.supportsMasking){if(t!=null)if(Array.isArray(t))t.forEach(r=>{if(r!=null)throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`)});else throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`);return null}return t}setMaskMetadata(e,t,r){if(!this.supportsMasking)return;const s=this.computeMask(e,r),o=rn(t),i=rn(s);if(o.length!==i.length)throw new Error(`${this.name} outputs ${o.length} tensors but ${o.length} masks for those tensors`);for(let a=0;a<o.length;a++)o[a].kerasMask=i[a]}addInboundNode(e,t,r,s,o,i,a=null){const l=rn(e);t=rn(t),r=rn(r),s=rn(s),o=qy(o),i=qy(i);const c=[],d=[],p=[];for(const m of l)c.push(m.sourceLayer),d.push(m.nodeIndex),p.push(m.tensorIndex);new _v({outboundLayer:this,inboundLayers:c,nodeIndices:d,tensorIndices:p,inputTensors:l,outputTensors:t,inputMasks:r,outputMasks:s,inputShapes:o,outputShapes:i},a);for(let m=0;m<t.length;m++)t[m].sourceLayer=this,t[m].nodeIndex=this.inboundNodes.length-1,t[m].tensorIndex=m}getConfig(){const e={name:this.name,trainable:this.trainable};return this.batchInputShape!=null&&(e.batchInputShape=this.batchInputShape),this.dtype!=null&&(e.dtype=this.dtype),e}disposeWeights(){return this.weights.forEach(e=>e.dispose()),this.weights.length}assertNotDisposed(){if(this._refCount===0)throw new Error(`Layer '${this.name}' is already disposed.`)}dispose(){if(!this.built)throw new Error(`Cannot dispose Layer ${this.name} because it has not been built yet.`);if(this._refCount===null)throw new Error(`Cannot dispose Layer ${this.name} because it has not been used yet.`);this.assertNotDisposed();let e=0;return--this._refCount===0&&(e=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:e}}}function Cq(n){n=rn(n);const e=[];for(const t of n)e.push(t.shape);return ks(e)}function Sq(n){return"float32"}function e_(n,e,t){if((e==null||t!=null&&t>0)&&(e=n.sourceLayer,t=n.nodeIndex),e.inboundNodes.length===0)return[n];{const r=e.inboundNodes[t];if(r.inboundLayers.length===0)return r.inputTensors;{const s=[];for(let o=0;o<r.inboundLayers.length;o++){const i=r.inputTensors[o],a=r.inboundLayers[o],l=r.nodeIndices[o],c=e_(i,a,l);for(const d of c)s.indexOf(d)===-1&&s.push(d)}return s}}}function kq(n){let e=!0;for(const t of rn(n))if(!(t instanceof va)){e=!1;break}return e}function Iq(n){let e=!0;for(const t of rn(n))if(t instanceof va){e=!1;break}return e}class hx extends Et{constructor(e){if(super({dtype:e.dtype,name:e.name!=null?e.name:Rv("input").toString()}),e.batchSize==null&&(e.batchSize=null),e.sparse==null&&(e.sparse=!1),this.trainable=!1,this.built=!0,this.sparse=e.sparse,e.inputShape!=null&&e.batchInputShape!=null)throw new Z("Only provide the inputShape OR batchInputShape argument to inputLayer, not both at the same time.");let t=e.batchInputShape;if(t==null){if(e.inputShape==null)throw new Z("An InputLayer should be passed either a `batchInputShape` or an `inputShape`.");t=[e.batchSize].concat(e.inputShape)}else if(e.batchSize!=null)throw new Z("Cannot specify batchSize if batchInputShape is specified when creating an InputLayer.");const r=e.dtype||"float32";this.batchInputShape=t,this.dtype=r,this.inputSpec=[{shape:t}];const s=new va(this.dtype,this.batchInputShape,this,[],{},this.name);s.nodeIndex=0,s.tensorIndex=0,new _v({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:[s],outputTensors:[s],inputMasks:[null],outputMasks:[null],inputShapes:[t],outputShapes:[t]})}apply(e,t){throw new Z(`Cannot pass any input to an InputLayer's apply() method. InputLayer name: ${this.name}`)}dispose(){return{refCountAfterDispose:this._refCount,numDisposedVariables:0}}getConfig(){return{batchInputShape:this.batchInputShape,dtype:this.dtype,sparse:this.sparse,name:this.name}}}hx.className="InputLayer";_e(hx);function $q(n){if(n.batchShape==null&&n.shape==null)throw new Error("Please provide to Input either a `shape` or a `batchShape` argument. Note that `shape` does not include the batch dimension.");if(n.batchShape!=null&&n.shape!=null)throw new Z("Please provide either a `shape` or `batchShape` argument to Input, but not both.");let e=n.batchShape;n.shape!=null&&e==null&&(e=[null].concat(n.shape));let t=n.dtype;return t==null&&(t="float32"),new hx({batchInputShape:e,name:n.name,dtype:t,sparse:n.sparse}).inboundNodes[0].outputTensors[0]}function Nq(n,e){if(n.dtype==null||n.dtype===e.dtype)return e;try{return Ge(e,n.dtype)}catch{throw new Z(`The dtype of the feed (${e.dtype}) can not be cast to the dtype of the key '${n.name}' (${n.dtype}).`)}}class eu{constructor(e){if(this.id2Value={},this.id2Mask={},this.name2Id={},e instanceof eu)for(const t in e.id2Value)this.id2Value[t]=e.id2Value[t],t in e.id2Mask&&(this.id2Mask[t]=e.id2Mask[t]);else{if(e==null)return;for(const t of e)this.add(t.key,t.value)}}add(e,t,r){if(this.id2Value[e.id]==null)this.id2Value[e.id]=Nq(e,t),this.name2Id[e.name]=e.id,r!=null&&(this.id2Mask[e.id]=r);else throw new Z(`Duplicate key: name=${e.name}, id=${e.id}`);return this}addFeed(e){this.add(e.key,e.value)}hasKey(e){return this.id2Value[e.id]!=null}names(){return Object.keys(this.name2Id)}getValue(e){if(e instanceof va){if(this.id2Value[e.id]==null)throw new Z(`Nonexistent key: ${e.name}`);return this.id2Value[e.id]}else{const t=this.name2Id[e];if(t==null)throw new Z(`Feed dict has no SymbolicTensor name: ${e}`);return this.id2Value[t]}}getMask(e){if(e instanceof va){if(this.id2Value[e.id]==null)throw new Z(`Nonexistent key: ${e.name}`);return this.id2Mask[e.id]}else{const t=this.name2Id[e];if(t==null)throw new Z(`Feed dict has no SymbolicTensor name: ${e}`);return this.id2Mask[t]}}disposeMasks(){this.id2Mask!=null&&kt(this.id2Mask)}}const Xy=new LA,Yy=new LA;function Tq(n){Xy?.setMaxEntries(n),Yy?.setMaxEntries(n)}function bm(n,e,t,r){const s=t==null?!1:t.training,o=Array.isArray(n),i=o?n:[n],a=i.map(v=>v.name),l=[],c=e.names();for(const v of a)c.indexOf(v)!==-1?l.push(e.getValue(v)):l.push(null);const d=a.join(",")+"|"+e.names().sort().join(",");let p=Xy.get(d),m;if(p==null){const v=Eq(i,e);p=v.sorted,m=v.recipientCounts,Xy.put(d,p),Yy.put(d,m)}m={},s||Object.assign(m,Yy.get(d));const y=new eu(e);for(let v=0;v<p.length;++v){const b=p[v],w=b.sourceLayer;if(w instanceof hx)continue;const k=[],I=[],N=[];let T=!1;for(const z of b.inputs){const L=y.getValue(z),_=y.getMask(z);k.push(L),I.push(_),_!=null&&(T=!0),s||(m[z.name]--,m[z.name]===0&&!e.hasKey(z)&&a.indexOf(z.name)===-1&&!L.isDisposed&&z.sourceLayer.stateful!==!0&&N.push(L))}T&&(t=t||{},t.mask=I[0]);const A=rn(w.apply(k,t));let O=null;w.supportsMasking&&(O=w.computeMask(k,I));const P=Aq(b),B=Array.isArray(P)?P:[P];for(let z=0;z<B.length;++z){y.hasKey(B[z])||y.add(B[z],A[z],Array.isArray(O)?O[0]:O);const L=a.indexOf(B[z].name);L!==-1&&(l[L]=A[z])}s||kt(N)}return y.disposeMasks(),o?l:l[0]}function Eq(n,e){U(n!=null&&n.length>0,()=>"Expected at least one fetch, got none");let t=[],r={};if(n.length===1){const s=p2(n[0],e);t=s.sorted,r=s.recipientMap}else{const s=new Set;for(const o of n){const{sorted:i,recipientMap:a}=p2(o,e);for(const l of i)s.has(l.name)||(t.push(l),s.add(l.name));for(const l in a)r[l]==null&&(r[l]=new Set),a[l].forEach(c=>r[l].add(c))}}return{sorted:t,recipientCounts:Rq(r)}}function Rq(n){const e={};for(const t in n)e[t]=n[t].size;return e}function p2(n,e){const t=new Set,r=[],s={};for(const a of e.names())t.add(a);const o=[],i=[];for(o.push(n);o.length>0;){const a=o[o.length-1];if(t.has(a.name)){o.pop();continue}const l=i[i.length-1]===o.length-1;if(a.inputs.length===0||l)o.pop(),r.push(a),t.add(a.name),l&&i.pop();else{i.push(o.length-1);for(const c of a.inputs)s[c.name]==null&&(s[c.name]=new Set),s[c.name].add(a.name),!t.has(c.name)&&o.push(c)}}return{sorted:r,recipientMap:s}}function Aq(n){let e;if(n.sourceLayer.inboundNodes.length===1)e=n.sourceLayer.output;else{let t=null;for(let r=0;r<n.sourceLayer.inboundNodes.length;++r)for(const s of n.sourceLayer.inboundNodes[r].outputTensors)if(s.id===n.id){t=r;break}e=n.sourceLayer.getOutputAt(t)}return e}const _q=ye();_q.registerFlag("TOPOLOGICAL_SORT_CACHE_MAX_ENTRIES",()=>100,Tq);function CI(n,e){return me(()=>jr(rt(ne(n,n),e,!0)))}class dx extends Tf{getConfig(){return{}}}class t_ extends dx{constructor(e){super(),this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=e.maxValue!=null?e.maxValue:this.defaultMaxValue,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return me(()=>{const t=CI(e,this.axis),r=wo(t,0,this.maxValue);return ne(e,st(r,Pe(nr(),t)))})}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}}t_.className="MaxNorm";_e(t_);class n_ extends dx{constructor(e){super(),this.defaultAxis=0,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return me(()=>st(e,Pe(nr(),CI(e,this.axis))))}getConfig(){return{axis:this.axis}}}n_.className="UnitNorm";_e(n_);class r_ extends dx{apply(e){return uh(e)}}r_.className="NonNeg";_e(r_);class s_ extends dx{constructor(e){super(),this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=e.minValue!=null?e.minValue:this.defaultMinValue,this.maxValue=e.maxValue!=null?e.maxValue:this.defaultMaxValue,this.rate=e.rate!=null?e.rate:this.defaultRate,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return me(()=>{const t=CI(e,this.axis),r=Pe(ne(this.rate,wo(t,this.minValue,this.maxValue)),ne(1-this.rate,t));return ne(e,st(r,Pe(nr(),t)))})}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}s_.className="MinMaxNorm";_e(s_);const m2={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function or(n){return hI(n)}function g2(n,e={}){return ax(n,Go.getMap().classNameMap,e,"constraint")}function ir(n){if(n==null)return null;if(typeof n=="string"){const t={className:n in m2?m2[n]:n,config:{}};return g2(t)}else return n instanceof dx?n:g2(n)}async function $c(n){if(n==null)return;const e=[],t=[],r=[];for(const s in n){const o=n[s];if(typeof o!="number"){const i=o;e.push(i.data()),t.push(s),r.push(i)}}if(e.length>0){const s=await Promise.all(e);for(let o=0;o<s.length;++o)n[t[o]]=s[o][0];kt(r)}}function o_(n){if(n!=null)for(const e in n){const t=n[e];typeof t!="number"&&t.dispose()}}var x2;(function(n){n[n.SILENT=0]="SILENT",n[n.VERBOSE=1]="VERBOSE"})(x2||(x2={}));const Dq=125;class Um{constructor(){this.validationData=null}setParams(e){this.params=e}async onEpochBegin(e,t){}async onEpochEnd(e,t){}async onBatchBegin(e,t){}async onBatchEnd(e,t){}async onTrainBegin(e){}async onTrainEnd(e){}setModel(e){}}class Oq{constructor(e,t=10){e==null&&(e=[]),this.callbacks=e,this.queueLength=t}append(e){this.callbacks.push(e)}setParams(e){for(const t of this.callbacks)t.setParams(e)}setModel(e){for(const t of this.callbacks)t.setModel(e)}async onEpochBegin(e,t){t==null&&(t={});for(const r of this.callbacks)await r.onEpochBegin(e,t)}async onEpochEnd(e,t){t==null&&(t={});for(const r of this.callbacks)await r.onEpochEnd(e,t)}async onBatchBegin(e,t){t==null&&(t={});for(const r of this.callbacks)await r.onBatchBegin(e,t)}async onBatchEnd(e,t){t==null&&(t={});for(const r of this.callbacks)await r.onBatchEnd(e,t)}async onTrainBegin(e){e==null&&(e={});for(const t of this.callbacks)await t.onTrainBegin(e)}async onTrainEnd(e){e==null&&(e={});for(const t of this.callbacks)await t.onTrainEnd(e)}}class Fq extends Um{constructor(){super()}async onEpochBegin(e){this.seen=0,this.totals={}}async onBatchEnd(e,t){t==null&&(t={});const r=t.size==null?0:t.size;this.seen+=r;for(const s in t){const o=t[s];if(typeof o=="number")this.totals.hasOwnProperty(s)||(this.totals[s]=0),this.totals[s]=this.totals[s]+o*r;else{let i;s in this.totals?i=this.totals[s]:this.totals[s]=0;const a=me(()=>Pe(this.totals[s],ne(o,r)));this.totals[s]=a,i?.dispose()}}}async onEpochEnd(e,t){if(t!=null)for(const r of this.params.metrics)this.totals[r]!=null&&(typeof this.totals[r]=="number"?t[r]=this.totals[r]/this.seen:me(()=>{const s=ne(st(1,this.seen),this.totals[r]);t[r]=s,this.totals[r].dispose(),ha(t[r])}))}}class Pq extends Um{async onTrainBegin(e){this.epoch=[],this.history={}}async onEpochEnd(e,t){t==null&&(t={}),this.epoch.push(e);for(const r in t)this.history[r]==null&&(this.history[r]=[]),this.history[r].push(t[r])}async syncData(){const e=[],t=[],r=[];for(const o in this.history){const i=this.history[o];for(let a=0;a<i.length;++a)if(typeof i[a]!="number"){const l=i[a];e.push(l.data()),t.push(o),r.push(a)}}const s=await Promise.all(e);for(let o=0;o<s.length;++o)this.history[t[o]][r[o]].dispose(),this.history[t[o]][r[o]]=s[o][0]}}class Lq extends Um{constructor(e,t){if(super(),this.currentEpoch=0,this.nowFunc=e.nowFunc,this.nextFrameFunc=e.nextFrameFunc||cA,this.yieldEvery=t||"auto",this.yieldEvery==="auto"&&(this.yieldEvery=Dq),this.yieldEvery==="never"&&e.onYield!=null)throw new Error("yieldEvery is `never` but you provided an `onYield` callback. Either change `yieldEvery` or remove the callback");sC(this.yieldEvery)&&(this.maybeWait=Y8(this.maybeWait.bind(this),this.yieldEvery,this.nowFunc)),this.trainBegin=e.onTrainBegin,this.trainEnd=e.onTrainEnd,this.epochBegin=e.onEpochBegin,this.epochEnd=e.onEpochEnd,this.batchBegin=e.onBatchBegin,this.batchEnd=e.onBatchEnd,this.yield=e.onYield}async maybeWait(e,t,r){const s=[];this.yield!=null&&(await $c(r),s.push(this.yield(e,t,r))),s.push(this.nextFrameFunc()),await Promise.all(s)}async onEpochBegin(e,t){this.currentEpoch=e,this.epochBegin!=null&&(await $c(t),await this.epochBegin(e,t))}async onEpochEnd(e,t){const r=[];this.epochEnd!=null&&(await $c(t),r.push(this.epochEnd(e,t))),this.yieldEvery==="epoch"&&r.push(this.nextFrameFunc()),await Promise.all(r)}async onBatchBegin(e,t){this.batchBegin!=null&&(await $c(t),await this.batchBegin(e,t))}async onBatchEnd(e,t){const r=[];this.batchEnd!=null&&(await $c(t),r.push(this.batchEnd(e,t))),this.yieldEvery==="batch"?r.push(this.nextFrameFunc()):sC(this.yieldEvery)&&r.push(this.maybeWait(this.currentEpoch,e,t)),await Promise.all(r)}async onTrainBegin(e){this.trainBegin!=null&&(await $c(e),await this.trainBegin(e))}async onTrainEnd(e){this.trainEnd!=null&&(await $c(e),await this.trainEnd(e))}}function i_(n,e){return n==null&&(n={}),n instanceof Um?[n]:Array.isArray(n)&&n[0]instanceof Um?n:rn(n).map(r=>new Lq(r,e))}class Vo{constructor(){}static registerCallbackConstructor(e,t){U(e>=0&&Number.isInteger(e),()=>`Verbosity level is expected to be an integer >= 0, but got ${e}`),Vo.checkForDuplicate(t),Vo.constructors[e]==null&&(Vo.constructors[e]=[]),Vo.constructors[e].push(t)}static checkForDuplicate(e){for(const t in Vo.constructors)Vo.constructors[+t].forEach(s=>{if(s===e)throw new Z("Duplicate callback constructor.")})}static clear(){Vo.constructors={}}static createCallbacks(e){const t=[];for(const r in Vo.constructors){const s=+r;e>=s&&t.push(...Vo.constructors[s])}return t.map(r=>new r)}}Vo.constructors={};function a_(n,e,t,r,s,o,i,a,l){const c=new Pq,d=[new Fq,...Vo.createCallbacks(e)];n!=null&&d.push(...n),d.push(c);const p=new Oq(d);return p.setParams({epochs:t,initialEpoch:r,samples:s,steps:o,batchSize:i,verbose:e,doValidation:a,metrics:l}),{callbackList:p,history:c}}function ma(n,e={},t=!1){return ax(n,Go.getMap().classNameMap,e,"layer",t)}function Qy(n,e){return me(()=>{n.dtype!=="float32"&&(n=Ge(n,"float32"));const t=rt(ux(n),e,!0),r=Cv(t.shape,nr()),s=jr(vu(t,r));return st(n,s)})}function Dv(n,e){return me(()=>Xn(ux(ut(e,n)),-1))}function SI(n,e){return me(()=>Xn(os(ut(e,n)),-1))}function kI(n,e){return me(()=>{const t=ut(n,e),r=wo(os(n),nr(),Number.MAX_VALUE),s=os(st(t,r));return ne(100,Xn(s,-1))})}function Mq(n,e){return me(()=>{const t=wo(e,nr(),Number.MAX_VALUE),r=ya(Pe(1,t)),s=wo(n,nr(),Number.MAX_VALUE),o=ya(Pe(1,s));return Xn(ux(ut(r,o)),-1)})}function zq(n,e){return me(()=>{const t=vu(0,ut(1,ne(n,e)));return Xn(ux(t),-1)})}function Bq(n,e){return me(()=>{const t=vu(0,ut(1,ne(n,e)));return Xn(t,-1)})}function Uq(n,e){return me(()=>{const t=rt(ne(n,e),-1),r=Si(ne(ut(1,n),e),-1);return vu(0,Pe(1,ut(r,t)))})}function Wq(n,e){return me(()=>{const t=Math.log(2),r=ut(e,n),s=ut(Pe(r,ex(ne(-2,r))),t);return Xn(s,-1)})}function Wm(n,e,t=!1){return me(()=>{if(t)e=Nk(e);else{const r=rt(e,e.shape.length-1,!0);e=st(e,r)}return e=wo(e,nr(),1-nr()),zn(rt(ne(Ge(n,"float32"),ya(e)),e.shape.length-1))})}function Jy(n,e,t=!1){return me(()=>{const r=Ge(Iv(lq(n)),"int32");e=wo(e,nr(),1-nr());const s=e.shape,o=ce(AR(r,s[s.length-1]),s);return Wm(o,e,t)})}function Vq(n,e){if(!Xt(n.shape,e.shape))throw new Z(`logits and labels must have the same shape, but got shapes ${JSON.stringify(n.shape)} and ${JSON.stringify(e.shape)}`);return me(()=>{const t=uh(e),r=zn(os(e));return Pe(ut(t,ne(e,n)),NR(xa(r)))})}function Ov(n,e){return me(()=>{let t;return t=wo(e,nr(),1-nr()),t=ya(st(t,ut(1,t))),Xn(Vq(n,t),-1)})}function Gq(n,e){return me(()=>{const t=wo(n,nr(),1),r=wo(e,nr(),1);return rt(ne(n,ya(st(t,r))),-1)})}function jq(n,e){return me(()=>{const t=ya(Pe(nr(),e));return Xn(ut(e,ne(n,t)),-1)})}function l_(n,e){return me(()=>{const t=Qy(n,-1),r=Qy(e,-1),s=ne(t,r);return zn(rt(s,-1))})}const Zy={meanSquaredError:Dv,meanAbsoluteError:SI,meanAbsolutePercentageError:kI,meanSquaredLogarithmicError:Mq,squaredHinge:zq,hinge:Bq,categoricalHinge:Uq,logcosh:Wq,categoricalCrossentropy:Wm,sparseCategoricalCrossentropy:Jy,binaryCrossentropy:Ov,kullbackLeiblerDivergence:Gq,poisson:jq,cosineProximity:l_};function Ab(n){if(typeof n=="string"){if(n in Zy)return Zy[n];let e=`Unknown loss ${n}`;throw n.toLowerCase().includes("softmaxcrossentropy")&&(e=`Unknown loss ${n}. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy`),new Z(e)}else return n}function u_(n,e){return me(()=>{const t=ne(.5,Ko(e)),r=fa(bo(e,t),n.dtype);return Xn(ga(n,r),-1)})}function c_(n,e){return me(()=>fa(ga(Pm(n,-1),Pm(e,-1)),"float32"))}function Hq(n,e){return me(()=>Ge(rt(rl(ga(n,1),ga(e,1))),"float32"))}function qq(n,e){return me(()=>Ge(rt(rl(ga(n,0),ga(e,1))),"float32"))}function Kq(n,e){return me(()=>{const t=Hq(n,e),r=qq(n,e),s=Pe(t,r);return Ge(us(bo(s,0),st(t,s),0),"float32")})}function Xq(n,e){return Ov(n,e)}function Yq(n,e){return n.rank===e.rank&&(n=nx(n,[n.rank-1])),e=Pm(e,-1),e.dtype!==n.dtype&&(e=Ge(e,n.dtype)),Ge(ga(n,e),"float32")}const Qq=Dv,Jq=Dv,Zq=SI,eK=SI,tK=kI,nK=kI,h_=Wm,rK=l_,d_=Jy,e1={binaryAccuracy:u_,categoricalAccuracy:c_,precision:Kq,categoricalCrossentropy:h_,sparseCategoricalCrossentropy:d_,mse:Qq,MSE:Jq,mae:Zq,MAE:eK,mape:tK,MAPE:nK,cosine:rK};function sK(n){if(typeof n=="string"&&n in e1)return e1[n];if(typeof n!="string"&&n!=null)return n;throw new Z(`Unknown metric ${n}`)}function ay(n){if(oa(n!==null,`Unknown LossOrMetricFn ${n}`),typeof n=="string")return n;{let e;for(const t of Object.keys(Zy))if(Zy[t]===n){e=t;break}if(e!==void 0)return e;for(const t of Object.keys(e1))if(e1[t]===n){e=t;break}return e!==void 0?e:n.name}}function oK(n){const e={Adagrad:()=>Wd.adagrad(.01),Adadelta:()=>Wd.adadelta(1,.95,nr()),Adam:()=>Wd.adam(.001,.9,.999,nr()),Adamax:()=>Wd.adamax(.002,.9,.999,nr(),0),RMSProp:()=>Wd.rmsprop(.001,.9,0,nr()),SGD:()=>Wd.sgd(.01)};if(e.adagrad=e.Adagrad,e.adadelta=e.Adadelta,e.adam=e.Adam,e.adamax=e.Adamax,e.rmsprop=e.RMSProp,e.sgd=e.SGD,n in e)return e[n]();throw new Z(`Unknown Optimizer ${n}`)}const y2=1*1024*1024;function v2(n,e,t=!1){if(n==null||typeof n!="object"||Object.getPrototypeOf(n)!==Object.prototype||!AC(n))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(t){const r=JSON.stringify(n);r.length>y2&&console.warn(`User-defined metadata of model "${e}" is too large in size (length=${r.length} when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= ${y2}.`)}}function AC(n){if(n===null)return!0;if(typeof n=="object")if(Object.getPrototypeOf(n)===Object.prototype){const e=Object.keys(n);for(const t of e)if(typeof t!="string"||!AC(n[t]))return!1;return!0}else if(Array.isArray(n)){for(const e of n)if(!AC(e))return!1;return!0}else return!1;else{const e=typeof n;return e==="string"||e==="number"||e==="boolean"}}function iK(n,e,t,r=console.log){const s=lK(n),o=["Layer (type)","Input Shape","Output shape","Param #"];s?(e=e||90,t=t||[.32,.61,.89,1]):(e=e||115,t=t||[.24,.48,.7,.8,1]),t[t.length-1]<=1&&(t=t.map(d=>Math.floor(e*d)));let i;if(!s){o.push("Receives inputs"),i=[];for(const d in n.nodesByDepth)i.push(...n.nodesByDepth[d])}r("_".repeat(e)),t1(o,t,r),r("=".repeat(e));const a=n.layers;for(let d=0;d<a.length;++d)s?uK(a[d],t,r):cK(a[d],t,i,r),r((d===a.length-1?"=":"_").repeat(e));n.checkTrainableWeightsConsistency();const l=aK(n),c=Ky(n.nonTrainableWeights);r(`Total params: ${l+c}`),r(`Trainable params: ${l}`),r(`Non-trainable params: ${c}`),r("_".repeat(e))}function aK(n){let e;return n.collectedTrainableWeights!=null?e=Ky(n.collectedTrainableWeights):e=Ky(n.trainableWeights),e}function lK(n){let e=!0;const t=[],r=[];for(const s in n.nodesByDepth)t.push(n.nodesByDepth[s]);for(const s of t){if(s.length>1||s.length===1&&s[0].inboundLayers.length>1){e=!1;break}r.push(...s)}if(e)for(const s of n.layers){let o=!1;for(const i of s.inboundNodes)if(r.indexOf(i)!==-1)if(o){e=!1;break}else o=!0;if(!e)break}return e}function t1(n,e,t=console.log){let r="";for(let s=0;s<n.length;++s)s>0&&(r=r.slice(0,r.length-1)+" "),r+=n[s],r=r.slice(0,e[s]),r+=" ".repeat(e[s]-r.length);t(r)}function uK(n,e,t){let r,s;try{s=n.inboundNodes.map(l=>JSON.stringify(l.inputShapes)).join(",")}catch{s="multiple"}try{r=JSON.stringify(n.outputShape)}catch{r="multiple"}const o=n.name,i=n.getClassName(),a=[`${o} (${i})`,s,r,n.countParams().toString()];t1(a,e,t)}function cK(n,e,t,r){let s,o;try{o=n.inboundNodes.map(p=>JSON.stringify(p.inputShapes)).join(",")}catch{o="multiple"}try{s=JSON.stringify(n.outputShape)}catch{s="multiple"}const i=[];for(const p of n.inboundNodes)if(!(t!=null&&t.length>0&&t.indexOf(p)===-1))for(let m=0;m<p.inboundLayers.length;++m){const y=p.inboundLayers[m].name,v=p.nodeIndices[m],b=p.tensorIndices[m];i.push(`${y}[${v}][${b}]`)}const a=n.name,l=n.getClassName(),c=i.length===0?"":i[0],d=[`${a} (${l})`,o,s,n.countParams().toString(),c];t1(d,e,r);for(let p=1;p<i.length;++p)t1(["","","","",i[p]],e,r)}function f_(n,e,t){return(n==="inboundNodes"||n==="outputLayers"||n==="inputLayers")&&e===0&&typeof t=="string"}function n1(n,e){if(n===null)return null;if(typeof n=="string")return Ac(n);if(typeof n=="number"||typeof n=="boolean")return n;if(n instanceof Array){const t=[],r=n.length;for(let s=0;s<r;++s){const o=n[s];f_(e,s,o)?t.push(o):t.push(n1(o,e))}return t}else{const t={};for(const r of Object.keys(n)){const s=n[r];if(r==="name"&&typeof s=="string")t[r]=s;else{const o=Ac(r);t[o]=n1(s,o)}}return t}}function _C(n,e){if(n==null)return null;if(typeof n=="string")return el(n);if(typeof n=="number"||typeof n=="boolean")return n;if(n instanceof Array){const t=[],r=n.length;for(let s=0;s<r;++s){const o=n[s];f_(e,s,o)?t.push(o):t.push(_C(o,e))}return t}else{const t={};for(const r of Object.keys(n)){const s=n[r],o=el(r);(r==="name"||r==="className")&&typeof s=="string"?t[o]=s:t[o]=_C(s,r)}return t}}const p_="4.22.0";const hK=n=>{const e=Object.keys(n);if(e.length===0)return!1;const t=e[0].split("/");return!isNaN(parseInt(t[t.length-1],10))};class xi extends Et{constructor(e){if(super({}),this.containerNodes=new Set,this.name=e.name,this.name==null){const I=this.getClassName().toLowerCase();this.name=Rv(I)}if(this.supportsMasking=!1,this.trainable_=!0,Array.isArray(e.inputs)?this.inputs=e.inputs.slice():this.inputs=[e.inputs],Array.isArray(e.outputs)?this.outputs=e.outputs.slice():this.outputs=[e.outputs],ou(this.inputs).length!==this.inputs.length)throw new Z(`The list of inputs passed to the model is redundant. All inputs should only appear once. Found: ${this.inputs.map(I=>I.name)}`);ou(this.outputs).length!==this.outputs.length&&console.warn(`The list of outputs passed to the model is redundant. All outputs should only appear once. Found: ${this.outputs.map(I=>I.name)}`),this.inputLayers=[],this.inputLayersNodeIndices=[],this.inputLayersTensorIndices=[],this.outputLayers=[],this.outputLayersNodeIndices=[],this.outputLayersTensorIndices=[],this.layers=[],this.internalContainerRefs=[];for(const I of this.outputs){const N=I.sourceLayer,T=I.nodeIndex,A=I.tensorIndex;this.outputLayers.push(N),this.outputLayersNodeIndices.push(T),this.outputLayersTensorIndices.push(A)}for(const I of this.inputs){const N=I.sourceLayer,T=I.nodeIndex,A=I.tensorIndex;oa(T===0,"input layer has >1 nodes"),oa(A===0,"input layer has >1 tensors"),this.inputLayers.push(N),this.inputLayersNodeIndices.push(T),this.inputLayersTensorIndices.push(A)}this.inputNames=[],this.outputNames=[],this.feedInputShapes=[],this.feedInputNames=[],this.feedOutputNames=[];for(let I=0;I<this.inputLayers.length;I++){const N=this.inputLayers[I];if(!(N instanceof hx))throw new TypeError(`Input layers to a LayersModel must be InputLayer objects. Received inputs: ${e.inputs}. Input ${I} (0-based) originates from layer type ${N.getClassName()}.`);this.inputNames.push(N.name),this.feedInputShapes.push(N.batchInputShape),this.feedInputNames.push(N.name)}for(const I of this.outputLayers)this.outputNames.push(I.name);this.internalInputShapes=this.inputs.map(I=>I.shape),this.internalOutputShapes=this.outputs.map(I=>I.shape);const t={},r={},s={},o={},i={},a=[],l=(I,N,T,A,O,P)=>{(A==null||O==null||P==null)&&(A=I.sourceLayer,O=I.nodeIndex,P=I.tensorIndex);const B=A.inboundNodes[O];if(T.indexOf(B)!==-1)throw new jo(`The tensor ${I.name} at layer "${A.name}" is part of a cycle.`);if(N.indexOf(B)!==-1)return;this.containerNodes.add(xi.nodeKey(A,O)),A.id in i||(i[A.id]=Object.keys(i).length),T.indexOf(B)===-1&&T.push(B);const z=B.inboundLayers.length;for(let L=0;L<z;L++){const _=B.inputTensors[L],H=B.inboundLayers[L],Y=B.nodeIndices[L],re=B.tensorIndices[L];l(_,N,T,H,Y,re)}for(N.push(B);T.indexOf(B)>=0;)T.splice(T.indexOf(B),1);a.push(B)},c=[],d=[];for(const I of this.outputs)l(I,c,d);const p=a.slice().reverse();for(const I of p){r[I.id]=I,I.id in t||(t[I.id]=0);let N=t[I.id];const T=s[I.outboundLayer.id]==null?0:s[I.outboundLayer.id];N=Math.max(N,T),s[I.outboundLayer.id]=N,o[I.outboundLayer.id]=I.outboundLayer,t[I.id]=N;for(let A=0;A<I.inboundLayers.length;A++){const O=I.inboundLayers[A],P=I.nodeIndices[A],B=O.inboundNodes[P],z=t[B.id]==null?0:t[B.id];t[B.id]=Math.max(N+1,z),r[B.id]=B}}const m={};for(const I in t){const N=t[I];N in m||(m[N]=[]),m[N].push(r[I])}const y={};for(const I in s){const N=s[I];N in y||(y[N]=[]),y[N].push(o[I])}let v=Object.keys(y).map(I=>parseInt(I,10)).sort(sy);this.layers=[];for(const I of v){const N=y[I];N.sort((T,A)=>{const O=i[T.id],P=i[A.id];return O<P?-1:O>P?1:0});for(const T of N)T instanceof xi&&this.internalContainerRefs.push(T),this.layers.push(T)}this.layersByDepth=y,v=Object.keys(m).map(I=>parseInt(I,10)).sort(sy);const b=this.inputs.slice(),w=[];for(const I of v)for(const N of m[I]){const T=N.outboundLayer;if(T!=null){for(const A of N.inputTensors)if(b.indexOf(A)===-1)throw new jo(`Graph disconnected: cannot obtain value for tensor ${A} at layer "${T.name}". The following previous layers were accessed without issue: ${w}`);for(const A of N.outputTensors)b.push(A);w.push(T.name)}}this.nodesByDepth=m;const k=this.layers.map(I=>I.name);for(const I of k){const N=k.filter(T=>T===I).length;if(N!==1)throw new jo(`The name "${I}" is used ${N} times in the model. All layer names should be unique. Layer names: `+JSON.stringify(k))}this.outboundNodes=[],this.inboundNodes=[],new _v({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:this.inputs.map(I=>null),outputMasks:this.outputs.map(I=>null),inputShapes:this.inputs.map(I=>I.shape),outputShapes:this.outputs.map(I=>I.shape)}),this.built=!0,this._refCount=1}assertNotDisposed(){if(this._refCount===0)throw new Error(`Container '${this.name}' is already disposed.`)}dispose(){this.assertNotDisposed();const e={refCountAfterDispose:null,numDisposedVariables:0};if(--this._refCount===0){for(const t of this.layers)e.numDisposedVariables+=t.dispose().numDisposedVariables;for(const t of this.internalContainerRefs)e.numDisposedVariables+=t.dispose().numDisposedVariables}return e.refCountAfterDispose=this._refCount,e}get trainable(){return this.trainable_}set trainable(e){this.layers.forEach(t=>{t._trainableWeights.forEach(r=>r.trainable=e)}),this.trainable_=e}get trainableWeights(){if(this._trainableWeights.length>0)throw new Z("Container instance unexpectedly contains _trainableWeights.The trainable weights of a Container are a union of the trainable weights of its consituent Layers. Its own _trainableWeights must remain an empty Array.");if(!this.trainable)return[];let e=[];for(const t of this.layers)e=e.concat(t.trainableWeights);return e}get nonTrainableWeights(){const e=[];for(const t of this.layers)e.push(...t.nonTrainableWeights);if(!this.trainable){const t=[];for(const r of this.layers)t.push(...r.trainableWeights);return t.concat(e)}return e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}loadWeights(e,t=!0){const r={};let s=0;const o=hK(e);o&&this.parseWeights(e);for(const a of this.layers)for(const[l,c]of a.weights.entries()){const d=o?`${c.name.split("/").slice(0,-1).join("/")+"/"}${l}`:c.originalName;if(r[d]!=null)throw new Z(`Duplicate weight name: ${d}`);r[d]=c,s++}const i=[];for(const a in e){let l=a;if(r[a]==null){const c=a.split("/");l=c.slice(0,-2).concat([c[c.length-1]]).join("/")}if(r[l]!=null)i.push([r[l],e[a]]);else if(t)throw new Z(`Provided weight data has no target variable: ${a}`);delete r[l]}if(t){const a=[];for(const l in r)a.push(l);if(a.length>0)throw new Z(`${a.length} of ${s} weights are not set: ${a}`)}bI(i)}parseWeights(e){for(const t in Object.keys(e)){const r=t.split("/"),s=["vars","layer_checkpoint_dependencies"],o=r.map(i=>i.startsWith("_")?i.slice(1):i).filter(i=>!s.includes(i)).join("/");o!==t&&(e[o]=e[t],delete e[t])}}updatedConfig(){const e=this.getConfig(),t={};return t.className=this.getClassName(),t.config=e,t.kerasVersion=`tfjs-layers ${p_}`,t.backend="TensorFlow.js",t}toJSON(e,t=!0){const r=_C(this.updatedConfig());return t?JSON.stringify(r):r}call(e,t){return me(()=>{e=rn(e);const r=new eu;for(let s=0;s<this.inputs.length;++s)r.add(this.inputs[s],e[s]);return bm(this.outputs,r,t)})}computeMask(e,t){return me(()=>{e=rn(e);let r;return t==null?r=th(null,e.length):r=rn(t),this.runInternalGraph(e,r)[1]})}computeOutputShape(e){const t=qy(e);if(t.length!==this.inputLayers.length)throw new Z(`Invalid inputShape argument ${e}: model has ${this.inputLayers.length} tensor inputs.`);const r={};for(let a=0;a<t.length;a++){const l=this.inputLayers[a],c=t[a],d=l.name+"_0_0";r[d]=c}const s=Object.keys(this.nodesByDepth).map(a=>parseInt(a,10)).sort(sy);if(s.length>1)for(const a of s){const l=this.nodesByDepth[a];for(const c of l){const d=c.outboundLayer;if(this.inputLayers.map(b=>b.id).indexOf(d.id)!==-1)continue;const p=[];for(let b=0;b<c.inboundLayers.length;b++){const w=c.inboundLayers[b],k=c.nodeIndices[b],I=c.tensorIndices[b],N=`${w.name}_${k}_${I}`,T=r[N];p.push(T)}const m=d.computeOutputShape(ks(p)),y=qy(m),v=d.inboundNodes.indexOf(c);for(let b=0;b<y.length;b++){const w=`${d.name}_${v}_${b}`;r[w]=y[b]}}}const o=[],i=[];for(let a=0;a<this.outputLayers.length;a++){const l=this.outputLayers[a],c=this.outputLayersNodeIndices[a],d=this.outputLayersTensorIndices[a],p=`${l.name}_${c}_${d}`;i.push(p)}for(let a=0;a<i.length;a++){const l=i[a];oa(l in r),o.push(r[l])}return ks(o)}runInternalGraph(e,t){t==null&&(t=th(null,e.length));const r={};for(let l=0;l<this.inputs.length;++l){const c=this.inputs[l],d=e[l],p=t[l];r[c.id]=[d,p]}const s=Object.keys(this.nodesByDepth).map(l=>parseInt(l,10)).sort(sy);for(const l of s){const c=this.nodesByDepth[l];for(const d of c){const p=d.outboundLayer,m=d.inputTensors,y=d.outputTensors,v=new Array;for(const b of m)b.id in r&&v.push(r[b.id]);if(v.length===m.length){let b={},w,k,I,N;if(d.callArgs!=null&&(b=d.callArgs),v.length===1){const[T,A]=v[0];b.mask==null&&(b.mask=A),I=rn(p.call(T,b)),N=rn(p.computeMask(T,A)),w=[T],k=[A]}else w=v.map(T=>T[0]),k=v.map(T=>T[1]),b.mask==null&&(b.mask=k),I=rn(p.call(w,b)),N=rn(p.computeMask(w,k));if(p.activityRegularizer)throw new wt("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(let T=0;T<y.length;++T){const A=y[T],O=I[T],P=N[T];r[A.id]=[O,P]}}}}const o=[],i=[],a=[];for(const l of this.outputs){oa(l.id in r,`Could not compute output ${l.name} : ${l.id}`);const[c,d]=r[l.id];a.push(c.shape),o.push(c),i.push(d)}return[o,i,a]}buildNodeConversionMap(e){const t={};let r;for(const s of this.layers){r=s instanceof xi?1:0;for(let o=0;o<s.inboundNodes.length;o++){const i=xi.nodeKey(s,o);this.containerNodes.has(i)&&(t[i]=r,r+=1)}}return t}getLayer(e,t){if(t!=null)return this.findLayer(t);if(e==null)throw new Z("Provide either a layer name or layer index");if(typeof e=="number")return this.findLayer(e);for(const r of this.layers)if(r.name===e)return r;throw new Z(`No such layer: ${e}`)}findLayer(e){if(this.layers.length<=e)throw new Z(`Was asked to retrieve layer at index ${e}, but model only has ${this.layers.length} layer(s).`);return this.layers[e]}calculateLosses(){return me(()=>{const e=[];for(const t of this.layers)for(let r=0;r<t.inboundNodes.length;++r){const s=xi.nodeKey(t,r);this.containerNodes.has(s)&&e.push(...t.calculateLosses())}return e})}getConfig(){const e={name:this.name},t=this.buildNodeConversionMap(this.layers),r=[];for(const i of this.layers){const a=i.getClassName(),l=i.getConfig(),c=[];for(let p=0;p<i.inboundNodes.length;p++){const m=i.inboundNodes[p],y=xi.nodeKey(i,p);let v={};if(this.containerNodes.has(y)){if(m.callArgs)try{JSON.stringify(m.callArgs),v=m.callArgs}catch{console.warn(`Layer ${i.name} was passed non-serializable keyword arguments: ${m.callArgs}. They will not be included in the serialized model (and thus will be missing at deserialization time).`),v={}}if(m.inboundLayers.length>0){const b=[];for(let w=0;w<m.inboundLayers.length;w++){const k=m.inboundLayers[w],I=m.nodeIndices[w],N=m.tensorIndices[w],T=xi.nodeKey(k,I);let A=t[T];A==null&&(A=0),b.push([k.name,A,N,v])}c.push(b)}}}const d={};d.name=i.name,d.className=a,d.config=l,d.inboundNodes=c,r.push(d)}e.layers=r;const s=[];for(let i=0;i<this.inputLayers.length;i++){const a=this.inputLayers[i],l=this.inputLayersNodeIndices[i],c=xi.nodeKey(a,l);if(!this.containerNodes.has(c))continue;let d=t[c];d==null&&(d=0);const p=this.inputLayersTensorIndices[i];s.push([a.name,d,p])}e.inputLayers=s;const o=[];for(let i=0;i<this.outputLayers.length;i++){const a=this.outputLayers[i],l=this.outputLayersNodeIndices[i],c=xi.nodeKey(a,l);if(!this.containerNodes.has(c))continue;let d=t[c];d==null&&(d=0);const p=this.outputLayersTensorIndices[i];o.push([a.name,d,p])}return e.outputLayers=o,e}static fromConfig(e,t,r={},s=!1){const o={},i={};function a(w,k){w.name in i?i[w.name].push(k):i[w.name]=[k]}function l(w,k){const I=[];let N;for(const T of k){const A=T[0],O=T[1],P=T[2];if(N=T[3]==null?{}:T[3],!(A in o)){a(w,k);return}const B=o[A];if(B.inboundNodes.length<=O){a(w,k);return}const z=B.inboundNodes[O];I.push(z.outputTensors[P])}I.length>0&&w.apply(ks(I),N)}function c(w){const k=w.name,I=ma(w,t.customObjects!=null?t.customObjects:{});I.setFastWeightInitDuringBuild(s),o[k]=I,w.inboundNodes.forEach(T=>{if(!(T instanceof Array))throw new Z(`Corrupted configuration, expected array for nodeData: ${T}`);a(I,T)})}const d=t.name,p=t.layers;for(const w of p)c(w);for(;!X8(i);)for(const w of p){const k=o[w.name];if(k.name in i){const I=i[k.name];delete i[k.name];for(const N of I)l(k,N)}}const m=[],y=[],v=t.inputLayers;for(const w of v){const k=w[0],I=w[1],N=w[2];oa(k in o);const A=o[k].inboundNodes[I].outputTensors;m.push(A[N])}const b=t.outputLayers;for(const w of b){const k=w[0],I=w[1],N=w[2];oa(k in o);const A=o[k].inboundNodes[I].outputTensors;y.push(A[N])}return new e({inputs:m,outputs:y,name:d})}get stateful(){if(this._stateful)throw new Z("Container instance unexpectedly has _stateful = true. The statefulness of a Container is determined by the Layers it contains. Its _stateful property must remain the default false.");for(const e of this.layers)if(e.stateful)return!0;return!1}resetStates(){me(()=>{this.layers.forEach(e=>{e.stateful&&e.resetStates()})})}}function dK(n,e,t){const r=e.length;if(n==null||Array.isArray(n)&&n.length===0)return e.map(s=>null);if(r===1)return Array.isArray(n)&&n.length===1?n:typeof n=="object"&&e[0]in n?[n[e[0]]]:[n];if(Array.isArray(n)){if(n.length!==r)throw new Error(`Provided ${t} is an array of ${n.length} element(s), but the model has ${r} outputs. Make sure a set of weights is provided for each model output.`);return n}else if(typeof n=="object"&&Object.keys(n).length>0&&typeof n[Object.keys(n)[0]]=="object"){const s=[];return e.forEach(o=>{o in n?s.push(n[o]):s.push(null)}),s}else throw new Error(`The model has multiple (${r}) outputs, so ${t} must be either an array with ${r} elements or an object with ${e} keys. Provided ${t} not understood: ${JSON.stringify(n)}`)}function m_(n,e){return dK(n,e,"classWeight")}async function g_(n,e,t,r){if(t!=null){const s=me(()=>{if(n.shape.length===1)return Lc(n);if(n.shape.length===2){if(n.shape[1]>1)return Pm(n,1);if(n.shape[1]===1)return ce(n,[n.shape[0]]);throw new Error(`Encountered unexpected last-dimension size (${n.shape[1]}) during handling of class weights. The size is expected to be >= 1.`)}else throw new Error(`Unexpected rank of target (y) tensor (${n.rank}) during handling of class weights. The rank is expected to be 1 or 2.`)}),o=Array.from(await s.data());kt(s);const i=[];return o.forEach(a=>{if(t[a]==null)throw new Error(`classWeight must contain all classes in the training data. The class ${a} exists in the data but not in classWeight`);i.push(t[a])}),qs(i,"float32")}else return null}function fK(n,e){return ne(n,e)}const pK=32;function x_(n,e){let t,r;const s=e;t=s.xs,r=s.ys,U(t!=null&&r!=null,()=>`A Dataset iterator for fitDataset() is expected to generate objects of the form \`{xs: xVal, ys: yVal}\`, where the two values may be \`tf.Tensor\`, an array of Tensors, or a map of string to Tensor. The provided Dataset instead generates ${e}`);const o=w2("input",n.inputNames,t),i=w2("output",n.outputNames,r),a=o[0].shape[0];U(o.length===n.inputs.length,()=>`LayersModel has ${n.inputs.length} inputs, but the dataset provides ${o.length} inputs. (Expected input keys: ${JSON.stringify(n.inputNames)})`),U(i.length===n.outputs.length,()=>`LayersModel has ${n.outputs.length} outputs, but the dataset provides ${i.length} outputs. (Expected output keys: ${JSON.stringify(n.outputNames)})`);for(let l=0;l<o.length;l++)U(o[l].shape[0]===a,()=>`Batch size mismatch: input ${n.inputNames[l]} has ${o[l].shape[0]}; expected ${a} based on input ${n.inputNames[0]}.`);for(let l=0;l<i.length;l++)U(i[l].shape[0]===a,()=>`Batch size mismatch: output ${n.outputNames[l]} has ${i[l].shape[0]}; expected ${a} based on input ${n.inputNames[0]}.`);return{xs:o,ys:i}}function w2(n,e,t){if(t instanceof tr)return[t];if(Array.isArray(t))return U(t.length===e.length,()=>`Received an array of ${t.length} Tensors, but expected ${e.length} to match the ${n} keys ${e}.`),t;{const r=[];for(const s of e){if(t[s]==null)throw new Z(`The feature data generated by the dataset lacks the required ${n} key '${s}'.`);r.push(t[s])}return r}}function mK(n){if(n.length===3)throw new wt("Validation with sample weights is not implemented yet.");return{xs:n[0],ys:n[1]}}async function gK(n,e,t){const r=t.batchesPerEpoch!=null;if(U(n.optimizer!=null,()=>"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig)."),U(t!=null,()=>"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call."),U(t.epochs!=null&&t.epochs>0&&Number.isInteger(t.epochs),()=>`For fitDataset(), config.epochs is expected to be a positive integer, but got ${t.epochs}`),U(!r||t.batchesPerEpoch>0&&Number.isInteger(t.batchesPerEpoch),()=>`For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got ${t.batchesPerEpoch}`),U(t.validationSplit==null,()=>"`validationSplit` is not supported by `fitDataset()`. Use validationData instead."),n.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");n.isTraining=!0;try{const s=t.validationData!=null;let o,i;if(s)if(b2(t.validationData))U(t.validationBatches==null||t.validationBatches>0&&Number.isInteger(t.validationBatches),()=>`For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, but got ${t.validationBatches}`);else{const w=mK(t.validationData);o=w.xs,i=w.ys}const a=n.makeTrainFunction(),l=n.getDedupedMetricsNames();let c;s?c=l.slice().concat(l.map(w=>"val_"+w)):c=l.slice();const d=i_(t.callbacks,t.yieldEvery),p=t.verbose==null?1:t.verbose,{callbackList:m,history:y}=a_(d,p,t.epochs,null,null,xK(e,t),null,s,c);m.setModel(n),n.history=y,await m.onTrainBegin(),n.stopTraining_=!1;let v=t.initialEpoch==null?0:t.initialEpoch,b=await e.iterator();for(;v<t.epochs;){const w={};await m.onEpochBegin(v);let k=0,I=0;for(r||(b=await e.iterator());!r||k<t.batchesPerEpoch;){const N=await b.next();if(r&&N.done){console.warn(`You provided \`batchesPerEpoch\` as ${t.batchesPerEpoch}, but your dataset iterator ran out of data after ${k} batches; interrupting training. Make sure that your dataset can generate at least \`batchesPerEpoch * epochs\` batches (in this case, ${t.batchesPerEpoch*t.epochs} batches). You may need to use the repeat() function when building your dataset.`);break}if(N.value!=null){const{xs:T,ys:A}=x_(n,N.value),O={};O.batch=I,O.size=T[0].shape[0],await m.onBatchBegin(I,O);const P=[];if(t.classWeight!=null){const L=m_(t.classWeight,n.outputNames);for(let _=0;_<L.length;++_)P.push(await g_(A[_],null,L[_]))}const B=T.concat(A).concat(P),z=a(B);kt(B);for(let L=0;L<l.length;++L){const _=l[L],H=z[L];O[_]=H,ha(H)}await m.onBatchEnd(I,O),o_(O),I++,k++}if(r?k>=t.batchesPerEpoch:N.done){if(s){let T;b2(t.validationData)?T=rn(await n.evaluateDataset(t.validationData,{batches:t.validationBatches})):T=rn(n.evaluate(o,i,{batchSize:t.validationBatchSize==null?pK:t.validationBatchSize,verbose:0}));for(let A=0;A<n.metricsNames.length;++A)w[`val_${n.metricsNames[A]}`]=T[A]}break}if(n.stopTraining_)break}if(await m.onEpochEnd(v,w),v++,n.stopTraining_)break}return await m.onTrainEnd(),await n.history.syncData(),n.history}finally{n.isTraining=!1}}function xK(n,e){let t=null;return e.batchesPerEpoch!=null?t=e.batchesPerEpoch:Number.isFinite(n.size)&&(t=n.size),t}function b2(n){return typeof n.iterator=="function"}function yK(n){return typeof n.next=="function"}async function vK(n,e,t){t=t||{};const r=t.batches!=null,s=n.testFunction;let o=[];if(t.verbose>0)throw new wt("Verbose mode is not implemented yet.");U(!r||t.batches>0&&Number.isInteger(t.batches),()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(t.batches)}`);const i=yK(e)?e:await e.iterator();let a=0,l=0;for(;!r||l<t.batches;){const c=await i.next();if(o=me(()=>{if(c.value){const{xs:d,ys:p}=x_(n,c.value),m=d.concat(p),y=me(()=>s(m));if(kt(m),l===0)for(let b=0;b<y.length;++b)o.push(Kt(0));const v=m[0].shape[0];for(let b=0;b<y.length;++b){const w=y[b],k=o[b];o[b]=me(()=>Pe(o[b],ne(v,w))),l>0&&kt(k)}kt(y),a+=v,++l}return o}),c.done){r&&console.warn(`Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least \`batches\` batches (in this case, ${t.batches} batches). You may need to use the repeat() function when building your dataset.`);break}}for(let c=0;c<o.length;++c){const d=o[c];o[c]=st(o[c],a),kt(d)}return ks(o)}function _b(n){U(n>0&&Number.isInteger(n),()=>`batchSize is required to be a positive integer, but got ${n}`)}function gm(n,e,t){return n==null?[null]:Array.isArray(n)?n.map(r=>zc(r,e,t-e)):zc(n,e,t-e)}function DC(n,e){return me(()=>n==null?null:Array.isArray(n)?n.map(t=>DC(t,e)):jA(n,e.dtype==="int32"?e:Ge(e,"int32")))}function Db(n,e){const t=[];let r=0,s=null;for(;r<n;)s=r+e,s>=n&&(s=n),t.push([r,s]),r=s;return t}function y_(n){const e=[];n instanceof tr&&(n=[n]);for(let t=0;t<n.length;++t){const r=n[t];if(r.rank===1)e.push(lx(r,1));else{if(r.rank===0)throw new Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar).");e.push(r)}}return e}function gi(n,e){if(n==null)return;const t=[];if(e instanceof tr)t.push(e.id);else if(Array.isArray(e))e.forEach(s=>t.push(s.id));else if(e!=null)for(const s in e){const o=e[s];t.push(o.id)}const r=[];if(n instanceof tr)t.indexOf(n.id)===-1&&r.push(n);else if(Array.isArray(n))n.forEach(s=>{t.indexOf(s.id)===-1&&r.push(s)});else if(n!=null)for(const s in n){const o=n[s];t.indexOf(o.id)===-1&&r.push(o)}r.forEach(s=>{s.isDisposed||s.dispose()})}function wK(n){return n instanceof tr}function OC(n){return Array.isArray(n)}function C2(n){return!wK(n)&&!OC(n)}function S2(n,e,t,r=!0,s=""){if(e==null||e.length===0){if(n!=null){let i=!1;if(OC(n)&&n.length>0)i=!0;else if(C2(n)){for(const a in n)if(n.hasOwnProperty(a)){i=!0;break}}else i=!0;if(i)throw new Z(`Error when checking model ${s} expected no data, but got ${n}`)}return[]}if(n==null)return e.map(i=>null);let o;if(C2(n)){n=n,o=[];for(const i of e){if(n[i]==null)throw new Z(`No data provided for "${i}". Need data for each key in: ${e}`);o.push(n[i])}}else if(OC(n)){if(n=n,n.length!==e.length)throw new Z(`Error when checking model ${s}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${e.length} Tensor(s), but instead got the following list of Tensor(s): ${n}`);o=n}else{if(n=n,e.length>1)throw new Z(`The model ${s} expects ${e.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${n.shape}`);o=[n]}if(o=y_(o),t!=null)for(let i=0;i<e.length;++i){if(t[i]==null)continue;const a=o[i];if(a.shape.length!==t[i].length)throw new Z(`Error when checking ${s}: expected ${e[i]} to have ${t[i].length} dimension(s). but got array with shape ${a.shape}`);for(let l=0;l<t[i].length;++l){if(l===0&&!r)continue;const c=a.shape[l],d=t[i][l];if(d!=null&&d>=0&&c!==d)throw new Z(`${s} expected a batch of elements where each example has shape [${t[i].slice(1,t[i].length)}] (i.e.,tensor shape [*,${t[i].slice(1,t[i].length)}]) but the ${s} received an input with ${a.shape[0]} examples, each with shape [${a.shape.slice(1,a.shape.length)}] (tensor shape [${a.shape}])`)}}return o}function bK(n,e,t){const r=ou(n.map(o=>o.shape[0]));r.sort();const s=ou(e.map(o=>o.shape[0]));if(s.sort(),r.length>1)throw new Z(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(n.map(o=>o.shape))}`);if(s.length>1)throw new Z(`All target Tensors (y) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map(o=>o.shape))}`);if(r.length>0&&s.length>0&&!Xt(r,s))throw new Z(`Input Tensors should have the same number of samples as target Tensors. Found ${r[0]} input sample(s) and ${s[0]} target sample(s).`)}function CK(n,e,t){const r=[Dv,Ov,Wm];for(let s=0;s<n.length;++s){const o=n[s],i=e[s],a=t[s];if(i!=null){if(i===Wm&&o.shape[o.shape.length-1]===1)throw new Z(`You are passing a target array of shape ${o.shape} while using a loss 'categorical_crossentropy'. 'categorical_crossentropy'expects targets to be binary matrices (1s and 0s) of shape [samples, classes].`);if(r.indexOf(i)!==-1){const l=o.shape.slice(1),c=a.slice(1);for(let d=0;d<l.length;++d){const p=l[d],m=c[d];if(m!=null&&p!==m)throw new Z(`A target Tensor with shape ${o.shape} was passed for an output of shape ${a}, while using a loss function that expects targets to have the same shape as the output.`)}}}}}function k2(n,e,t,r=!0,s=""){let o;if(Array.isArray(n)){if(n.length!==e.length)throw new Z(`Error when checking model ${s}: the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see ${e.length} Tensor(s), but instead got ${n.length} Tensors(s).`);o=n}else{if(e.length>1)throw new Z(`The model expects ${e.length} ${s} Tensors, but only received one Tensor. Found: array with shape ${JSON.stringify(n.shape)}.`);o=[n]}if(t!=null)for(let i=0;i<e.length;++i){if(t[i]==null)continue;const a=o[i];if(a.shape.length!==t[i].length)throw new Z(`Error when checking ${s}: expected ${e[i]} to have ${t[i].length} dimension(s), but got array with shape ${JSON.stringify(a.shape)}`);for(let l=0;l<t[i].length;++l){if(l===0&&!r)continue;const c=a.shape[l],d=t[i][l];if(d!=null&&d!==c)throw new Z(`Error when checking ${s}: expected ${e[i]} to have shape ${JSON.stringify(t[i])} but got array with shape ${JSON.stringify(a.shape)}.`)}}}function SK(n,e){if(n==null||Array.isArray(n)&&n.length===0)return e.map(r=>[]);let t;if(typeof n=="string"||typeof n=="function")t=[n];else if(Array.isArray(n)||typeof n=="object")t=n;else throw new TypeError(`Type of metrics argument not understood. Expected an string,function, Array, or Object, found: ${n}`);if(Array.isArray(t))return e.map(r=>t);{const r=[];for(const s of e){let o=t.hasOwnProperty(s)?t[s]:[];Array.isArray(o)||(o=[o]),r.push(o)}return r}}const kK="layers-model";class nf extends xi{constructor(e){super(e),this.isTraining=!1}summary(e,t,r=console.log){if(!this.built)throw new Z("This model has never been called, thus its weights have not been created yet. So no summary can be displayed. Build the model first (e.g., by calling it on some test data).");iK(this,e,t,r)}compile(e){if(e.loss==null&&(e.loss=[]),this.loss=e.loss,typeof e.optimizer=="string")this.optimizer_=oK(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof bu))throw new Z("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=e.optimizer,this.isOptimizerOwned=!1}let t=[];if(!Array.isArray(e.loss)&&typeof e.loss!="string"&&typeof e.loss!="function"){e.loss=e.loss;for(const i in e.loss)if(this.outputNames.indexOf(i)===-1)throw new Z(`Unknown entry in loss dictionary: "${i}". Only expected the following keys: ${this.outputNames}`);for(const i of this.outputNames)e.loss[i]==null&&console.warn(`Output "${i}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${i} during training`),t.push(Ab(e.loss[i]))}else if(Array.isArray(e.loss)){if(e.loss.length!==this.outputs.length)throw new Z(`When passing an Array as loss, it should have one entry per model output. The model has ${this.outputs.length} output(s), but you passed loss=${e.loss}.`);t=e.loss.map(a=>Ab(a))}else{const i=Ab(e.loss);this.outputs.forEach(a=>{t.push(i)})}this.lossFunctions=t,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(let i=0;i<this.outputs.length;++i){const a=this.internalOutputShapes[i],l=this.outputNames[i];this.feedOutputNames.push(l),this.feedOutputShapes.push(a),this.feedLossFns.push(this.lossFunctions[i])}const r=[];this.metrics=e.metrics,this.metricsNames=["loss"],this.metricsTensors=[],Mc("loss",()=>{for(let i=0;i<this.outputs.length;++i){if(r.indexOf(i)!==-1)continue;const a=this.lossFunctions[i];this.outputs.length>1&&(this.metricsTensors.push([a,i]),this.metricsNames.push(this.outputNames[i]+"_loss"))}});const s=SK(e.metrics,this.outputNames),o=(i,a,l)=>{this.outputNames.length>1&&(a=this.outputNames[i]+"_"+a),this.metricsNames.push(a),this.metricsTensors.push([l,i])};Mc("metric",()=>{for(let i=0;i<this.outputs.length;++i){if(r.indexOf(i)!==-1)continue;const a=s[i];(c=>{let p,m,y;for(const v of c){if(typeof v=="string"&&["accuracy","acc","crossentropy","ce"].indexOf(v)!==-1){const w=this.internalOutputShapes[i];w[w.length-1]===1||this.lossFunctions[i]===Ov?["accuracy","acc"].indexOf(v)!==-1?m=u_:["crossentropy","ce"].indexOf(v)!==-1&&(m=Xq):this.lossFunctions[i]===Jy?["accuracy","acc"].indexOf(v)!==-1?m=Yq:["crossentropy","ce"].indexOf(v)!==-1&&(m=d_):["accuracy","acc"].indexOf(v)!==-1?m=c_:["crossentropy","ce"].indexOf(v)!==-1&&(m=h_);let k;["accuracy","acc"].indexOf(v)!==-1?k="acc":["crossentropy","ce"].indexOf(v)!==-1&&(k="ce"),y=m,p=""+k}else y=sK(v),p=""+ay(v);let b;Mc(p,()=>{b=y}),o(i,p,b)}})(a)}}),this.collectedTrainableWeights=this.trainableWeights}checkTrainableWeightsConsistency(){this.collectedTrainableWeights!=null&&this.trainableWeights.length!==this.collectedTrainableWeights.length&&console.warn("Discrepancy between trainableweights and collected trainable weights. Did you set `model.trainable` without calling `model.compile()` afterwards?")}evaluate(e,t,r={}){const s=r.batchSize==null?32:r.batchSize;_b(s);const i=this.standardizeUserDataXY(e,t,!0,s);try{const a=i[0].concat(i[1]);this.makeTestFunction();const l=this.testFunction,c=this.testLoop(l,a,s,r.verbose,r.steps);return ks(c)}finally{gi(i[0],e),gi(i[1],t)}}async evaluateDataset(e,t){return this.makeTestFunction(),vK(this,e,t)}checkNumSamples(e,t,r,s="steps"){let o;if(r!=null){if(o=null,t!=null)throw new Z(`If ${s} is set, batchSize must be null or undefined.Got batchSize = ${t}`)}else if(e!=null)Array.isArray(e)?o=e[0].shape[0]:o=e.shape[0];else throw new Z(`Either the input data should have a defined shape, or ${s} shoud be specified.`);return o}execute(e,t){if(Array.isArray(t)&&t.length===0)throw new Z("`outputs` is an empty Array, which is not allowed.");const r=Array.isArray(t),s=r?t:[t],o=this.retrieveSymbolicTensors(s),i=new eu;if(e instanceof tr&&(e=[e]),Array.isArray(e)){if(e.length!==this.inputs.length)throw new Z(`The number of inputs provided (${e.length}) does not match the number of inputs of this model (${this.inputs.length}).`);for(let l=0;l<this.inputs.length;++l)i.add(this.inputs[l],e[l])}else for(const l of this.inputs){const c=e[l.name];if(c==null)throw new Z(`No value is provided for the model's input ${l.name}`);i.add(l,c)}const a=bm(o,i);return r?a:a[0]}retrieveSymbolicTensors(e){const t=th(null,e.length);let r=e.length;for(const s of this.layers){const o=Array.isArray(s.output)?s.output:[s.output],i=o.map(a=>a.name);for(let a=0;a<e.length;++a){const l=i.indexOf(e[a]);if(l!==-1&&(t[a]=o[l],r--),r===0)break}if(r===0)break}if(r>0){const s=[];throw t.forEach((o,i)=>{o==null&&s.push(e[i])}),new Z(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(s)}`)}return t}predictLoop(e,t=32,r=!1){return me(()=>{const s=this.checkNumSamples(e);if(r)throw new wt("Verbose predictLoop() is not implemented yet.");const o=Db(s,t),i=this.outputs.map(a=>[]);for(let a=0;a<o.length;++a)me(()=>{const c=o[a][0],d=o[a][1],p=gm(e,c,d),m=[];if(Array.isArray(p))for(let v=0;v<p.length;++v)m.push({key:this.inputs[v],value:p[v]});else m.push({key:this.inputs[0],value:p});const y=new eu(m);return bm(this.outputs,y)}).forEach((c,d)=>i[d].push(c));return ks(i.map(a=>Is(a,0)))})}predict(e,t={}){const r=y_(e);k2(r,this.inputNames,this.feedInputShapes,!1);try{const s=t.batchSize==null?32:t.batchSize;return _b(s),this.predictLoop(r,s)}finally{gi(r,e)}}predictOnBatch(e){k2(e,this.inputNames,this.feedInputShapes,!0);const t=(Array.isArray(e)?e[0]:e).shape[0];return this.predictLoop(e,t)}standardizeUserDataXY(e,t,r=!0,s){if(this.optimizer_==null)throw new jo("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");const o=[];for(let i=0;i<this.feedOutputShapes.length;++i){const a=this.feedOutputShapes[i];this.feedLossFns[i]===Jy?o.push(a.slice(0,a.length-1).concat([1])):o.push(a)}if(e=S2(e,this.feedInputNames,this.feedInputShapes,!1,"input"),t=S2(t,this.feedOutputNames,o,!1,"target"),bK(e,t),CK(t,this.feedLossFns,this.feedOutputShapes),this.stateful&&s!=null&&s>0&&e[0].shape[0]%s!==0)throw new Z(`In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size ${s}. Found: ${e[0].shape[0]} sample(s).`);return[e,t]}async standardizeUserData(e,t,r,s,o=!0,i){const[a,l]=this.standardizeUserDataXY(e,t,o,i);if(r!=null)throw new Error("sample weight is not supported yet.");let c=null;if(s!=null){const d=m_(s,this.outputNames);c=[];for(let p=0;p<d.length;++p)c.push(await g_(l[p],null,d[p]))}return[a,l,c]}testLoop(e,t,r,s=0,o){return me(()=>{const i=this.checkNumSamples(t,r,o,"steps"),a=[];if(s>0)throw new wt("Verbose mode is not implemented yet.");if(o!=null)throw new wt("steps mode in testLoop() is not implemented yet");{const l=Db(i,r),c=qs(Ii(0,i));for(let d=0;d<l.length;++d){const p=l[d][0],m=l[d][1],y=zc(c,p,m-p),v=DC(t,y),b=e(v);if(d===0)for(let w=0;w<b.length;++w)a.push(Kt(0));for(let w=0;w<b.length;++w){const k=b[w];a[w]=Pe(a[w],ne(m-p,k))}}for(let d=0;d<a.length;++d)a[d]=st(a[d],i)}return a})}getDedupedMetricsNames(){const e=this.metricsNames,t=[];for(let r=0;r<e.length;++r){const s=e[r];let o=s;if(l2(e,s)>1){const i=l2(e.slice(0,r),s);o+=`_${i}`}t.push(o)}return t}makeTrainFunction(){return e=>{const t=[],r=e.slice(0,this.inputs.length),s=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),o=e.slice(this.inputs.length+this.outputs.length,this.inputs.length+this.outputs.length*2),i=[],a=()=>{const p=[];for(let b=0;b<this.inputs.length;++b)p.push({key:this.inputs[b],value:r[b]});const m=new eu(p),y=bm(this.outputs,m,{training:!0});let v;for(let b=0;b<this.lossFunctions.length;++b){const w=this.lossFunctions[b];let k=w(s[b],y[b]);o[b]!=null&&(k=fK(k,o[b]));const I=Xn(k);t.push(I),b===0?v=k:v=Pe(v,k)}for(let b=0;b<this.metricsTensors.length;++b){let w;if(this.outputs.length>1&&b<this.outputs.length)w=t[b];else{const k=this.metricsTensors[b][0],I=this.metricsTensors[b][1];w=Xn(k(s[I],y[I]))}ha(w),i.push(w)}return v=Xn(v),this.calculateLosses().forEach(b=>{v=Pe(v,b)}),v},l=this.collectedTrainableWeights.map(p=>p.read());return[this.optimizer_.minimize(a,!0,l)].concat(i)}}makeTestFunction(){this.testFunction=e=>me(()=>{const t=[];let r;const s=e.slice(0,this.inputs.length),o=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),i=[];for(let c=0;c<this.inputs.length;++c)i.push({key:this.inputs[c],value:s[c]});const a=new eu(i),l=bm(this.outputs,a);for(let c=0;c<this.lossFunctions.length;++c){const d=this.lossFunctions[c],p=Xn(d(o[c],l[c]));c===0?r=p:r=Pe(r,p),t.push(r)}for(let c=0;c<this.metricsTensors.length;++c){const d=this.metricsTensors[c][0],p=this.metricsTensors[c][1],m=Xn(d(o[p],l[p]));t.push(m)}return t})}async fit(e,t,r={}){if(this.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");this.isTraining=!0;let s,o,i,a,l,c,d,p,m;try{const y=r.batchSize==null?32:r.batchSize;_b(y);const b=await this.standardizeUserData(e,t,r.sampleWeight,r.classWeight,!1,y);s=b[0],o=b[1],m=b[2];let w=!1,k;if(r.validationData!=null&&r.validationData.length>0){if(w=!0,r.validationData.length===2)l=r.validationData[0],c=r.validationData[1];else throw r.validationData.length===3?new wt("validationData including sample weights is not supported yet."):new Z(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${r.validationData} is invalid.`);const L=await this.standardizeUserData(l,c,null,null,!0,y);d=L[0],p=L[1],k=d.concat(p)}else if(r.validationSplit!=null&&r.validationSplit>0&&r.validationSplit<1){w=!0;const z=Math.floor(s[0].shape[0]*(1-r.validationSplit)),L=s[0].shape[0];d=gm(s,z,L),i=s,s=gm(s,0,z),p=gm(o,z,L),a=o,o=gm(o,0,z),k=d.concat(p)}else r.validationSteps!=null&&(w=!0);const I=s.concat(o).concat(m);this.checkTrainableWeightsConsistency();const N=this.makeTrainFunction(),T=this.getDedupedMetricsNames();let A,O;w?(this.makeTestFunction(),A=this.testFunction,O=T.slice().concat(T.map(z=>"val_"+z))):(A=null,k=[],O=T.slice());const P=i_(r.callbacks,r.yieldEvery);return await this.fitLoop(N,I,T,y,r.epochs,r.verbose,P,A,k,r.shuffle,O,r.initialEpoch,null,null)}finally{this.isTraining=!1,gi(s,e),gi(o,t),gi(i,e),gi(a,t),gi(d,l),gi(p,c),m!=null&&kt(m)}}async fitLoop(e,t,r,s,o,i,a,l,c,d,p,m,y,v){s==null&&(s=32),o==null&&(o=1),d==null&&(d=!0),m==null&&(m=0);let b=!1;if(l!=null&&c!=null&&(b=!0),v!=null&&(b=!0,y==null))throw new Z("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");const w=this.checkNumSamples(t,s,y,"steps_per_epoch");let k;w!=null&&(k=Ii(0,w)),i==null&&(i=1);const{callbackList:I,history:N}=a_(a,i,o,m,w,y,s,b,p);I.setModel(this),this.history=N,await I.onTrainBegin(),this.stopTraining_=!1;for(let T=m;T<o;++T){await I.onEpochBegin(T);const A={};if(y!=null)throw new wt("stepsPerEpoch mode is not implemented yet.");{if(d==="batch")throw new wt("batch shuffling is not implemneted yet");d&&W4(k);const O=qs(k),P=Db(w,s);for(let B=0;B<P.length;++B){const z={};if(await I.onBatchBegin(B,z),me(()=>{const L=P[B][0],_=P[B][1],H=zc(O,L,_-L);z.batch=B,z.size=_-L;const Y=DC(t,H),re=e(Y);for(let te=0;te<r.length;++te){const le=r[te],de=re[te];z[le]=de,ha(de)}if(B===P.length-1&&b){const te=this.testLoop(l,c,s);for(let le=0;le<r.length;++le){const de=r[le],j=te[le];ha(j),A["val_"+de]=j}}}),await I.onBatchEnd(B,z),o_(z),this.stopTraining_)break}O.dispose()}if(await I.onEpochEnd(T,A),this.stopTraining_)break}return await I.onTrainEnd(),await this.history.syncData(),this.history}async fitDataset(e,t){return gK(this,e,t)}async trainOnBatch(e,t){const r=await this.standardizeUserData(e,t),s=r[0],o=r[1],a=this.makeTrainFunction()(s.concat(o)),l=[];for(const c of a){const d=await c.data();l.push(d[0])}return kt(a),gi(r[0],e),gi(r[1],t),ks(l)}getNamedWeights(e){const t=[],r=e!=null&&e.trainableOnly,s=r?this.trainableWeights:this.weights,o=this.getWeights(r);for(let i=0;i<s.length;++i)r&&!s[i].trainable||t.push({name:s[i].originalName,tensor:o[i]});return t}set stopTraining(e){this.stopTraining_=e}get stopTraining(){return this.stopTraining_}get optimizer(){return this.optimizer_}set optimizer(e){this.optimizer_!==e&&(this.optimizer_=e,this.isOptimizerOwned=!1)}dispose(){const e=super.dispose();if(e.refCountAfterDispose===0&&this.optimizer!=null&&this.isOptimizerOwned){const t=ON().numTensors;this.optimizer_.dispose(),e.numDisposedVariables+=t-ON().numTensors}return e}getLossIdentifiers(){let e;if(typeof this.loss=="string")e=el(this.loss);else if(Array.isArray(this.loss)){for(const t of this.loss)if(typeof t!="string")throw new Error("Serialization of non-string loss is not supported.");e=this.loss.map(t=>el(t))}else{const t=Object.keys(this.loss);e={};const r=this.loss;for(const s of t)if(typeof r[s]=="string")e[s]=el(r[s]);else throw new Error("Serialization of non-string loss is not supported.")}return e}getMetricIdentifiers(){if(typeof this.metrics=="string"||typeof this.metrics=="function")return[el(ay(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map(e=>el(ay(e)));{const e={};for(const t in this.metrics)e[t]=el(ay(this.metrics[t]));return e}}getTrainingConfig(){return{loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}}}loadTrainingConfig(e){if(e.weighted_metrics!=null)throw new Error("Loading weight_metrics is not supported yet.");if(e.loss_weights!=null)throw new Error("Loading loss_weights is not supported yet.");if(e.sample_weight_mode!=null)throw new Error("Loading sample_weight_mode is not supported yet.");const t=n1(e.optimizer_config),r=ma(t);let s;if(typeof e.loss=="string")s=Ac(e.loss);else if(Array.isArray(e.loss))s=e.loss.map(i=>Ac(i));else if(e.loss!=null){s={};for(const i in e.loss)s[i]=Ac(e.loss[i])}let o;if(Array.isArray(e.metrics))o=e.metrics.map(i=>Ac(i));else if(e.metrics!=null){o={};for(const i in e.metrics)o[i]=Ac(e.metrics[i])}this.compile({loss:s,metrics:o,optimizer:r})}async save(e,t){if(typeof e=="string"){const c=HU(e);if(c.length===0)throw new Z(`Cannot find any save handlers for URL '${e}'`);if(c.length>1)throw new Z(`Found more than one (${c.length}) save handlers for URL '${e}'`);e=c[0]}if(e.save==null)throw new Z("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");const r=await FN(this.getNamedWeights(t)),a={modelTopology:this.toJSON(null,!1),format:kK,generatedBy:`TensorFlow.js tfjs-layers v${p_}`,convertedBy:null};if((t==null?!1:t.includeOptimizer)&&this.optimizer!=null){a.trainingConfig=this.getTrainingConfig();const c="optimizer",{data:d,specs:p}=await FN(await this.optimizer.getWeights(),c);r.specs.push(...p),r.data=MU([r.data,d])}return this.userDefinedMetadata!=null&&(v2(this.userDefinedMetadata,this.name,!0),a.userDefinedMetadata=this.userDefinedMetadata),a.weightData=r.data,a.weightSpecs=r.specs,e.save(a)}setUserDefinedMetadata(e){v2(e,this.name),this.userDefinedMetadata=e}getUserDefinedMetadata(){return this.userDefinedMetadata}}nf.className="Model";_e(nf);class v_ extends nf{}v_.className="Functional";_e(v_);async function IK(n,e){if(e==null&&(e={}),typeof n=="string"){const t=qU(n,e);if(t.length===0)t.push(R5(n,e));else if(t.length>1)throw new Z(`Found more than one (${t.length}) load handlers for URL '${n}'`);n=t[0]}return $K(n,void 0,e)}async function $K(n,e,t){if(t==null&&(t={}),n.load==null)throw new Z("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const r=await n.load();let s=r.modelTopology;s.model_config!=null&&(s=s.model_config);const o=t.strict==null?!0:t.strict,i=r.weightData!=null&&r.weightSpecs!=null&&o,a=ma(n1(s),e,i),l=r.trainingConfig;if(l!=null&&a.loadTrainingConfig(l),r.userDefinedMetadata!=null&&a.setUserDefinedMetadata(r.userDefinedMetadata),r.weightData!=null){if(r.weightSpecs==null)throw new Z("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");const{modelWeights:c,optimizerWeights:d}=NK(r.weightData,r.weightSpecs);a.loadWeights(c,o),a.optimizer!=null&&d.length>0&&await a.optimizer.setWeights(d),kt(c),kt(d.map(p=>p.tensor))}return a}function NK(n,e){const t=_U(n,e),r={},s=[];return e.forEach(o=>{o.group==="optimizer"?s.push({name:o.name,tensor:t[o.name]}):r[o.name]=t[o.name]}),{modelWeights:r,optimizerWeights:s}}class Vm extends nf{constructor(e){if(super({inputs:[],outputs:[]}),e=e||{},this.trainable=!0,this.built=!1,this.name=e.name!=null?e.name:Rv("sequential_"),e.layers!=null)for(const t of e.layers)this.add(t)}checkShape(e){if(e.inboundNodes[0].outputTensors[0].shape.some(r=>r<0))throw new Z(`Negative dimension size caused by adding layer ${e.name} with input shape [${e.inboundNodes[0].inputTensors[0].shape}]`)}add(e){const t=e instanceof Vm||e instanceof nf;let r;if(t){if(r=e,r.outputs.length!==1)throw new Z("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(r.inputs.length!==1)throw new Z("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.")}if(this.outputs.length===0){if(e.inboundNodes.length===0){if(e.batchInputShape==null)throw new Z("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");const s=$q({batchShape:e.batchInputShape,dtype:e.dtype,name:e.name+"_input"});e.apply(s)}if(t)this.outputs=r.outputs,this.inputs=r.inputs;else{if(e.inboundNodes.length!==1)throw new Z(`A layer added to a Sequential model must not already be connected somewhere else. LayersModel received layer ${e.name} which has ${e.inboundNodes.length} pre-existing inbound connections.`);if(e.inboundNodes[0].outputTensors.length!==1)throw new Z("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[e.inboundNodes[0].outputTensors[0]],this.inputs=e_(this.outputs[0])}this.inboundNodes=[],new _v({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:th(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map(s=>s.shape),outputShapes:this.outputs[0].shape})}else{const s=e.apply(this.outputs[0]);if(Array.isArray(s))throw new TypeError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[s],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(e),this.built=!1}pop(){if(this.layers.length===0)throw new TypeError("There are no layers in the model.");if(this.layers.pop(),this.layers.length===0)this.outputs=[],this.inboundNodes=[],this.outboundNodes=[];else{const e=this.layers.length-1;this.layers[e].outboundNodes=[],this.outputs=[this.layers[e].output],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}}call(e,t){return this.model==null&&this.build(),this.model.call(e,t)}build(e){if(Gt(e),this.inputs.length===0||this.outputs.length===0)throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new nf({inputs:this.inputs,outputs:this.outputs[0],name:this.name+"_model"}),this.model.trainable=this.trainable,this.supportsMasking=this.model.supportsMasking,this.inputLayers=this.model.inputLayers,this.inputLayersNodeIndices=this.model.inputLayersNodeIndices,this.inputLayersTensorIndices=this.model.inputLayersTensorIndices,this.outputLayers=this.model.outputLayers,this.outputLayersNodeIndices=this.model.outputLayersNodeIndices,this.outputLayersTensorIndices=this.model.outputLayersTensorIndices,this.nodesByDepth=this.model.nodesByDepth,this.containerNodes=this.model.containerNodes,this.outputNames=this.model.outputNames,this.inputNames=this.model.inputNames,this.built=!0}countParams(){return this.built||this.build(),super.countParams()}summary(e,t,r=console.log){this.built||this.build(),super.summary(e,t,r)}setWeights(e){this.model==null&&this.build(),this.model.setWeights(e)}evaluate(e,t,r={}){if(!this.built)throw new jo("The model needs to be compiled before being used.");return this.model.evaluate(e,t,r)}async evaluateDataset(e,t){if(!this.built)throw new jo("The model needs to be compiled before being used.");return this.model.evaluateDataset(e,t)}predict(e,t={}){return this.model==null&&this.build(),this.model.predict(e,t)}predictOnBatch(e){return this.model==null&&this.build(),this.model.predictOnBatch(e)}compile(e){this.build(),this.model.compile(e),this.optimizer_=this.model.optimizer,this.isOptimizerOwned=this.model.isOptimizerOwned,this.loss=this.model.loss,this.metrics=this.model.metrics,this.metricsTensors=this.model.metricsTensors,this.metricsNames=this.model.metricsNames}get optimizer(){return this.model==null?void 0:this.model.optimizer}set optimizer(e){this.model.optimizer=e}async fit(e,t,r={}){if(!this.built)throw new jo("The model needs to be compiled before being used.");return this.model.fit(e,t,r)}async fitDataset(e,t){if(!this.built)throw new jo("The model needs to be compiled before being used.");return this.model.fitDataset(e,t)}async trainOnBatch(e,t){return this.model.trainOnBatch(e,t)}static fromConfig(e,t,r={},s=!1){let o,i={};if(t instanceof Array){if(t[0].className==null||t[0].className==="Merge")throw new Z("Legacy serialization format not supported yet.");o=t}else U(t.layers!=null,()=>"When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field."),o=t.layers,delete t.layers,i=t;const a=new e(i);if(!(a instanceof Vm))throw new wt(`Sequential.fromConfig called on non-Sequential input: ${a}`);for(const l of o){const d=ma(l,void 0,s);s&&d.setFastWeightInitDuringBuild(!0),a.add(d)}return a}set stopTraining(e){if(this.model==null)throw new Z("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=e}get stopTraining(){if(this.model==null)throw new Z("Cannot get the stopTraining property of a sequential model before it is compiled.");return this.model.stopTraining}getConfig(){const e=[];for(const t of this.layers){const r={};r.className=t.getClassName(),r.config=t.getConfig(),e.push(r)}return{name:this.name,layers:e}}}Vm.className="Sequential";_e(Vm);let qr=class extends Tf{getConfig(){return{}}};class w_ extends qr{apply(e,t=1){return cq(e,t)}}w_.className="elu";_e(w_);class b_ extends qr{apply(e){return PR(e)}}b_.className="selu";_e(b_);class C_ extends qr{apply(e){return uh(e)}}C_.className="relu";_e(C_);class S_ extends qr{apply(e){return me(()=>zm(6,uh(e)))}}S_.className="relu6";_e(S_);class k_ extends qr{apply(e){return e}}k_.className="linear";_e(k_);class I_ extends qr{apply(e){return If(e)}}I_.className="sigmoid";_e(I_);class $_ extends qr{apply(e){return dq(e)}}$_.className="hardSigmoid";_e($_);class N_ extends qr{apply(e){return ex(e)}}N_.className="softplus";_e(N_);class T_ extends qr{apply(e){return hq(e)}}T_.className="softsign";_e(T_);class E_ extends qr{apply(e){return wv(e)}}E_.className="tanh";_e(E_);let II=class extends qr{apply(e,t=-1){return Nk(e,t)}};II.className="softmax";_e(II);class R_ extends qr{apply(e,t=-1){return TR(e,t)}}R_.className="logSoftmax";_e(R_);class A_ extends qr{apply(e){return me(()=>me(()=>{const t=Math.sqrt(2),r=ne(.5,Pe(1,SR(st(e,t))));return ne(e,r)}))}}A_.className="gelu";_e(A_);class __ extends qr{apply(e){return me(()=>ne(.5,ne(e,Pe(1,wv(ne(jr(st(2,Math.PI)),Pe(e,ne(.044715,Jc(e,3)))))))))}}__.className="gelu_new";_e(__);class D_ extends qr{apply(e){return me(()=>ne(e,wv(ex(e))))}}D_.className="mish";_e(D_);class O_ extends qr{apply(e,t=1){return me(()=>ne(If(ne(e,t)),e))}}O_.className="swish";_e(O_);function uu(n){return n.getClassName()}function Ob(n,e={}){return ax(n,Go.getMap().classNameMap,e,"activation")}function cu(n){if(n==null){const e={};return e.className="linear",e.config={},Ob(e)}if(typeof n=="string"){const e={};return e.className=n,e.config={},Ob(e)}else return n instanceof qr?n:Ob(n)}function TK(n){if(n!=null&&typeof n!="object")throw new Error(`Argument to L1L2 regularizer's constructor is expected to be an object, but received: ${n}`)}class F_ extends Tf{}class P_ extends F_{constructor(e){super(),TK(e),this.l1=e==null||e.l1==null?.01:e.l1,this.l2=e==null||e.l2==null?.01:e.l2,this.hasL1=this.l1!==0,this.hasL2=this.l2!==0}apply(e){return me(()=>{let t=gr([1]);return this.hasL1&&(t=Pe(t,rt(ne(this.l1,os(e))))),this.hasL2&&(t=Pe(t,rt(ne(this.l2,ux(e))))),ce(t,[])})}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(e,t){return new e({l1:t.l1,l2:t.l2})}}P_.className="L1L2";_e(P_);const I2={l1l2:"L1L2"};function un(n){return hI(n)}function $2(n,e={}){return ax(n,Go.getMap().classNameMap,e,"regularizer")}function In(n){if(n==null)return null;if(typeof n=="string"){const t={className:n in I2?I2[n]:n,config:{}};return $2(t)}else return n instanceof F_?n:$2(n)}class L_ extends Et{constructor(e){super(e??{}),this.supportsMasking=!0,e!=null&&(this.maxValue=e.maxValue)}call(e,t){e=ft(e);let r=uh(e);return this.maxValue!=null&&(r=wo(r,0,this.maxValue)),r}computeOutputShape(e){return e}getConfig(){const e={maxValue:this.maxValue},t=super.getConfig();return Object.assign(e,t),e}}L_.className="ReLU";_e(L_);class M_ extends Et{constructor(e){super(e??{}),this.DEFAULT_ALPHA=.3,e==null&&(e={}),this.alpha=e.alpha==null?this.DEFAULT_ALPHA:e.alpha}call(e,t){const r=ft(e);return xk(r,this.alpha)}computeOutputShape(e){return e}getConfig(){const e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}}M_.className="LeakyReLU";_e(M_);class z_ extends Et{constructor(e){if(super(e??{}),this.DEFAULT_ALPHA_INITIALIZER="zeros",e==null&&(e={}),this.supportsMasking=!0,this.alphaInitializer=kn(e.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=In(e.alphaRegularizer),this.alphaConstraint=ir(e.alphaConstraint),e.sharedAxes==null)this.sharedAxes=null;else if(Array.isArray(e.sharedAxes))this.sharedAxes=e.sharedAxes;else if(typeof e.sharedAxes=="number")this.sharedAxes=[e.sharedAxes];else throw new Z(`Expected sharedAxes to be a number or an array of numbers, but got ${e.sharedAxes}`)}build(e){e=Gt(e);const t=e.slice(1);if(this.sharedAxes!=null)for(const s of this.sharedAxes)t[s-1]=1;this.alpha=this.addWeight("alpha",t,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);const r={};if(this.sharedAxes!=null)for(let s=1;s<e.length;++s)r[s]=e[s];this.inputSpec=[new rr({ndim:e.length,axes:r})],this.built=!0}call(e,t){return e=ft(e),Sk(e,this.alpha.read())}getConfig(){const e={alphaInitializer:Tn(this.alphaInitializer),alphaRegularizer:un(this.alphaRegularizer),alphaConstraint:or(this.alphaConstraint),sharedAxes:this.sharedAxes},t=super.getConfig();return Object.assign(e,t),e}}z_.className="PReLU";_e(z_);let B_=class extends Et{constructor(e){if(super(e??{}),this.DEFAULT_ALPHA=1,e==null&&(e={}),e.alpha!=null&&e.alpha!==this.DEFAULT_ALPHA)throw new wt(`Non-default alpha value (${e.alpha}) is not supported by the ELU layer yet.`);this.alpha=e.alpha==null?this.DEFAULT_ALPHA:e.alpha}call(e,t){const r=ft(e);return Sv(r)}computeOutputShape(e){return e}getConfig(){const e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}};B_.className="ELU";_e(B_);class U_ extends Et{constructor(e){super(e??{}),this.DEFAULT_THETA=1,e==null&&(e={}),this.theta=e.theta==null?this.DEFAULT_THETA:e.theta}call(e,t){const r=ft(e);return ne(r,Ge(bo(r,this.theta),"float32"))}computeOutputShape(e){return e}getConfig(){const e={theta:this.theta},t=super.getConfig();return Object.assign(e,t),e}}U_.className="ThresholdedReLU";_e(U_);class W_ extends Et{constructor(e){super(e??{}),this.DEFAULT_AXIS=1,e==null&&(e={}),this.softmax=new II().apply,this.axis=e.axis==null?this.DEFAULT_AXIS:e.axis}call(e,t){return me(()=>{let r=ft(e);const s=t.mask;if(s!=null){const o=ne(ut(wu(r.shape),Ge(s,r.dtype)),Kt(-1e9));r=Pe(r,o)}return this.axis instanceof Array?this.axis.length>1?xa(ut(r,ER(r,this.axis,!0))):this.softmax(r,this.axis[0]):this.softmax(r,this.axis)})}computeOutputShape(e){return e}getConfig(){const e={axis:this.axis},t=super.getConfig();return Object.assign(e,t),e}}W_.className="Softmax";_e(W_);function rf(n,e,t){if(typeof n=="number")return th(n,e);if(n.length!==e)throw new Z(`The ${t} argument must be an integer or tuple of ${e} integers. Received: ${n.length} elements.`);for(let r=0;r<e;++r){const s=n[r];if(!iq(s))throw new Z(`The ${t} argument must be an integer or tuple of ${e} integers. Received: ${JSON.stringify(n)} including a non-integer number ${s}`)}return n}function ki(n,e,t,r,s=1){if(n==null)return n;const o=e+(e-1)*(s-1);let i;return t==="same"?i=n:i=n-o+1,Math.floor((i+r-1)/r)}function ia(n,e,t,r){if(n==null)return null;if(r==="valid")n=n*e+lu([t-e,0]);else if(r==="same")n=n*e;else throw new Z(`Unsupport padding mode: ${r}.`);return n}function $I(n,e){return me(()=>(Vn(e),e==="channelsFirst"?Lt(n,[0,2,3,1]):n))}function V_(n,e){return me(()=>(Vn(e),e==="channelsFirst"?Lt(n,[0,2,3,4,1]):n))}function EK(n,e,t,r=1,s="valid",o,i=1){return me(()=>{if(o==null&&(o=$i()),Vn(o),n.shape.length!==3)throw new Z(`The input of a conv1dWithBias operation should be 3, but is ${n.shape.length} instead.`);if(e.shape.length!==3)throw new Z(`The kernel for a conv1dWithBias operation should be 3, but is ${e.shape.length} instead`);if(t!=null&&t.shape.length!==1)throw new Z(`The bias for a conv1dWithBias operation should be 1, but is ${t.shape.length} instead`);if(o==="channelsFirst"&&(n=Lt(n,[0,2,1])),s==="causal")throw new wt("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let a=yR(n,e,r,s==="same"?"same":"valid","NWC",i);return t!=null&&(a=Ei(a,t)),a})}function N2(n,e,t,r=[1,1],s="valid",o,i,a=null){return me(()=>{if(o==null&&(o=$i()),Vn(o),n.rank!==3&&n.rank!==4)throw new Z(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${n.rank}.`);if(e.rank!==3&&e.rank!==4)throw new Z(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${n.rank}.`);let l=$I(n,o);if(s==="causal")throw new wt("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return l=NH({x:l,filter:e,strides:r,pad:s==="same"?"same":"valid",dilations:i,dataFormat:"NHWC",bias:t,activation:a}),o==="channelsFirst"&&(l=Lt(l,[0,3,1,2])),l})}function RK(n,e,t,r=[1,1,1],s="valid",o,i){return me(()=>{if(o==null&&(o=$i()),Vn(o),n.rank!==4&&n.rank!==5)throw new Z(`conv3dWithBias expects input to be of rank 4 or 5, but received ${n.rank}.`);if(e.rank!==4&&e.rank!==5)throw new Z(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${n.rank}.`);let a=V_(n,o);if(s==="causal")throw new wt("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return a=SV(a,e,r,s==="same"?"same":"valid","NDHWC",i),t!=null&&(a=Ei(a,t)),o==="channelsFirst"&&(a=Lt(a,[0,4,1,2,3])),a})}class Fv extends Et{constructor(e,t){if(super(t),this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",Fv.verifyArgs(t),this.rank=e,xr(this.rank,"rank"),this.rank!==1&&this.rank!==2&&this.rank!==3)throw new wt(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=rf(t.kernelSize,e,"kernelSize"),this.strides=rf(t.strides==null?1:t.strides,e,"strides"),this.padding=t.padding==null?"valid":t.padding,Co(this.padding),this.dataFormat=t.dataFormat==null?"channelsLast":t.dataFormat,Vn(this.dataFormat),this.activation=cu(t.activation),this.useBias=t.useBias==null?!0:t.useBias,this.biasInitializer=kn(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=ir(t.biasConstraint),this.biasRegularizer=In(t.biasRegularizer),this.activityRegularizer=In(t.activityRegularizer),this.dilationRate=rf(t.dilationRate==null?1:t.dilationRate,e,"dilationRate"),this.rank===1&&Array.isArray(this.dilationRate)&&this.dilationRate.length!==1)throw new Z(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`);if(this.rank===2){if(typeof this.dilationRate=="number")this.dilationRate=[this.dilationRate,this.dilationRate];else if(this.dilationRate.length!==2)throw new Z(`dilationRate must be a number or array of two numbers for 2D convolution, but received ${JSON.stringify(this.dilationRate)}`)}else if(this.rank===3){if(typeof this.dilationRate=="number")this.dilationRate=[this.dilationRate,this.dilationRate,this.dilationRate];else if(this.dilationRate.length!==3)throw new Z(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`)}}static verifyArgs(e){if(oa("kernelSize"in e,"required key 'kernelSize' not in config"),typeof e.kernelSize!="number"&&!dI(e.kernelSize,"number",1,3))throw new Z(`BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received ${JSON.stringify(e.kernelSize)}.`)}getConfig(){const e={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:uu(this.activation),useBias:this.useBias,biasInitializer:Tn(this.biasInitializer),biasRegularizer:un(this.biasRegularizer),activityRegularizer:un(this.activityRegularizer),biasConstraint:or(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}class Ef extends Fv{constructor(e,t){super(e,t),this.kernel=null,Ef.verifyArgs(t),this.filters=t.filters,xr(this.filters,"filters"),this.kernelInitializer=kn(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=ir(t.kernelConstraint),this.kernelRegularizer=In(t.kernelRegularizer)}build(e){e=Gt(e);const t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null)throw new Z(`The channel dimension of the input should be defined. Found ${e[t]}`);const r=e[t],s=this.kernelSize.concat([r,this.filters]);this.kernel=this.addWeight("kernel",s,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[{ndim:this.rank+2,axes:{[t]:r}}],this.built=!0}call(e,t){return me(()=>{e=ft(e);let r;const s=this.bias==null?null:this.bias.read(),o=zA(this.activation.getClassName());if(o!=null&&this.rank===2)r=N2(e,this.kernel.read(),s,this.strides,this.padding,this.dataFormat,this.dilationRate,o);else{if(this.rank===1)r=EK(e,this.kernel.read(),s,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(this.rank===2)r=N2(e,this.kernel.read(),s,this.strides,this.padding,this.dataFormat,this.dilationRate);else if(this.rank===3)r=RK(e,this.kernel.read(),s,this.strides,this.padding,this.dataFormat,this.dilationRate);else throw new wt("convolutions greater than 3D are not implemented yet.");this.activation!=null&&(r=this.activation.apply(r))}return r})}computeOutputShape(e){e=Gt(e);const t=[],r=this.dataFormat==="channelsLast"?e.slice(1,e.length-1):e.slice(2);for(let o=0;o<r.length;++o){const i=ki(r[o],this.kernelSize[o],this.padding,this.strides[o],typeof this.dilationRate=="number"?this.dilationRate:this.dilationRate[o]);t.push(i)}let s=[e[0]];return this.dataFormat==="channelsLast"?(s=s.concat(t),s.push(this.filters)):(s.push(this.filters),s=s.concat(t)),s}getConfig(){const e={filters:this.filters,kernelInitializer:Tn(this.kernelInitializer),kernelRegularizer:un(this.kernelRegularizer),kernelConstraint:or(this.kernelConstraint)},t=super.getConfig();return Object.assign(e,t),e}static verifyArgs(e){if(!("filters"in e)||typeof e.filters!="number"||e.filters<1)throw new Z(`Convolution layer expected config.filters to be a 'number' > 0 but got ${JSON.stringify(e.filters)}`)}}class fx extends Ef{constructor(e){super(2,e),fx.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!dI(e.kernelSize,"number",1,2))throw new Z(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(e.kernelSize)}.`)}}fx.className="Conv2D";_e(fx);class px extends Ef{constructor(e){super(3,e),px.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!(Array.isArray(e.kernelSize)&&(e.kernelSize.length===1||e.kernelSize.length===3)))throw new Z(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(e.kernelSize)}.`)}}px.className="Conv3D";_e(px);class G_ extends fx{constructor(e){if(super(e),this.inputSpec=[new rr({ndim:4})],this.padding!=="same"&&this.padding!=="valid")throw new Z(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(e=Gt(e),e.length!==4)throw new Z("Input should have rank 4; Received input shape: "+JSON.stringify(e));const t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null)throw new Z("The channel dimension of the inputs should be defined. Found `None`.");const r=e[t],s=this.kernelSize.concat([this.filters,r]);this.kernel=this.addWeight("kernel",s,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new rr({ndim:4,axes:{[t]:r}})],this.built=!0}call(e,t){return me(()=>{let r=ft(e);if(r.shape.length!==4)throw new Z(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${r.shape.length}`);const s=r.shape,o=s[0];let i,a;this.dataFormat==="channelsFirst"?(i=2,a=3):(i=1,a=2);const l=s[i],c=s[a],d=this.kernelSize[0],p=this.kernelSize[1],m=this.strides[0],y=this.strides[1],v=ia(l,m,d,this.padding),b=ia(c,y,p,this.padding),w=[o,v,b,this.filters];this.dataFormat!=="channelsLast"&&(r=Lt(r,[0,2,3,1]));let k=vR(r,this.kernel.read(),w,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(k=Lt(k,[0,3,1,2])),this.bias!=null&&(k=Ei(k,this.bias.read(),this.dataFormat)),this.activation!=null&&(k=this.activation.apply(k)),k})}computeOutputShape(e){e=Gt(e);const t=e.slice();let r,s,o;this.dataFormat==="channelsFirst"?(r=1,s=2,o=3):(r=3,s=1,o=2);const i=this.kernelSize[0],a=this.kernelSize[1],l=this.strides[0],c=this.strides[1];return t[r]=this.filters,t[s]=ia(t[s],l,i,this.padding),t[o]=ia(t[o],c,a,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}G_.className="Conv2DTranspose";_e(G_);class j_ extends px{constructor(e){if(super(e),this.inputSpec=[new rr({ndim:5})],this.padding!=="same"&&this.padding!=="valid")throw new Z(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(e=Gt(e),e.length!==5)throw new Z("Input should have rank 5; Received input shape: "+JSON.stringify(e));const t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null)throw new Z("The channel dimension of the inputs should be defined. Found `None`.");const r=e[t],s=this.kernelSize.concat([this.filters,r]);this.kernel=this.addWeight("kernel",s,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new rr({ndim:5,axes:{[t]:r}})],this.built=!0}call(e,t){return me(()=>{let r=ft(e);if(r.shape.length!==5)throw new Z(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${r.shape.length}`);const s=r.shape,o=s[0];let i,a,l;this.dataFormat==="channelsFirst"?(l=2,i=3,a=4):(l=1,i=2,a=3);const c=s[l],d=s[i],p=s[a],m=this.kernelSize[0],y=this.kernelSize[1],v=this.kernelSize[2],b=this.strides[0],w=this.strides[1],k=this.strides[2],I=ia(c,b,m,this.padding),N=ia(d,w,y,this.padding),T=ia(p,k,v,this.padding),A=[o,I,N,T,this.filters];this.dataFormat!=="channelsLast"&&(r=Lt(r,[0,2,3,4,1]));let O=$V(r,this.kernel.read(),A,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(O=Lt(O,[0,4,1,2,3])),this.bias!==null&&(O=Ei(O,this.bias.read(),this.dataFormat)),this.activation!==null&&(O=this.activation.apply(O)),O})}computeOutputShape(e){e=Gt(e);const t=e.slice();let r,s,o,i;this.dataFormat==="channelsFirst"?(r=1,s=2,o=3,i=4):(r=4,s=1,o=2,i=3);const a=this.kernelSize[0],l=this.kernelSize[1],c=this.kernelSize[2],d=this.strides[0],p=this.strides[1],m=this.strides[2];return t[r]=this.filters,t[s]=ia(t[s],d,a,this.padding),t[o]=ia(t[o],p,l,this.padding),t[i]=ia(t[i],m,c,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}j_.className="Conv3DTranspose";_e(j_);class H_ extends Ef{constructor(e,t){if(super(e,t),this.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",this.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",this.depthwiseKernel=null,this.pointwiseKernel=null,t.filters==null)throw new Z("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(t.kernelInitializer!=null||t.kernelRegularizer!=null||t.kernelConstraint!=null)throw new Z("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(t.padding!=null&&t.padding!=="same"&&t.padding!=="valid")throw new Z(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(t.padding)}`);this.depthMultiplier=t.depthMultiplier==null?1:t.depthMultiplier,this.depthwiseInitializer=kn(t.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=In(t.depthwiseRegularizer),this.depthwiseConstraint=ir(t.depthwiseConstraint),this.pointwiseInitializer=kn(t.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=In(t.pointwiseRegularizer),this.pointwiseConstraint=ir(t.pointwiseConstraint)}build(e){if(e=Gt(e),e.length<this.rank+2)throw new Z(`Inputs to SeparableConv${this.rank}D should have rank ${this.rank+2}, but received input shape: ${JSON.stringify(e)}`);const t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null||e[t]<0)throw new Z(`The channel dimension of the inputs should be defined, but found ${JSON.stringify(e[t])}`);const r=e[t],s=this.kernelSize.concat([r,this.depthMultiplier]),o=[];for(let a=0;a<this.rank;++a)o.push(1);o.push(r*this.depthMultiplier,this.filters);const i=!0;this.depthwiseKernel=this.addWeight("depthwise_kernel",s,"float32",this.depthwiseInitializer,this.depthwiseRegularizer,i,this.depthwiseConstraint),this.pointwiseKernel=this.addWeight("pointwise_kernel",o,"float32",this.pointwiseInitializer,this.pointwiseRegularizer,i,this.pointwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,i,this.biasConstraint):this.bias=null,this.inputSpec=[new rr({ndim:this.rank+2,axes:{[t]:r}})],this.built=!0}call(e,t){return me(()=>{e=ft(e);let r;if(this.rank===1)throw new wt("1D separable convolution is not implemented yet.");return this.rank===2&&(this.dataFormat==="channelsFirst"&&(e=Lt(e,[0,2,3,1])),r=LR(e,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(r=Ei(r,this.bias.read(),this.dataFormat)),this.activation!=null&&(r=this.activation.apply(r)),this.dataFormat==="channelsFirst"&&(r=Lt(r,[0,3,1,2])),r})}getConfig(){const e=super.getConfig();return delete e.rank,delete e.kernelInitializer,delete e.kernelRegularizer,delete e.kernelConstraint,e.depthwiseInitializer=Tn(this.depthwiseInitializer),e.pointwiseInitializer=Tn(this.pointwiseInitializer),e.depthwiseRegularizer=un(this.depthwiseRegularizer),e.pointwiseRegularizer=un(this.pointwiseRegularizer),e.depthwiseConstraint=or(this.depthwiseConstraint),e.pointwiseConstraint=or(this.pointwiseConstraint),e}}H_.className="SeparableConv";class q_ extends H_{constructor(e){super(2,e)}}q_.className="SeparableConv2D";_e(q_);class Pv extends Ef{constructor(e){super(1,e),Pv.verifyArgs(e),this.inputSpec=[{ndim:3}]}getConfig(){const e=super.getConfig();return delete e.rank,delete e.dataFormat,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!dI(e.kernelSize,"number",1,1))throw new Z(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(e.kernelSize)}.`)}}Pv.className="Conv1D";_e(Pv);class K_ extends Et{constructor(e){super(e),typeof e.cropping=="number"?this.cropping=[[e.cropping,e.cropping],[e.cropping,e.cropping]]:typeof e.cropping[0]=="number"?this.cropping=[[e.cropping[0],e.cropping[0]],[e.cropping[1],e.cropping[1]]]:this.cropping=e.cropping,this.dataFormat=e.dataFormat===void 0?"channelsLast":e.dataFormat,this.inputSpec=[{ndim:4}]}computeOutputShape(e){return this.dataFormat==="channelsFirst"?[e[0],e[1],e[2]-this.cropping[0][0]-this.cropping[0][1],e[3]-this.cropping[1][0]-this.cropping[1][1]]:[e[0],e[1]-this.cropping[0][0]-this.cropping[0][1],e[2]-this.cropping[1][0]-this.cropping[1][1],e[3]]}call(e,t){return me(()=>{if(e=ft(e),this.dataFormat==="channelsLast"){const r=iy(e,this.cropping[0][0],e.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return iy(r,this.cropping[1][0],e.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}else{const r=iy(e,this.cropping[0][0],e.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return iy(r,this.cropping[1][0],e.shape[3]-this.cropping[1][1]-this.cropping[1][0],4)}})}getConfig(){const e={cropping:this.cropping,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}K_.className="Cropping2D";_e(K_);class X_ extends Et{constructor(e){super(e),this.DEFAULT_SIZE=[2,2],this.inputSpec=[{ndim:4}],this.size=e.size==null?this.DEFAULT_SIZE:e.size,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Vn(this.dataFormat),this.interpolation=e.interpolation==null?"nearest":e.interpolation,rq(this.interpolation)}computeOutputShape(e){if(this.dataFormat==="channelsFirst"){const t=e[2]==null?null:this.size[0]*e[2],r=e[3]==null?null:this.size[1]*e[3];return[e[0],e[1],t,r]}else{const t=e[1]==null?null:this.size[0]*e[1],r=e[2]==null?null:this.size[1]*e[2];return[e[0],t,r,e[3]]}}call(e,t){return me(()=>{let r=ft(e);const s=r.shape;if(this.dataFormat==="channelsFirst"){r=Lt(r,[0,2,3,1]);const o=this.size[0]*s[2],i=this.size[1]*s[3],a=this.interpolation==="nearest"?nl.resizeNearestNeighbor(r,[o,i]):nl.resizeBilinear(r,[o,i]);return Lt(a,[0,3,1,2])}else{const o=this.size[0]*s[1],i=this.size[1]*s[2];return this.interpolation==="nearest"?nl.resizeNearestNeighbor(r,[o,i]):nl.resizeBilinear(r,[o,i])}})}getConfig(){const e={size:this.size,dataFormat:this.dataFormat,interpolation:this.interpolation},t=super.getConfig();return Object.assign(e,t),e}}X_.className="UpSampling2D";_e(X_);function AK(n,e,t=[1,1],r="valid",s,o){return me(()=>{s==null&&(s=$i()),Vn(s);let i=$I(n,s);if(n.rank!==4)throw new Z(`Input for depthwiseConv2d is required to be 4-D, but is instead ${n.rank}-D`);if(e.rank!==4)throw new Z(`depthwiseKernel is required to be 4-D, but is instead ${e.rank}-D`);return i=fk(i,e,t,r==="same"?"same":"valid","NHWC",o),s==="channelsFirst"&&(i=Lt(i,[0,3,1,2])),i})}class Y_ extends Fv{constructor(e){super(2,e),this.depthwiseKernel=null,this.depthMultiplier=e.depthMultiplier==null?1:e.depthMultiplier,this.depthwiseInitializer=kn(e.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=ir(e.depthwiseConstraint),this.depthwiseRegularizer=In(e.depthwiseRegularizer)}build(e){if(e=Gt(e),e.length<4)throw new Z(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(e)}.`);const t=this.dataFormat==="channelsFirst"?1:3;if(e[t]==null||e[t]<0)throw new Z(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${e[t]}).`);const r=e[t],s=[this.kernelSize[0],this.kernelSize[1],r,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",s,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[r*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return me(()=>{e=ft(e);let r=AK(e,this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(r=Ei(r,this.bias.read(),this.dataFormat)),this.activation!=null&&(r=this.activation.apply(r)),r})}computeOutputShape(e){e=Gt(e);const t=this.dataFormat==="channelsFirst"?e[2]:e[1],r=this.dataFormat==="channelsFirst"?e[3]:e[2],s=this.dataFormat==="channelsFirst"?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,o=ki(t,this.kernelSize[0],this.padding,this.strides[0]),i=ki(r,this.kernelSize[1],this.padding,this.strides[1]);return this.dataFormat==="channelsFirst"?[e[0],s,o,i]:[e[0],o,i,s]}getConfig(){const e=super.getConfig();return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=Tn(this.depthwiseInitializer),e.depthwiseRegularizer=un(this.depthwiseRegularizer),e.depthwiseConstraint=or(this.depthwiseRegularizer),e}}Y_.className="DepthwiseConv2D";_e(Y_);function Q_(n,e,t,r){if(Array.isArray(n)){if(e!=null||t!=null)throw new Z("When inputs is an array, neither initialState or constants should be provided");r!=null&&(t=n.slice(n.length-r,n.length),n=n.slice(0,n.length-r)),n.length>1&&(e=n.slice(1,n.length)),n=n[0]}function s(o){return o==null||Array.isArray(o)?o:[o]}return e=s(e),t=s(t),{inputs:n,initialState:e,constants:t}}function J_(n,e,t,r=!1,s,o,i=!1,a=!1){return me(()=>{const l=e.shape.length;if(l<3)throw new Z(`Input should be at least 3D, but is ${l}D.`);const c=[1,0].concat(Ii(2,l));e=Lt(e,c),i&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),s!=null&&(s=Ge(Ge(s,"bool"),"float32"),s.rank===l-1&&(s=Ss(s,-1)),s=Lt(s,c)),r&&(e=Zc(e,0),s!=null&&(s=Zc(s,0)));const d=[];let p,m=t;const y=e.shape[0],v=eh(e);let b;s!=null&&(b=eh(s));for(let k=0;k<y;++k){const I=v[k],N=me(()=>n(I,m));if(s==null)p=N[0],m=N[1];else{const T=me(()=>{const A=b[k],O=ut(Ko(A),A),P=Pe(ne(N[0],A),ne(m[0],O)),B=m.map((z,L)=>Pe(ne(N[1][L],A),ne(z,O)));return{output:P,newStates:B}});p=T.output,m=T.newStates}a&&d.push(p)}let w;return a&&(w=sl(d,1)),[p,w,m]})}class Cu extends Et{constructor(e){super(e);let t;if(e.cell==null)throw new Z("cell property is missing for the constructor of RNN.");if(Array.isArray(e.cell)?t=new EI({cells:e.cell}):t=e.cell,t.stateSize==null)throw new Z("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");this.cell=t,this.returnSequences=e.returnSequences==null?!1:e.returnSequences,this.returnState=e.returnState==null?!1:e.returnState,this.goBackwards=e.goBackwards==null?!1:e.goBackwards,this._stateful=e.stateful==null?!1:e.stateful,this.unroll=e.unroll==null?!1:e.unroll,this.supportsMasking=!0,this.inputSpec=[new rr({ndim:3})],this.stateSpec=null,this.states_=null,this.numConstants=null,this.keptStates=[]}getStates(){if(this.states_==null){const e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;return Ii(0,e).map(t=>null)}else return this.states_}setStates(e){this.states_=e}computeOutputShape(e){EC(e)&&(e=e[0]),e=e;let t=this.cell.stateSize;Array.isArray(t)||(t=[t]);const r=t[0];let s;if(this.returnSequences?s=[e[0],e[1],r]:s=[e[0],r],this.returnState){const o=[];for(const i of t)o.push([e[0],i]);return[s].concat(o)}else return s}computeMask(e,t){return me(()=>{Array.isArray(t)&&(t=t[0]);const r=this.returnSequences?t:null;if(this.returnState){const s=this.states.map(o=>null);return[r].concat(s)}else return r})}get states(){if(this.states_==null){const e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,t=[];for(let r=0;r<e;++r)t.push(null);return t}else return this.states_}set states(e){this.states_=e}build(e){if(this.numConstants!=null)throw new wt("Constants support is not implemented in RNN yet.");EC(e)&&(e=e[0]),e=e;const t=this.stateful?e[0]:null,r=e.slice(2);this.inputSpec[0]=new rr({shape:[t,null,...r]});const s=[e[0]].concat(e.slice(2));this.cell.build(s);let o;if(Array.isArray(this.cell.stateSize)?o=this.cell.stateSize:o=[this.cell.stateSize],this.stateSpec!=null){if(!Xt(this.stateSpec.map(i=>i.shape[i.shape.length-1]),o))throw new Z(`An initialState was passed that is not compatible with cell.stateSize. Received stateSpec=${this.stateSpec}; However cell.stateSize is ${this.cell.stateSize}`)}else this.stateSpec=o.map(i=>new rr({shape:[null,i]}));this.stateful&&this.resetStates()}resetStates(e,t=!1){me(()=>{if(!this.stateful)throw new sa("Cannot call resetStates() on an RNN Layer that is not stateful.");const r=this.inputSpec[0].shape[0];if(r==null)throw new Z("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(this.states_==null)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(s=>gr([r,s])):this.states_=[gr([r,this.cell.stateSize])];else if(e==null)kt(this.states_),this.keptStates!=null&&(kt(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(s=>gr([r,s])):this.states_[0]=gr([r,this.cell.stateSize]);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new Z(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);t===!0?this.keptStates.push(this.states_.slice()):kt(this.states_);for(let s=0;s<this.states_.length;++s){const o=e[s],i=Array.isArray(this.cell.stateSize)?this.cell.stateSize[s]:this.cell.stateSize,a=[r,i];if(!Xt(o.shape,a))throw new Z(`State ${s} is incompatible with layer ${this.name}: expected shape=${a}, received shape=${o.shape}`);this.states_[s]=o}}this.states_=this.states_.map(s=>ha(s.clone()))})}apply(e,t){let r=t==null?null:t.initialState,s=t==null?null:t.constants;t==null&&(t={});const o=Q_(e,r,s,this.numConstants);e=o.inputs,r=o.initialState,s=o.constants;let i=[],a=[];if(r!=null){t.initialState=r,i=i.concat(r),this.stateSpec=[];for(const c of r)this.stateSpec.push(new rr({shape:c.shape}));a=a.concat(this.stateSpec)}if(s!=null&&(t.constants=s,i=i.concat(s),this.numConstants=s.length),i[0]instanceof va){const c=[e].concat(i),d=this.inputSpec.concat(a),p=this.inputSpec;this.inputSpec=d;const m=super.apply(c,t);return this.inputSpec=p,m}else return super.apply(e,t)}call(e,t){return me(()=>{const r=t==null?null:t.mask,s=t==null?null:t.training;let o=t==null?null:t.initialState;e=ft(e),o==null&&(this.stateful?o=this.states_:o=this.getInitialState(e));const i=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;if(o.length!==i)throw new Z(`RNN Layer has ${i} state(s) but was passed ${o.length} initial state(s).`);this.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");const a={training:s},c=J_((v,b)=>{const w=this.cell.call([v].concat(b),a);return[w[0],w.slice(1)]},e,o,this.goBackwards,r,null,this.unroll,this.returnSequences),d=c[0],p=c[1],m=c[2];this.stateful&&this.resetStates(m,s);const y=this.returnSequences?p:d;return this.returnState?[y].concat(m):y})}getInitialState(e){return me(()=>{let t=gr(e.shape);return t=rt(t,[1,2]),t=lx(t),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map(r=>r>1?NC(t,[1,r]):t):this.cell.stateSize>1?[NC(t,[1,this.cell.stateSize])]:[t]})}get trainableWeights(){return this.trainable?this.cell.trainableWeights:[]}get nonTrainableWeights(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.cell!=null&&this.cell.setFastWeightInitDuringBuild(e)}getConfig(){const e=super.getConfig(),t={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};this.numConstants!=null&&(t.numConstants=this.numConstants);const r=this.cell.getConfig();return this.getClassName()===Cu.className&&(t.cell={className:this.cell.getClassName(),config:r}),Object.assign(Object.assign(Object.assign({},r),e),t)}static fromConfig(e,t,r={}){const s=t.cell,o=ma(s,r);return new e(Object.assign(t,{cell:o}))}}Cu.className="RNN";_e(Cu);class Lv extends Et{}class NI extends Lv{constructor(e){super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=e.units,xr(this.units,"units"),this.activation=cu(e.activation==null?this.DEFAULT_ACTIVATION:e.activation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=kn(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=kn(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=kn(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=In(e.kernelRegularizer),this.recurrentRegularizer=In(e.recurrentRegularizer),this.biasRegularizer=In(e.biasRegularizer),this.kernelConstraint=ir(e.kernelConstraint),this.recurrentConstraint=ir(e.recurrentConstraint),this.biasConstraint=ir(e.biasConstraint),this.dropout=hf([1,lu([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=hf([1,lu([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=Gt(e),this.kernel=this.addWeight("kernel",[e[e.length-1],this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return me(()=>{if(e=e,e.length!==2)throw new Z(`SimpleRNNCell expects 2 input Tensors, got ${e.length}.`);let r=e[1];e=e[0];const s=t.training==null?!1:t.training;0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=hu({ones:()=>Ko(e),rate:this.dropout,training:s,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=hu({ones:()=>Ko(r),rate:this.recurrentDropout,training:s,dropoutFunc:this.dropoutFunc}));let o;const i=this.dropoutMask,a=this.recurrentDropoutMask;i!=null?o=pa(ne(e,i),this.kernel.read()):o=pa(e,this.kernel.read()),this.bias!=null&&(o=Ei(o,this.bias.read())),a!=null&&(r=ne(r,a));let l=Pe(o,pa(r,this.recurrentKernel.read()));return this.activation!=null&&(l=this.activation.apply(l)),[l,l]})}getConfig(){const e=super.getConfig(),t={units:this.units,activation:uu(this.activation),useBias:this.useBias,kernelInitializer:Tn(this.kernelInitializer),recurrentInitializer:Tn(this.recurrentInitializer),biasInitializer:Tn(this.biasInitializer),kernelRegularizer:un(this.kernelRegularizer),recurrentRegularizer:un(this.recurrentRegularizer),biasRegularizer:un(this.biasRegularizer),activityRegularizer:un(this.activityRegularizer),kernelConstraint:or(this.kernelConstraint),recurrentConstraint:or(this.recurrentConstraint),biasConstraint:or(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign(Object.assign({},e),t)}}NI.className="SimpleRNNCell";_e(NI);class Z_ extends Cu{constructor(e){e.cell=new NI(e),super(e)}call(e,t){return me(()=>{this.cell.dropoutMask!=null&&(kt(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(kt(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const r=t==null?null:t.mask,s=t==null?null:t.training,o=t==null?null:t.initialState;return super.call(e,{mask:r,training:s,initialState:o})})}static fromConfig(e,t){return new e(t)}}Z_.className="SimpleRNN";_e(Z_);class TI extends Lv{constructor(e){if(super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",e.resetAfter)throw new Z("GRUCell does not support reset_after parameter set to true.");this.units=e.units,xr(this.units,"units"),this.activation=cu(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=cu(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=kn(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=kn(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=kn(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=In(e.kernelRegularizer),this.recurrentRegularizer=In(e.recurrentRegularizer),this.biasRegularizer=In(e.biasRegularizer),this.kernelConstraint=ir(e.kernelConstraint),this.recurrentConstraint=ir(e.recurrentConstraint),this.biasConstraint=ir(e.biasConstraint),this.dropout=hf([1,lu([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=hf([1,lu([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=Gt(e);const t=e[e.length-1];this.kernel=this.addWeight("kernel",[t,this.units*3],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units*3],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units*3],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return me(()=>{if(e=e,e.length!==2)throw new Z(`GRUCell expects 2 input Tensors (inputs, h, c), got ${e.length}.`);const r=t.training==null?!1:t.training;let s=e[1];e=e[0],0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=hu({ones:()=>Ko(e),rate:this.dropout,training:r,count:3,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=hu({ones:()=>Ko(s),rate:this.recurrentDropout,training:r,count:3,dropoutFunc:this.dropoutFunc}));const o=this.dropoutMask,i=this.recurrentDropoutMask;let a,l,c;0<this.dropout&&this.dropout<1&&(e=ne(e,o[0]));let d=pa(e,this.kernel.read());this.useBias&&(d=Ei(d,this.bias.read())),0<this.recurrentDropout&&this.recurrentDropout<1&&(s=ne(s,i[0]));const p=this.recurrentKernel.read(),[m,y]=yo(p,[2*this.units,this.units],p.rank-1),v=pa(s,m),[b,w,k]=yo(d,3,d.rank-1),[I,N]=yo(v,2,v.rank-1);a=this.recurrentActivation.apply(Pe(b,I)),l=this.recurrentActivation.apply(Pe(w,N));const T=pa(ne(l,s),y);c=this.activation.apply(Pe(k,T));const A=Pe(ne(a,s),ne(Pe(1,zn(a)),c));return[A,A]})}getConfig(){const e=super.getConfig(),t={units:this.units,activation:uu(this.activation),recurrentActivation:uu(this.recurrentActivation),useBias:this.useBias,kernelInitializer:Tn(this.kernelInitializer),recurrentInitializer:Tn(this.recurrentInitializer),biasInitializer:Tn(this.biasInitializer),kernelRegularizer:un(this.kernelRegularizer),recurrentRegularizer:un(this.recurrentRegularizer),biasRegularizer:un(this.biasRegularizer),activityRegularizer:un(this.activityRegularizer),kernelConstraint:or(this.kernelConstraint),recurrentConstraint:or(this.recurrentConstraint),biasConstraint:or(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation,resetAfter:!1};return Object.assign(Object.assign({},e),t)}}TI.className="GRUCell";_e(TI);class eD extends Cu{constructor(e){e.implementation===0&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),e.cell=new TI(e),super(e)}call(e,t){return me(()=>{this.cell.dropoutMask!=null&&(kt(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(kt(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const r=t==null?null:t.mask,s=t==null?null:t.training,o=t==null?null:t.initialState;return super.call(e,{mask:r,training:s,initialState:o})})}static fromConfig(e,t){return t.implmentation===0&&(t.implementation=1),new e(t)}}eD.className="GRU";_e(eD);class Mv extends Lv{constructor(e){super(e),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=e.units,xr(this.units,"units"),this.activation=cu(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=cu(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=kn(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=kn(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=kn(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=e.unitForgetBias,this.kernelRegularizer=In(e.kernelRegularizer),this.recurrentRegularizer=In(e.recurrentRegularizer),this.biasRegularizer=In(e.biasRegularizer),this.kernelConstraint=ir(e.kernelConstraint),this.recurrentConstraint=ir(e.recurrentConstraint),this.biasConstraint=ir(e.biasConstraint),this.dropout=hf([1,lu([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=hf([1,lu([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=[this.units,this.units],this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){var t;e=Gt(e);const r=e[e.length-1];this.kernel=this.addWeight("kernel",[r,this.units*4],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units*4],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint);let s;if(this.useBias){if(this.unitForgetBias){const o=this.biasInitializer,i=this.units;s=new(t=class extends Yo{apply(l,c){const d=o.apply([i]),p=new pI().apply([i]),m=o.apply([i*2]);return c2(c2(d,p),m)}},t.className="CustomInit",t)}else s=this.biasInitializer;this.bias=this.addWeight("bias",[this.units*4],null,s,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0}call(e,t){return me(()=>{const r=t.training==null?!1:t.training;if(e=e,e.length!==3)throw new Z(`LSTMCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);let s=e[1];const o=e[2];e=e[0],0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=hu({ones:()=>Ko(e),rate:this.dropout,training:r,count:4,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=hu({ones:()=>Ko(s),rate:this.recurrentDropout,training:r,count:4,dropoutFunc:this.dropoutFunc}));const i=this.dropoutMask,a=this.recurrentDropoutMask;let l,c,d,p;0<this.dropout&&this.dropout<1&&(e=ne(e,i[0]));let m=pa(e,this.kernel.read());0<this.recurrentDropout&&this.recurrentDropout<1&&(s=ne(s,a[0])),m=Pe(m,pa(s,this.recurrentKernel.read())),this.useBias&&(m=Ei(m,this.bias.read()));const[y,v,b,w]=yo(m,4,m.rank-1);l=this.recurrentActivation.apply(y),c=this.recurrentActivation.apply(v),d=Pe(ne(c,o),ne(l,this.activation.apply(b))),p=this.recurrentActivation.apply(w);const k=ne(p,this.activation.apply(d));return[k,k,d]})}getConfig(){const e=super.getConfig(),t={units:this.units,activation:uu(this.activation),recurrentActivation:uu(this.recurrentActivation),useBias:this.useBias,kernelInitializer:Tn(this.kernelInitializer),recurrentInitializer:Tn(this.recurrentInitializer),biasInitializer:Tn(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:un(this.kernelRegularizer),recurrentRegularizer:un(this.recurrentRegularizer),biasRegularizer:un(this.biasRegularizer),activityRegularizer:un(this.activityRegularizer),kernelConstraint:or(this.kernelConstraint),recurrentConstraint:or(this.recurrentConstraint),biasConstraint:or(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation};return Object.assign(Object.assign({},e),t)}}Mv.className="LSTMCell";_e(Mv);class tD extends Cu{constructor(e){e.implementation===0&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),e.cell=new Mv(e),super(e)}call(e,t){return me(()=>{this.cell.dropoutMask!=null&&(kt(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(kt(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const r=t==null?null:t.mask,s=t==null?null:t.training,o=t==null?null:t.initialState;return super.call(e,{mask:r,training:s,initialState:o})})}static fromConfig(e,t){return t.implmentation===0&&(t.implementation=1),new e(t)}}tD.className="LSTM";_e(tD);class EI extends Lv{constructor(e){super(e),this.cells=e.cells}get stateSize(){const e=[];for(const t of this.cells.slice().reverse())Array.isArray(t.stateSize)?e.push(...t.stateSize):e.push(t.stateSize);return e}call(e,t){return me(()=>{e=e;let r=e.slice(1);const s=[];for(const a of this.cells.slice().reverse())Array.isArray(a.stateSize)?s.push(r.splice(0,a.stateSize.length)):s.push(r.splice(0,1));s.reverse();const o=[];let i;for(let a=0;a<this.cells.length;++a){const l=this.cells[a];r=s[a],a===0?i=[e[0]].concat(r):i=[i[0]].concat(r),i=l.call(i,t),o.push(i.slice(1))}r=[];for(const a of o.slice().reverse())r.push(...a);return[i[0]].concat(r)})}build(e){EC(e)&&(e=e[0]),e=e;let t;this.cells.forEach((r,s)=>{Mc(`RNNCell_${s}`,()=>{r.build(e),Array.isArray(r.stateSize)?t=r.stateSize[0]:t=r.stateSize,e=[e[0],t]})}),this.built=!0}getConfig(){const e=super.getConfig(),t=o=>({className:o.getClassName(),config:o.getConfig()}),s={cells:this.cells.map(t)};return Object.assign(Object.assign({},e),s)}static fromConfig(e,t,r={}){const s=[];for(const o of t.cells)s.push(ma(o,r));return new e({cells:s})}get trainableWeights(){if(!this.trainable)return[];const e=[];for(const t of this.cells)e.push(...t.trainableWeights);return e}get nonTrainableWeights(){const e=[];for(const t of this.cells)e.push(...t.nonTrainableWeights);if(!this.trainable){const t=[];for(const r of this.cells)t.push(...r.trainableWeights);return t.concat(e)}return e}getWeights(){const e=[];for(const t of this.cells)e.push(...t.weights);return RC(e)}setWeights(e){const t=[];for(const r of this.cells){const s=r.weights.length,o=e.splice(s);for(let i=0;i<r.weights.length;++i)t.push([r.weights[i],o[i]])}bI(t)}}EI.className="StackedRNNCells";_e(EI);function hu(n){const{ones:e,rate:t,training:r=!1,count:s=1,dropoutFunc:o}=n,i=()=>o!=null?o(e(),t):HA(e(),t),a=()=>cx(i,e,r);return!s||s<=1?ha(a().clone()):Array(s).fill(void 0).map(a).map(c=>ha(c.clone()))}var _K=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t};class nD extends Cu{constructor(e){if(e.unroll)throw new wt("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(e.cell))throw new wt("It is not possible at the moment to stack convolutional cells.");super(e),this.inputSpec=[new rr({ndim:5})]}call(e,t){return me(()=>{if(this.cell.dropoutMask!=null&&(kt(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(kt(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),t&&t.constants)throw new Z("ConvRNN2D cell does not support constants");const r=t==null?null:t.mask,s=t==null?null:t.training,o=t==null?null:t.initialState;return super.call(e,{mask:r,training:s,initialState:o})})}computeOutputShape(e){let t=this.computeSingleOutputShape(e);return this.returnSequences||(t=[t[0],...t.slice(2)]),this.returnState&&(t=[t,...Array(2).fill([e[0],...t.slice(-3)])]),t}getInitialState(e){return me(()=>{const{stateSize:t}=this.cell,r=e.shape,s=this.computeSingleOutputShape(r),o=[s[0],...s.slice(2)],i=gr(o);return Array.isArray(t)?Array(t.length).fill(i):[i]})}resetStates(e,t=!1){me(()=>{if(!this.stateful)throw new sa("Cannot call resetStates() on an RNN Layer that is not stateful.");const r=this.inputSpec[0].shape,s=this.computeSingleOutputShape(r),o=[s[0],...s.slice(2)];if(r[0]==null)throw new Z("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(this.getStates()==null)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>gr(o)):this.states_=[gr(o)];else if(e==null)kt(this.states_),this.keptStates!=null&&(kt(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>gr(o)):this.states_[0]=gr(o);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new Z(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);t?this.keptStates.push(this.states_.slice()):kt(this.states_);for(let a=0;a<this.states_.length;++a){const l=e[a],c=o;if(!Xt(l.shape,c))throw new Z(`State ${a} is incompatible with layer ${this.name}: expected shape=${c}, received shape=${l.shape}`);this.states_[a]=l}}this.states_=this.states_.map(a=>ha(a.clone()))})}computeSingleOutputShape(e){const{dataFormat:t,filters:r,kernelSize:s,padding:o,strides:i,dilationRate:a}=this.cell,l=t==="channelsFirst",c=e[l?3:2],d=e[l?4:3],p=ki(c,s[0],o,i[0],a[0]),m=ki(d,s[1],o,i[1],a[1]);return[...e.slice(0,2),...l?[r,p,m]:[p,m,r]]}}nD.className="ConvRNN2D";class RI extends Mv{constructor(e){const{filters:t,kernelSize:r,strides:s,padding:o,dataFormat:i,dilationRate:a}=e;super(Object.assign(Object.assign({},e),{units:t})),this.filters=t,xr(this.filters,"filters"),this.kernelSize=rf(r,2,"kernelSize"),this.kernelSize.forEach(l=>xr(l,"kernelSize")),this.strides=rf(s||1,2,"strides"),this.strides.forEach(l=>xr(l,"strides")),this.padding=o||"valid",Co(this.padding),this.dataFormat=i||"channelsLast",Vn(this.dataFormat),this.dilationRate=rf(a||1,2,"dilationRate"),this.dilationRate.forEach(l=>xr(l,"dilationRate"))}build(e){var t;e=Gt(e);const r=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[r]==null)throw new Z(`The channel dimension of the input should be defined. Found ${e[r]}`);const s=e[r],o=4,i=this.kernelSize.concat([s,this.filters*o]);this.kernel=this.addWeight("kernel",i,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);const a=this.kernelSize.concat([this.filters,this.filters*o]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",a,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let l;if(this.unitForgetBias){const c=this.biasInitializer,d=this.filters;l=new(t=class extends Yo{apply(m,y){const v=c.apply([d]),b=wu([d]),w=c.apply([d*2]);return fI([v,b,w])}},t.className="CustomInit",t)}else l=this.biasInitializer;this.bias=this.addWeight("bias",[this.filters*o],null,l,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(e,t){return me(()=>{if(e.length!==3)throw new Z(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);const r=t.training||!1,s=e[0],o=e[1],i=e[2],a=4;0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=hu({ones:()=>Ko(s),rate:this.dropout,training:r,count:a,dropoutFunc:this.dropoutFunc}));const l=this.dropoutMask,c=(se,V,X)=>!V||!V[X]?se:ne(V[X],se);let d=c(s,l,0),p=c(s,l,1),m=c(s,l,2),y=c(s,l,3);0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=hu({ones:()=>Ko(o),rate:this.recurrentDropout,training:r,count:a,dropoutFunc:this.dropoutFunc}));const v=this.recurrentDropoutMask;let b=c(o,v,0),w=c(o,v,1),k=c(o,v,2),I=c(o,v,3);const N=3,[T,A,O,P]=yo(this.kernel.read(),a,N),[B,z,L,_]=this.useBias?yo(this.bias.read(),a):[null,null,null,null];d=this.inputConv(d,T,B,this.padding),p=this.inputConv(p,A,z,this.padding),m=this.inputConv(m,O,L,this.padding),y=this.inputConv(y,P,_,this.padding);const[H,Y,re,te]=yo(this.recurrentKernel.read(),a,N);b=this.recurrentConv(b,H),w=this.recurrentConv(w,Y),k=this.recurrentConv(k,re),I=this.recurrentConv(I,te);const le=this.recurrentActivation.apply(Pe(d,b)),de=this.recurrentActivation.apply(Pe(p,w)),j=Pe(ne(de,i),ne(le,this.activation.apply(Pe(m,k)))),ie=ne(this.recurrentActivation.apply(Pe(y,I)),this.activation.apply(j));return[ie,ie,j]})}getConfig(){const e=super.getConfig(),{units:t}=e,r=_K(e,["units"]),s={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return Object.assign(Object.assign({},r),s)}inputConv(e,t,r,s){const o=Qc(e,t,this.strides,s||"valid",this.dataFormat==="channelsFirst"?"NCHW":"NHWC",this.dilationRate);return r?Ei(o,r,this.dataFormat):o}recurrentConv(e,t){return Qc(e,t,1,"same",this.dataFormat==="channelsFirst"?"NCHW":"NHWC")}}RI.className="ConvLSTM2DCell";_e(RI);class rD extends nD{constructor(e){const t=new RI(e);super(Object.assign(Object.assign({},e),{cell:t}))}static fromConfig(e,t){return new e(t)}}rD.className="ConvLSTM2D";_e(rD);class AI extends Et{constructor(e){super(e),this.rate=Math.max(Math.min(e.rate,1),0),this.noiseShape=e.noiseShape,this.seed=e.seed,this.supportsMasking=!0}getNoiseShape(e){if(this.noiseShape==null)return this.noiseShape;const t=e.shape,r=[];for(let s=0;s<this.noiseShape.length;++s)r.push(this.noiseShape[s]==null?t[s]:this.noiseShape[s]);return r}call(e,t){return me(()=>{this.invokeCallHook(e,t);const r=ft(e);if(0<this.rate&&this.rate<1){const s=t.training==null?!1:t.training,o=this.getNoiseShape(r);return cx(()=>HA(r,this.rate,o,this.seed),()=>r,s)}return e})}getConfig(){const e={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},t=super.getConfig();return Object.assign(e,t),e}dispose(){return super.dispose()}}AI.className="Dropout";_e(AI);class sD extends AI{constructor(e){super(e),this.inputSpec=[{ndim:3}]}getNoiseShape(e){const t=e.shape;return[t[0],1,t[2]]}}sD.className="SpatialDropout1D";_e(sD);class oD extends Et{constructor(e){if(super(e),this.activation=null,this.useBias=!0,this.kernel=null,this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",e.batchInputShape==null&&e.inputShape==null&&e.inputDim!=null){let t=null;e.batchSize!=null&&(t=e.batchSize),this.batchInputShape=[t,e.inputDim]}this.units=e.units,xr(this.units,"units"),this.activation=cu(e.activation),e.useBias!=null&&(this.useBias=e.useBias),this.kernelInitializer=kn(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=kn(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=ir(e.kernelConstraint),this.biasConstraint=ir(e.biasConstraint),this.kernelRegularizer=In(e.kernelRegularizer),this.biasRegularizer=In(e.biasRegularizer),this.activityRegularizer=In(e.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(e){e=Gt(e);const t=e[e.length-1];this.kernel==null&&(this.kernel=this.addWeight("kernel",[t,this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint))),this.inputSpec=[{minNDim:2,axes:{[-1]:t}}],this.built=!0}computeOutputShape(e){e=Gt(e);const t=e.slice();return t[t.length-1]=this.units,t}call(e,t){return me(()=>{this.invokeCallHook(e,t);const r=ft(e),s=zA(this.activation.getClassName());let o;return s!=null?o=pa(r,this.kernel.read(),s,this.bias?this.bias.read():null):(o=pa(r,this.kernel.read()),this.bias!=null&&(o=Ei(o,this.bias.read())),this.activation!=null&&(o=this.activation.apply(o))),o})}getConfig(){const e={units:this.units,activation:uu(this.activation),useBias:this.useBias,kernelInitializer:Tn(this.kernelInitializer),biasInitializer:Tn(this.biasInitializer),kernelRegularizer:un(this.kernelRegularizer),biasRegularizer:un(this.biasRegularizer),activityRegularizer:un(this.activityRegularizer),kernelConstraint:or(this.kernelConstraint),biasConstraint:or(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}oD.className="Dense";_e(oD);class iD extends Et{constructor(e){e=e||{},super(e),this.inputSpec=[{minNDim:3}],this.dataFormat=e.dataFormat}computeOutputShape(e){e=Gt(e);for(const t of e.slice(1))if(t==null)throw new Z(`The shape of the input to "Flatten" is not fully defined (got ${e.slice(1)}). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.`);return[e[0],iu(e,1)]}call(e,t){return me(()=>{this.invokeCallHook(e,t);let r=ft(e);if(this.dataFormat==="channelsFirst"&&r.rank>1){const s=[0];for(let o=2;o<r.rank;++o)s.push(o);s.push(1),r=Lt(r,s)}return uq(r)})}getConfig(){const e={};this.dataFormat!=null&&(e.dataFormat=this.dataFormat);const t=super.getConfig();return Object.assign(e,t),e}}iD.className="Flatten";_e(iD);class aD extends Et{constructor(e){super(e),this.supportsMasking=!0,this.activation=cu(e.activation)}call(e,t){return me(()=>{this.invokeCallHook(e,t);const r=ft(e);return this.activation.apply(r)})}getConfig(){const e={activation:uu(this.activation)},t=super.getConfig();return Object.assign(e,t),e}}aD.className="Activation";_e(aD);class lD extends Et{constructor(e){super(e),this.n=e.n,this.inputSpec=[{ndim:2}]}computeOutputShape(e){return[e[0],this.n,e[1]]}call(e,t){return me(()=>(e=ft(e),aq(e,this.n)))}getConfig(){const e={n:this.n},t=super.getConfig();return Object.assign(e,t),e}}lD.className="RepeatVector";_e(lD);class uD extends Et{constructor(e){super(e),this.targetShape=e.targetShape;for(let t=0;t<this.targetShape.length;++t)this.isUnknown(this.targetShape[t])&&(this.targetShape[t]=null)}isUnknown(e){return e<0||e==null}fixUnknownDimension(e,t){const r="Total size of new array must be unchanged.",s=t.slice();let o=1,i=null;for(let l=0;l<s.length;++l){const c=s[l];if(this.isUnknown(c))if(i===null)i=l;else throw new Z("Can only specifiy one unknown dimension.");else o*=c}const a=iu(e);if(i!==null){if(o===0||a%o!==0)throw new Z(r);s[i]=a/o}else if(a!==o)throw new Z(r);return s}computeOutputShape(e){let t=!1;for(let r=0;r<e.length;++r)if(this.isUnknown(e[r])){t=!0;break}return t?e.slice(0,1).concat(this.targetShape):e.slice(0,1).concat(this.fixUnknownDimension(e.slice(1),this.targetShape))}call(e,t){return me(()=>{this.invokeCallHook(e,t);const r=ft(e),s=r.shape,o=s.slice(0,1).concat(this.fixUnknownDimension(s.slice(1),this.targetShape));return ce(r,o)})}getConfig(){const e={targetShape:this.targetShape},t=super.getConfig();return Object.assign(e,t),e}}uD.className="Reshape";_e(uD);class cD extends Et{constructor(e){if(super(e),e.dims==null)throw new Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(e.dims))throw new Error(`Permute constructor requires \`dims\` to be an Array, but received ${e.dims} instead.`);const t=Ii(1,e.dims.length+1);if(!Xt(e.dims.slice().sort(),t))throw new Error("Invalid permutation `dims`: "+JSON.stringify(e.dims)+" `dims` must contain consecutive integers starting from 1.");this.dims=e.dims,this.dimsIncludingBatch=[0].concat(this.dims),this.inputSpec=[new rr({ndim:this.dims.length+1})]}computeOutputShape(e){e=Gt(e);const t=e.slice();return this.dims.forEach((r,s)=>{t[s+1]=e[r]}),t}call(e,t){return Lt(ft(e),this.dimsIncludingBatch)}getConfig(){const e={dims:this.dims},t=super.getConfig();return Object.assign(e,t),e}}cD.className="Permute";_e(cD);class hD extends Et{constructor(e){super(e??{}),this.supportsMasking=!0,e!=null?this.maskValue=e.maskValue==null?0:e.maskValue:this.maskValue=0}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={maskValue:this.maskValue};return Object.assign(t,e),t}computeMask(e,t){const r=ft(e);return wC(Gy(r,this.maskValue),-1)}call(e,t){return me(()=>{this.invokeCallHook(e,t);const r=ft(e),i=wC(Gy(r,this.maskValue),-1,!0);return ne(r,Ge(i,r.dtype))})}}hD.className="Masking";_e(hD);class dD extends Et{constructor(e){if(super(e),this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",e.batchInputShape==null&&e.inputShape==null){let t=null;e.batchSize!=null&&(t=e.batchSize),e.inputLength==null?this.batchInputShape=[t,null]:this.batchInputShape=[t].concat(rn(e.inputLength))}this.inputDim=e.inputDim,xr(this.inputDim,"inputDim"),this.outputDim=e.outputDim,xr(this.outputDim,"outputDim"),this.embeddingsInitializer=kn(e.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=In(e.embeddingsRegularizer),this.activityRegularizer=In(e.activityRegularizer),this.embeddingsConstraint=ir(e.embeddingsConstraint),this.maskZero=e.maskZero,this.supportsMasking=e.maskZero,this.inputLength=e.inputLength}build(e){this.embeddings=this.addWeight("embeddings",[this.inputDim,this.outputDim],this.dtype,this.embeddingsInitializer,this.embeddingsRegularizer,!0,this.embeddingsConstraint),this.built=!0}warnOnIncompatibleInputShape(e){}computeMask(e,t){return me(()=>this.maskZero?(e=ft(e),Gy(e,Mt(e))):null)}computeOutputShape(e){if(e=Gt(e),this.inputLength==null)return[...e,this.outputDim];const t=rn(this.inputLength);if(t.length!==e.length-1)throw new Z(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);{let r=0;for(let s=0;s<t.length;++s){const o=t[s],i=e[s+1];if(o!=null&&i!=null&&o!==i)throw new Z(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);o==null&&(t[r]=i),r++}}return[e[0],...t,this.outputDim]}call(e,t){return me(()=>{this.invokeCallHook(e,t);let r=ft(e);r.dtype!=="int32"&&(r=fa(r,"int32"));const s=jA(this.embeddings.read(),ce(r,[r.size]));return ce(s,Gt(this.computeOutputShape(r.shape)))})}getConfig(){const e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:Tn(this.embeddingsInitializer),embeddingsRegularizer:un(this.embeddingsRegularizer),activityRegularizer:un(this.activityRegularizer),embeddingsConstraint:or(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},t=super.getConfig();return Object.assign(e,t),e}}dD.className="Embedding";_e(dD);class dh extends Et{constructor(e){super(e||{}),this.supportsMasking=!0}mergeFunction(e){throw new wt}computeElementwiseOpOutputShape(e,t){if(e==null||t==null)return null;if(e.length<t.length)return this.computeElementwiseOpOutputShape(t,e);if(t.length===0)return e;const r=e.slice(0,e.length-t.length);for(let s=0;s<t.length;++s){const o=e[e.length-t.length+s],i=t[s];if(o==null||i==null||o<0||i<0)r.push(null);else if(o===1)r.push(i);else if(i===1)r.push(o);else{if(o!==i)throw new Z("Operands could not be broadcast together with shapes "+JSON.stringify(e)+" "+JSON.stringify(t));r.push(o)}}return r}build(e){if(Array.isArray(e)&&!Array.isArray(e[0])&&(e=[Gt(e)]),e=e,e.length<2)throw new Z(`A merge layer should be called on an Array of at least 2 inputs. Got ${e.length} input(s).`);let t=[];for(const o of e)o!=null&&o[0]!==null&&t.push(o[0]);if(t=ou(t),t.length>1)throw new Z(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(e)}.`);let r=e[0]==null?null:e[0].slice(1);for(let o=1;o<e.length;++o){const i=e[o]==null?null:e[o].slice(1);r=this.computeElementwiseOpOutputShape(r,i)}const s=e.map(o=>o.length);e.indexOf(null)===-1&&ou(s).length===1?this.reshapeRequired=!1:this.reshapeRequired=!0}call(e,t){return me(()=>{if(e=e,this.reshapeRequired){const r=[],s=e.map(o=>o.rank);if(s.indexOf(null)===-1){const o=lu(s);for(let i of e){const a=i.rank;for(let l=0;l<o-a;++l)i=lx(i,1);r.push(i)}return this.mergeFunction(r)}else{let o=!1;for(const l of e){const c=l.rank;if(c==null){const d=l.shape,p=d[0],m=d.slice(1).concat([p]);let y=ce(l,[p].concat(iu(d.slice(1))));y=Lt(y,[1,0]),y=ce(y,m),r.push(y),o=!0}else if(c>1){const d=Ii(1,c).concat([0]);r.push(Lt(l,d)),o=!0}else r.push(l)}let i=this.mergeFunction(r);const a=i.rank;if(o){if(a==null){const l=i.shape,c=l.length,d=l[c-1],p=[d].concat(l.slice(0,l.length-1));i=ce(Lt(ce(i,[-1,d]),[1,0]),p)}else if(a>1){const l=[a-1].concat(Ii(0,a-1));i=Lt(i,l)}}return i}}else return this.mergeFunction(e)})}computeOutputShape(e){e=e;let t;e[0]==null?t=null:t=e[0].slice(1);for(let s=1;s<e.length;++s){const o=e[s]==null?null:e[s].slice(1);t=this.computeElementwiseOpOutputShape(t,o)}let r=[];for(const s of e)s!=null&&s[0]!==null&&r.push(s[0]);return r=ou(r),r.length===1?t=r.concat(t):t=[null].concat(t),t}computeMask(e,t){return me(()=>{if(t==null)return null;if(!Array.isArray(t))throw new Z("`mask` should be an Array");if(!Array.isArray(e))throw new Z("`inputs` should be an Array");if(t.length!==e.length)throw new Z(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${e.length} vs ${t.length})`);if(t.every(s=>s==null))return null;t=t.map(s=>s==null?s:Ss(s,0));let r=t[0];for(let s=1;s<t.length-1;++s)r=rl(r,t[s]);return r})}}class fD extends dh{constructor(e){super(e)}mergeFunction(e){return me(()=>{let t=e[0].clone();for(let r=1;r<e.length;++r)t=Pe(t,e[r]);return t})}}fD.className="Add";_e(fD);class pD extends dh{constructor(e){super(e)}mergeFunction(e){return me(()=>{let t=e[0].clone();for(let r=1;r<e.length;++r)t=ne(t,e[r]);return t})}}pD.className="Multiply";_e(pD);class mD extends dh{constructor(e){super(e)}mergeFunction(e){return me(()=>{let t=e[0].clone();for(let r=1;r<e.length;++r)t=Pe(t,e[r]);return ne(1/e.length,t)})}}mD.className="Average";_e(mD);class gD extends dh{constructor(e){super(e)}mergeFunction(e){return me(()=>{let t=e[0];for(let r=1;r<e.length;++r)t=vu(t,e[r]);return t})}}gD.className="Maximum";_e(gD);class xD extends dh{constructor(e){super(e)}mergeFunction(e){return me(()=>{let t=e[0];for(let r=1;r<e.length;++r)t=zm(t,e[r]);return t})}}xD.className="Minimum";_e(xD);class yD extends dh{constructor(e){super(e),this.DEFAULT_AXIS=-1,e==null&&(e={}),this.axis=e.axis==null?this.DEFAULT_AXIS:e.axis,this.supportsMasking=!0,this.reshapeRequired=!1}build(e){if(!(Array.isArray(e)&&Array.isArray(e[0]))||e.length===1)throw new Z("A `Concatenate` layer should be called on a list of at least 2 inputs");e=e;let t=!0;for(const s of e)if(s!=null){t=!1;break}if(t)return;const r=[];for(let s=0;s<e.length;++s){const o=e[s].slice();o.splice(this.axis,1);let i=!1;for(const a of r)if(Xt(a,o)){i=!0;break}i||r.push(o)}if(r.length>1)throw new Z("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}mergeFunction(e){return me(()=>fI(e,this.axis))}computeOutputShape(e){if(!(Array.isArray(e)&&Array.isArray(e[0])))throw new Z("A `Concatenate` layer should be called on a list of inputs.");const t=e,r=t[0].slice(),s=this.axis<0?r.length+this.axis:this.axis;for(const o of t.slice(1)){if(r[s]==null||o[s]==null){r[s]=null;break}r[s]+=o[s]}return r}computeMask(e,t){if(t==null)return null;if(!Array.isArray(t))throw new Z("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new Z("`inputs` should be an array for Concatenate");if(t.length!==e.length)throw new Z(`Mismatch in the length of mask (${t.length}) and the legnth of inputs (${e.length})`);return me(()=>{let r=!0;if(t.forEach(i=>{if(i!=null){r=!1;return}}),r)return null;const s=[];for(let i=0;i<e.length;++i)t[i]==null?s.push(Ge(Ko(e[i]),"bool")):t[i].rank<e[i].rank?s.push(Ss(t[i],-1)):s.push(t[i]);const o=Is(s,this.axis);return xR(o,-1,!1)})}getConfig(){const e={axis:this.axis},t=super.getConfig();return Object.assign(e,t),e}}yD.className="Concatenate";_e(yD);function xm(n,e){for(;n<0;)n+=e;return n}function DK(n,e,t){if(n.shape.length>3||e.shape.length>3)throw new wt("batchDot is not implemented for tensors of 4D or higher rank yet");if(U(n.shape.length>=2,()=>`batchDot requires the rank of x to be >= 2, but got ${n.shape.length}`),U(n.shape.length>=2,()=>`batchDot requires the rank of y to be >= 2, but got ${e.shape.length}`),typeof t=="number"&&(t=[t,t]),n.dtype==="complex64"||e.dtype==="complex64")throw new wt("batchDot is not implemented for complex64-type Tensors yet.");const r=n.shape.length,s=e.shape.length;t==null&&(t=[r-1,s-2]);const o=t;return me(()=>{let i;if(r>s){i=r-s;const l=[];for(let c=0;c<i;++c)l.push(1);e=ce(e,e.shape.concat(l))}else if(s>r){i=s-r;const l=[];for(let c=0;c<i;++c)l.push(1);n=ce(n,n.shape.concat(l))}else i=0;let a;if(n.shape.length===2&&e.shape.length===2)o[0]===o[1]?a=rt(ne(n,e),o[0]):a=rt(ne(Lt(n,[1,0]),e),o[1]);else{const l=o[0]!==n.shape.length-1,c=o[1]===e.shape.length-1;a=qt(n,e,l,c)}if(i>0){let l;r>s?l=r+s-3:l=r-1;const c=[];for(let d=l;d<l+i;++d)c.push(d);a=nx(a,c)}return a.shape.length===1&&(a=Ss(a,1)),a})}class vD extends dh{constructor(e){super(e),this.axes=e.axes,this.normalize=e.normalize==null?!1:e.normalize,this.supportsMasking=!0,this.reshapeRequired=!1}build(e){U(Array.isArray(e)&&e.length===2&&Array.isArray(e[0])&&Array.isArray(e[1]),()=>"A `Dot` layer should be called on a list of exactly 2 inputs.");const t=e[0],r=e[1];if(t.length>3||r.length>3)throw new wt("Dot layer does not support tensors of 4D or higher rank yet.");const s=this.interpretAxes(t,r);if(t[s[0]]!==r[s[1]])throw new Z(`Dimension incompatibility: ${t[s[0]]} !== ${r[s[1]]}`)}mergeFunction(e){if(e.length!==2)throw new Z(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`);let t=e[0],r=e[1],s;return Array.isArray(this.axes)?s=this.axes.map((o,i)=>xm(o,e[i].shape.length)):s=[xm(this.axes,t.shape.length),xm(this.axes,r.shape.length)],this.normalize&&(t=Qy(t,s[0]),r=Qy(r,s[1])),DK(t,r,s)}interpretAxes(e,t){let r;return Array.isArray(this.axes)?r=this.axes:r=[xm(this.axes,e.length),xm(this.axes,t.length)],r}computeOutputShape(e){U(Array.isArray(e)&&e.length===2&&Array.isArray(e[0])&&Array.isArray(e[1]),()=>"A `Dot` layer should be called on a list of exactly 2 inputs.");const t=e[0].slice(),r=e[1].slice();if(t.length>3||r.length>3)throw new wt("Dot layer does not support tensors of 4D or higher rank yet.");const s=this.interpretAxes(t,r);t.splice(s[0],1),r.splice(s[1],1),r.splice(0,1);const o=t.concat(r);return o.length===1&&o.push(1),o}computeMask(e,t){return null}getConfig(){const e={axes:this.axes,normalize:this.normalize},t=super.getConfig();return Object.assign(e,t),e}}vD.className="Dot";_e(vD);class wD extends Et{constructor(e){super(e),this.supportsMasking=!0,this.stddev=e.stddev}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={stddev:this.stddev};return Object.assign(t,e),t}call(e,t){return me(()=>{this.invokeCallHook(e,t);const r=ft(e);return cx(()=>Pe(Av(r.shape,0,this.stddev),r),()=>r,t.training||!1)})}}wD.className="GaussianNoise";_e(wD);class bD extends Et{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={rate:this.rate};return Object.assign(t,e),t}call(e,t){return me(()=>{this.invokeCallHook(e,t);const r=ft(e);return this.rate>0&&this.rate<1?cx(()=>{const o=Math.sqrt(this.rate/(1-this.rate));return ne(r,Av(r.shape,1,o))},()=>r,t.training||!1):r})}}bD.className="GaussianDropout";_e(bD);class CD extends Et{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate,this.noiseShape=e.noiseShape}_getNoiseShape(e){return this.noiseShape||ft(e).shape}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),t={rate:this.rate};return Object.assign(t,e),t}call(e,t){return me(()=>{if(this.rate<1&&this.rate>0){const r=this._getNoiseShape(e);return cx(()=>{const o=ft(e),a=-1.6732632423543772*1.0507009873554805;let l=lh(tx(r),this.rate);l=fa(l,"float32");const c=((1-this.rate)*(1+this.rate*a**2))**-.5,d=-c*a*this.rate,p=Pe(ne(o,l),ne(Pe(l,-1),a));return Pe(ne(p,c),d)},()=>ft(e),t.training||!1)}return e})}}CD.className="AlphaDropout";_e(CD);function Gm(n,e,t,r,s,o=.001){let i;if(n.rank===2)i=ZW(n,e,t,r,s,o);else if(n.rank===3)i=tV(n,e,t,r,s,o);else if(n.rank===4)i=rV(n,e,t,r,s,o);else throw new wt(`batchNormalization is not implemented for array of rank ${n.rank} yet`);return i}function OK(n,e,t,r,s=.001){return me(()=>{const o=wk(n,r),i=o.mean,a=o.variance;return[Gm(n,i,a,t,e,s),i,a]})}function FK(n,e,t,r,s=.001){return me(()=>{const o=wk(n,r),i=o.mean,a=o.variance,l=[];for(const v of Ii(0,n.rank))r.indexOf(v)!==-1?l.push(1):l.push(n.shape[v]);const c=ce(i,l),d=ce(a,l),p=e==null?null:ce(e,l),m=t==null?null:ce(t,l);return[Gm(n,c,d,m,p,s),i,a]})}function PK(n,e,t,r,s=.001){return Xt(r.slice().sort(),Ii(0,n.rank-1))?OK(n,e,t,r,s):FK(n,e,t,r,s)}class SD extends Et{constructor(e){e==null&&(e={}),super(e),this.supportsMasking=!0,this.axis=e.axis==null?-1:e.axis,this.momentum=e.momentum==null?.99:e.momentum,this.epsilon=e.epsilon==null?.001:e.epsilon,this.center=e.center==null?!0:e.center,this.scale=e.scale==null?!0:e.scale,this.betaInitializer=kn(e.betaInitializer||"zeros"),this.gammaInitializer=kn(e.gammaInitializer||"ones"),this.movingMeanInitializer=kn(e.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=kn(e.movingVarianceInitializer||"ones"),this.betaConstraint=ir(e.betaConstraint),this.gammaConstraint=ir(e.gammaConstraint),this.betaRegularizer=In(e.betaRegularizer),this.gammaRegularizer=In(e.gammaRegularizer)}build(e){e=Gt(e);const t=this.axis>=0?this.axis:this.axis+e.length,r=e[t];if(r==null)throw new Z(`Axis ${t} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(e)}.`);this.inputSpec=[new rr({ndim:e.length,axes:{[t]:r}})];const s=[r];this.scale&&(this.gamma=this.addWeight("gamma",s,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",s,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",s,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",s,null,this.movingVarianceInitializer,null,!1),this.built=!0}call(e,t){return me(()=>{const r=t.training==null?!1:t.training,s=ft(e),o=s.shape,i=o.length,a=Ii(0,i),l=this.axis>=0?this.axis:this.axis+i;a.splice(l,1);const c=th(1,i);c[l]=o[l];const d=a.slice();d.sort();const p=!Xt(d,Ii(0,i).slice(0,i-1)),m=()=>{if(p){const I=ce(this.movingMean.read(),c),N=ce(this.movingVariance.read(),c),T=this.center?ce(this.beta.read(),c):null,A=this.scale?ce(this.gamma.read(),c):null;return Gm(s,I,N,T,A,this.epsilon)}else return Gm(s,this.movingMean.read(),this.movingVariance.read(),this.beta==null?null:this.beta.read(),this.gamma==null?null:this.gamma.read(),this.epsilon)};if(!r)return m();const[y,v,b]=PK(s,this.gamma.read(),this.beta.read(),a,this.epsilon),w=(I,N,T)=>{me(()=>{const A=1-T,O=I.read(),P=ne(ut(O,N),A);I.write(ut(O,P))})};return(()=>{w(this.movingMean,v,this.momentum),w(this.movingVariance,b,this.momentum)})(),y})}getConfig(){const e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Tn(this.betaInitializer),gammaInitializer:Tn(this.gammaInitializer),movingMeanInitializer:Tn(this.movingMeanInitializer),movingVarianceInitializer:Tn(this.movingVarianceInitializer),betaRegularizer:un(this.betaRegularizer),gammaRegularizer:un(this.gammaRegularizer),betaConstraint:or(this.betaConstraint),gammaConstraint:or(this.gammaConstraint)},t=super.getConfig();return Object.assign(e,t),e}}SD.className="BatchNormalization";_e(SD);class kD extends Et{constructor(e){if(e==null&&(e={}),super(e),this.axis=e.axis==null?-1:e.axis,typeof this.axis=="number"){if(!Number.isInteger(this.axis))throw new Error(`Expected axis to be an integer, but received ${this.axis}`)}else if(Array.isArray(this.axis)){for(const t of this.axis)if(!Number.isInteger(t))throw new Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`)}else throw new Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`);this.epsilon=e.epsilon==null?.001:e.epsilon,this.center=e.center==null?!0:e.center,this.scale=e.scale==null?!0:e.scale,this.betaInitializer=kn(e.betaInitializer||"zeros"),this.gammaInitializer=kn(e.gammaInitializer||"ones"),this.betaRegularizer=In(e.betaRegularizer),this.gammaRegularizer=In(e.gammaRegularizer),this.supportsMasking=!0}build(e){e=Gt(e);const t=e.length;typeof this.axis=="number"&&(this.axis=[this.axis]);for(let o=0;o<this.axis.length;++o)this.axis[o]<0&&(this.axis[o]+=t);for(const o of this.axis)if(o<0||o>=t)throw new Error(`Invalid axis: ${o}`);if(this.axis.length!==ou(this.axis).length)throw new Error(`Found duplicate axes in: ${this.axis}`);const r=this.axis.map(o=>e[o]),s=!0;this.scale?this.gamma=this.addWeight("gamma",r,"float32",this.gammaInitializer,this.gammaRegularizer,s):this.gamma=null,this.center?this.beta=this.addWeight("beta",r,"float32",this.betaInitializer,this.betaRegularizer,s):this.beta=null,this.built=!0}call(e,t){const r=ft(e),s=r.shape,o=s.length;return me(()=>{let{mean:a,variance:l}=wk(r,this.axis,!0);const c=th(1,o);for(const b of this.axis)c[b]=s[b];const d=b=>b!=null&&b.shape.length!==o?ce(b,c):b;let p=this.scale?d(this.gamma.read()):null,m=this.center?d(this.beta.read()):null;const y=[],v=[];for(let b=0;b<o;++b)this.axis.indexOf(b)!==-1?(y.push(s[b]),v.push(1)):(y.push(1),v.push(s[b]));return a=bi(a,y),l=bi(l,y),p!=null&&(p=bi(p,v)),m!=null&&(m=bi(m,v)),Gm(r,a,l,m,p,this.epsilon)})}getConfig(){const e={axis:this.axis,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Tn(this.betaInitializer),gammaInitializer:Tn(this.gammaInitializer),betaRegularizer:un(this.betaRegularizer),gammaRegularizer:un(this.gammaRegularizer)},t=super.getConfig();return Object.assign(e,t),e}}kD.className="LayerNormalization";_e(kD);function LK(n,e,t){return me(()=>{if(n.rank!==4)throw new Z(`temporalPadding expects input tensor to be 4-D, but received a ${n.rank}-D tensor.`);if(e==null&&(e=[[1,1],[1,1]]),e.length!==2||e[0].length!==2||e[1].length!==2)throw new Z("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(t==null&&(t=$i()),t!=="channelsLast"&&t!=="channelsFirst")throw new Z(`Unknown data format: ${t}. Supported data formats are 'channelsLast' and 'channelsFirst.`);let r;return t==="channelsFirst"?r=[[0,0],[0,0],e[0],e[1]]:r=[[0,0],e[0],e[1],[0,0]],bk(n,r)})}class ID extends Et{constructor(e){if(e==null&&(e={}),super(e),this.dataFormat=e.dataFormat==null?$i():e.dataFormat,e.padding==null)this.padding=[[1,1],[1,1]];else if(typeof e.padding=="number")this.padding=[[e.padding,e.padding],[e.padding,e.padding]];else{if(e.padding=e.padding,e.padding.length!==2)throw new Z(`ZeroPadding2D expects padding to be a length-2 array, but received a length-${e.padding.length} array.`);let t,r;if(typeof e.padding[0]=="number")t=[e.padding[0],e.padding[0]],r=[e.padding[1],e.padding[1]];else{if(e.padding=e.padding,e.padding[0].length!==2)throw new Z(`ZeroPadding2D expects height padding to be a length-2 array, but received a length-${e.padding[0].length} array.`);if(t=e.padding[0],e.padding[1].length!==2)throw new Z(`ZeroPadding2D expects width padding to be a length-2 array, but received a length-${e.padding[1].length} array.`);r=e.padding[1]}this.padding=[t,r]}this.inputSpec=[new rr({ndim:4})]}computeOutputShape(e){e=Gt(e);let t,r;return this.dataFormat==="channelsFirst"?(e[2]!=null&&e[2]>=0?t=e[2]+this.padding[0][0]+this.padding[0][1]:t=null,e[3]!=null&&e[3]>=0?r=e[3]+this.padding[1][0]+this.padding[1][1]:r=null,[e[0],e[1],t,r]):(e[1]!=null&&e[1]>=0?t=e[1]+this.padding[0][0]+this.padding[0][1]:t=null,e[2]!=null&&e[2]>=0?r=e[2]+this.padding[1][0]+this.padding[1][1]:r=null,[e[0],t,r,e[3]])}call(e,t){return me(()=>LK(ft(e),this.padding,this.dataFormat))}getConfig(){const e={padding:this.padding,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}ID.className="ZeroPadding2D";_e(ID);function zv(n,e,t,r,s,o){return me(()=>{Vn(s),UA(o),Co(r),t==null&&(t=[1,1]),r==null&&(r="valid"),s==null&&(s=$i()),o==null&&(o="max"),n=$I(n,s);let i;const a=r==="same"?"same":"valid";return o==="max"?i=vk(n,e,t,a):i=uk(n,e,t,a),s==="channelsFirst"&&(i=Lt(i,[0,3,1,2])),i})}function $D(n,e,t,r,s,o){return me(()=>{Vn(s),UA(o),Co(r),t==null&&(t=[1,1,1]),r==null&&(r="valid"),s==null&&(s=$i()),o==null&&(o="max"),n=V_(n,s);let i;const a=r==="same"?"same":"valid";return o==="max"?i=UG(n,e,t,a):i=VW(n,e,t,a),s==="channelsFirst"&&(i=Lt(i,[0,4,1,2,3])),i})}class ND extends Et{constructor(e){if(e.poolSize==null&&(e.poolSize=2),super(e),typeof e.poolSize=="number")this.poolSize=[e.poolSize];else if(Array.isArray(e.poolSize)&&e.poolSize.length===1&&typeof e.poolSize[0]=="number")this.poolSize=e.poolSize;else throw new Z(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.poolSize)}`);if(xr(this.poolSize,"poolSize"),e.strides==null)this.strides=this.poolSize;else if(typeof e.strides=="number")this.strides=[e.strides];else if(Array.isArray(e.strides)&&e.strides.length===1&&typeof e.strides[0]=="number")this.strides=e.strides;else throw new Z(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.strides)}`);xr(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,Co(this.padding),this.inputSpec=[new rr({ndim:3})]}computeOutputShape(e){e=Gt(e);const t=ki(e[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],t,e[2]]}call(e,t){return me(()=>{this.invokeCallHook(e,t),e=lx(ft(e),2);const r=this.poolingFunction(ft(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return nx(r,[2])})}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},t=super.getConfig();return Object.assign(e,t),e}}class TD extends ND{constructor(e){super(e)}poolingFunction(e,t,r,s,o){return Vn(o),Co(s),zv(e,t,r,s,o,"max")}}TD.className="MaxPooling1D";_e(TD);class ED extends ND{constructor(e){super(e)}poolingFunction(e,t,r,s,o){return Vn(o),Co(s),zv(e,t,r,s,o,"avg")}}ED.className="AveragePooling1D";_e(ED);class RD extends Et{constructor(e){if(e.poolSize==null&&(e.poolSize=[2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],e.strides==null)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(e.strides.length!==2)throw new Z(`If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides];xr(this.poolSize,"poolSize"),xr(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Vn(this.dataFormat),Co(this.padding),this.inputSpec=[new rr({ndim:4})]}computeOutputShape(e){e=Gt(e);let t=this.dataFormat==="channelsFirst"?e[2]:e[1],r=this.dataFormat==="channelsFirst"?e[3]:e[2];return t=ki(t,this.poolSize[0],this.padding,this.strides[0]),r=ki(r,this.poolSize[1],this.padding,this.strides[1]),this.dataFormat==="channelsFirst"?[e[0],e[1],t,r]:[e[0],t,r,e[3]]}call(e,t){return me(()=>(this.invokeCallHook(e,t),this.poolingFunction(ft(e),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class AD extends RD{constructor(e){super(e)}poolingFunction(e,t,r,s,o){return Vn(o),Co(s),zv(e,t,r,s,o,"max")}}AD.className="MaxPooling2D";_e(AD);class _D extends RD{constructor(e){super(e)}poolingFunction(e,t,r,s,o){return Vn(o),Co(s),zv(e,t,r,s,o,"avg")}}_D.className="AveragePooling2D";_e(_D);class DD extends Et{constructor(e){if(e.poolSize==null&&(e.poolSize=[2,2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],e.strides==null)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(e.strides.length!==3)throw new Z(`If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides,e.strides];xr(this.poolSize,"poolSize"),xr(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Vn(this.dataFormat),Co(this.padding),this.inputSpec=[new rr({ndim:5})]}computeOutputShape(e){e=Gt(e);let t=this.dataFormat==="channelsFirst"?e[2]:e[1],r=this.dataFormat==="channelsFirst"?e[3]:e[2],s=this.dataFormat==="channelsFirst"?e[4]:e[3];return t=ki(t,this.poolSize[0],this.padding,this.strides[0]),r=ki(r,this.poolSize[1],this.padding,this.strides[1]),s=ki(s,this.poolSize[2],this.padding,this.strides[2]),this.dataFormat==="channelsFirst"?[e[0],e[1],t,r,s]:[e[0],t,r,s,e[4]]}call(e,t){return me(()=>(this.invokeCallHook(e,t),this.poolingFunction(ft(e),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class OD extends DD{constructor(e){super(e)}poolingFunction(e,t,r,s,o){return Vn(o),Co(s),$D(e,t,r,s,o,"max")}}OD.className="MaxPooling3D";_e(OD);class FD extends DD{constructor(e){super(e)}poolingFunction(e,t,r,s,o){return Vn(o),Co(s),$D(e,t,r,s,o,"avg")}}FD.className="AveragePooling3D";_e(FD);class PD extends Et{constructor(e){super(e),this.inputSpec=[new rr({ndim:3})]}computeOutputShape(e){return[e[0],e[2]]}call(e,t){throw new wt}}class LD extends PD{constructor(e){super(e||{})}call(e,t){return me(()=>{const r=ft(e);return Xn(r,1)})}}LD.className="GlobalAveragePooling1D";_e(LD);class MD extends PD{constructor(e){super(e||{})}call(e,t){return me(()=>{const r=ft(e);return Si(r,1)})}}MD.className="GlobalMaxPooling1D";_e(MD);class zD extends Et{constructor(e){super(e),this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Vn(this.dataFormat),this.inputSpec=[new rr({ndim:4})]}computeOutputShape(e){return e=e,this.dataFormat==="channelsLast"?[e[0],e[3]]:[e[0],e[1]]}call(e,t){throw new wt}getConfig(){const e={dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class BD extends zD{call(e,t){return me(()=>{const r=ft(e);return this.dataFormat==="channelsLast"?Xn(r,[1,2]):Xn(r,[2,3])})}}BD.className="GlobalAveragePooling2D";_e(BD);class UD extends zD{call(e,t){return me(()=>{const r=ft(e);return this.dataFormat==="channelsLast"?Si(r,[1,2]):Si(r,[2,3])})}}UD.className="GlobalMaxPooling2D";_e(UD);class WD extends Et{constructor(e){super(e),this.layer=e.layer}build(e){this.built=!0}get trainable(){return this.layer!=null?this.layer.trainable:!1}set trainable(e){this.layer!=null&&(this.layer.trainable=e)}get trainableWeights(){return this.layer.trainableWeights}get nonTrainableWeights(){return this.layer.nonTrainableWeights}get updates(){return this.layer._updates}get losses(){return this.layer.losses}getWeights(){return this.layer.getWeights()}setWeights(e){this.layer.setWeights(e)}getConfig(){const e={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}},t=super.getConfig();return Object.assign(e,t),e}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.layer!=null&&this.layer.setFastWeightInitDuringBuild(e)}static fromConfig(e,t,r={}){const s=t.layer,o=ma(s,r);delete t.layer;const i={layer:o};return Object.assign(i,t),new e(i)}}class VD extends WD{constructor(e){super(e),this.supportsMasking=!0}build(e){if(e=Gt(e),e.length<3)throw new Z(`TimeDistributed layer expects an input shape >= 3D, but received input shape ${JSON.stringify(e)}`);this.inputSpec=[{shape:e}];const t=[e[0]].concat(e.slice(2));this.layer.built||(this.layer.build(t),this.layer.built=!0),super.build(e)}computeOutputShape(e){e=Gt(e);const t=[e[0]].concat(e.slice(2)),r=this.layer.computeOutputShape(t),s=e[1];return[r[0],s].concat(r.slice(1))}call(e,t){return me(()=>(e=ft(e),J_((i,a)=>[ft(this.layer.call(i,t)),[]],e,[],!1,null,null,!1,!0)[1]))}}VD.className="TimeDistributed";_e(VD);function MK(n){hh(nq,"BidirectionalMergeMode",n)}const zK="concat";class GD extends WD{constructor(e){super(e);const t=e.layer.getConfig(),r={};r.className=e.layer.getClassName(),r.config=t,this.forwardLayer=ma(r),t.goBackwards=t.goBackwards!==!0;const s={};if(s.className=e.layer.getClassName(),s.config=t,this.backwardLayer=ma(s),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=e.mergeMode===void 0?zK:e.mergeMode,MK(this.mergeMode),e.weights)throw new wt("weights support is not implemented for Bidirectional layer yet.");this._stateful=e.layer.stateful,this.returnSequences=e.layer.returnSequences,this.returnState=e.layer.returnState,this.supportsMasking=!0,this._trainable=!0,this.inputSpec=e.layer.inputSpec,this.numConstants=null}get trainable(){return this._trainable}set trainable(e){this._trainable=e,this.forwardLayer!=null&&(this.forwardLayer.trainable=e),this.backwardLayer!=null&&(this.backwardLayer.trainable=e)}getWeights(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())}setWeights(e){const t=e.length,r=Math.floor(t/2);this.forwardLayer.setWeights(e.slice(0,r)),this.backwardLayer.setWeights(e.slice(r))}computeOutputShape(e){let t=this.forwardLayer.computeOutputShape(e);Array.isArray(t)&&Array.isArray(t[0])||(t=[t]),t=t;let r,s,o;return this.returnState&&(o=t.slice(1)),r=t[0],r=r,this.mergeMode==="concat"?(r[r.length-1]*=2,s=[r]):this.mergeMode==null?s=[r,r.slice()]:s=[r],this.returnState?this.mergeMode==null?s.concat(o).concat(o.slice()):[r].concat(o).concat(o.slice()):ks(s)}apply(e,t){let r=t==null?null:t.initialState,s=t==null?null:t.constants;t==null&&(t={});const o=Q_(e,r,s,this.numConstants);if(e=o.inputs,r=o.initialState,s=o.constants,Array.isArray(e)&&(r=e.slice(1),e=e[0]),(r==null||r.length===0)&&s==null)return super.apply(e,t);const i=[],a=[];if(r!=null){const c=r.length;if(c%2>0)throw new Z("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");t.initialState=r,i.push(...r);const d=r.map(p=>new rr({shape:p.shape}));this.forwardLayer.stateSpec=d.slice(0,c/2),this.backwardLayer.stateSpec=d.slice(c/2),a.push(...d)}if(s!=null)throw new wt("Support for constants in Bidirectional layers is not implemented yet.");const l=i[0]instanceof va;for(const c of i)if(c instanceof va!==l)throw new Z("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");if(l){const c=[e].concat(i),d=this.inputSpec.concat(a),p=this.inputSpec;this.inputSpec=d;const m=super.apply(c,t);return this.inputSpec=p,m}else return super.apply(e,t)}call(e,t){return me(()=>{const r=t.initialState;let s,o;if(r==null)s=this.forwardLayer.call(e,t),o=this.backwardLayer.call(e,t);else{const l=r.slice(0,r.length/2),c=r.slice(r.length/2);s=this.forwardLayer.call(e,Object.assign(t,{initialState:l})),o=this.backwardLayer.call(e,Object.assign(t,{initialState:c}))}let i;this.returnState&&(Array.isArray(s)&&(i=s.slice(1).concat(o.slice(1))),s=s[0],o=o[0]),this.returnSequences&&(o=Zc(o,1));let a;return this.mergeMode==="concat"?a=fI([s,o]):this.mergeMode==="sum"?a=Pe(s,o):this.mergeMode==="ave"?a=ne(.5,Pe(s,o)):this.mergeMode==="mul"?a=ne(s,o):this.mergeMode==null&&(a=[s,o]),this.returnState?this.mergeMode==null?a.concat(i):[a].concat(i):a})}resetStates(e){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()}build(e){Mc(this.forwardLayer.name,()=>{this.forwardLayer.build(e)}),Mc(this.backwardLayer.name,()=>{this.backwardLayer.build(e)}),this.built=!0}computeMask(e,t){Array.isArray(t)&&(t=t[0]);let r;if(this.returnSequences?this.mergeMode==null?r=[t,t]:r=t:this.mergeMode==null?r=[null,null]:r=null,this.returnState){const o=this.forwardLayer.states.map(i=>null);return Array.isArray(r)?r.concat(o).concat(o):[r].concat(o).concat(o)}else return r}get trainableWeights(){return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights)}get nonTrainableWeights(){return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights)}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.forwardLayer!=null&&this.forwardLayer.setFastWeightInitDuringBuild(e),this.backwardLayer!=null&&this.backwardLayer.setFastWeightInitDuringBuild(e)}getConfig(){const e={mergeMode:this.mergeMode},t=super.getConfig();return Object.assign(e,t),e}static fromConfig(e,t){const r=ma(t.layer);if(delete t.layer,t.numConstants!=null)throw new wt("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");const s=t;return s.layer=r,new e(s)}}GD.className="Bidirectional";_e(GD);class jD extends Et{constructor(e){super(e),this.scale=e.scale,e.offset?this.offset=e.offset:this.offset=0}getConfig(){const e={scale:this.scale,offset:this.offset},t=super.getConfig();return Object.assign(e,t),e}call(e,t){return me(()=>(e=ft(e),e.dtype!=="float32"&&(e=fa(e,"float32")),Pe(ne(e,this.scale),this.offset)))}}jD.className="Rescaling";_e(jD);const{resizeBilinear:BK,cropAndResize:UK}=nl;class HD extends Et{constructor(e){super(e),this.height=e.height,this.width=e.width}centerCrop(e,t,r,s,o,i,a,l){return me(()=>{let c,d=!1;const p=t/i,m=r/a,y=(s+t)/i,v=(o+r)/a,b=[p,m,y,v],w=[];e.rank===3?(d=!0,c=sl([e])):c=e;for(let A=0;A<c.shape[0];A++)w.push(b);const k=$m(w,[w.length,4]),I=Bm(0,w.length,1,"int32"),T=UK(c,k,I,[s,o],"nearest");return fa(d?ft(eh(T)):T,l)})}upsize(e,t,r,s){return me(()=>{const o=BK(e,[t,r]);return fa(o,s)})}call(e,t){return me(()=>{const r=ft(e),s=r.dtype,o=r.shape,i=o[o.length-3],a=o[o.length-2];let l=0;i!==this.height&&(l=Math.floor((i-this.height)/2));let c=0;return a!==this.width&&(c=Math.floor((a-this.width)/2),c===0&&(c=1)),l>=0&&c>=0?this.centerCrop(r,l,c,this.height,this.width,i,a,s):this.upsize(e,this.height,this.width,s)})}getConfig(){const e={height:this.height,width:this.width},t=super.getConfig();return Object.assign(e,t),e}computeOutputShape(e){e=Gt(e);const t=e.length-3,r=e.length-2;return e[t]=this.height,e[r]=this.width,e}}HD.className="CenterCrop";_e(HD);function WK(n,e,t,r){let s=ft(n);if(s.dtype!=="int32"&&(s=fa(s,"int32")),e==="int")return s;const o=s.shape;if(s.rank===0&&(s=Ss(s,-1)),e==="oneHot"&&s.shape[s.shape.length-1]!==1&&(s=Ss(s,-1)),s.rank>2)throw new Z(`When outputMode is not int, maximum output rank is 2 Received outputMode ${e} and input shape ${o} which would result in output rank ${s.rank}.`);const i=["multiHot","oneHot"].includes(e),a=s;let l;if(typeof r<"u"&&e==="count"?l=zN(a,r,t,i):l=zN(a,[],t,i),e!=="tfIdf")return l;if(r)return ne(l,r);throw new Z("When outputMode is 'tfIdf', weights must be provided.")}class qD extends Et{constructor(e){super(e),this.numTokens=e.numTokens,e.outputMode?this.outputMode=e.outputMode:this.outputMode="multiHot"}getConfig(){const e={numTokens:this.numTokens,outputMode:this.outputMode},t=super.getConfig();return Object.assign(e,t),e}computeOutputShape(e){return e=Gt(e),e==null?[this.numTokens]:this.outputMode==="oneHot"&&e[e.length-1]!==1?(e.push(this.numTokens),e):(e[e.length-1]=this.numTokens,e)}call(e,t){return me(()=>{e=ft(e),e.dtype!=="int32"&&(e=fa(e,"int32"));let r;if(typeof t.countWeights<"u"){if(this.outputMode!=="count")throw new Z(`countWeights is not used when outputMode !== count.
Received countWeights=${t.countWeights}`);r=ft(t.countWeights)}const s=Si(e),o=Wy(e),i=bo(this.numTokens,s).bufferSync().get(0),a=lh(o,0).bufferSync().get(0);if(!(i&&a))throw new Z(`Input values must be between 0 < values <= numTokens with numTokens=${this.numTokens}`);return WK(e,this.outputMode,this.numTokens,r)})}}qD.className="CategoryEncoding";_e(qD);const VK=["bilinear","nearest"],T2=new Set(VK);class KD extends Et{constructor(e){if(super(e),this.height=e.height,this.width=e.width,e.interpolation)if(T2.has(e.interpolation))this.interpolation=e.interpolation;else throw new Z(`Invalid interpolation parameter: ${e.interpolation} is not implemented`);else this.interpolation="bilinear";this.cropToAspectRatio=!!e.cropToAspectRatio}computeOutputShape(e){e=Gt(e);const t=e[2];return[this.height,this.width,t]}getConfig(){const e={height:this.height,width:this.width,interpolation:this.interpolation,cropToAspectRatio:this.cropToAspectRatio},t=super.getConfig();return Object.assign(e,t),e}call(e,t){return me(()=>{const r=[this.height,this.width];if(this.interpolation==="bilinear")return nl.resizeBilinear(e,r,!this.cropToAspectRatio);if(this.interpolation==="nearest")return nl.resizeNearestNeighbor(e,r,!this.cropToAspectRatio);throw new Error(`Interpolation is ${this.interpolation} but only ${[...T2]} are supported`)})}}KD.className="Resizing";_e(KD);class XD{constructor(e){this.seed=e}next(){if(this.seed!==void 0)return this.seed++}}XD.className="RandomSeed";class YD extends Et{constructor(e){super(e),this.randomGenerator=new XD(e.seed)}getConfig(){const e={seed:this.randomGenerator.seed},t=super.getConfig();return Object.assign(e,t),e}}YD.className="BaseRandomLayer";const GK=["bilinear","nearest"],E2=new Set(GK);class QD extends YD{constructor(e){super(e);const{factor:t,interpolation:r="bilinear"}=e;if(this.factor=t,Array.isArray(this.factor)&&this.factor.length===2)this.widthLower=this.factor[0],this.widthUpper=this.factor[1];else if(!Array.isArray(this.factor)&&this.factor>0)this.widthLower=-this.factor,this.widthUpper=this.factor;else throw new Z(`Invalid factor: ${this.factor}. Must be positive number or tuple of 2 numbers`);if(this.widthLower<-1||this.widthUpper<-1)throw new Z(`factor must have values larger than -1. Got: ${this.factor}`);if(this.widthUpper<this.widthLower)throw new Z(`factor cannot have upper bound less than lower bound.
Got upper bound: ${this.widthUpper}.
Got lower bound: ${this.widthLower}
`);if(r)if(E2.has(r))this.interpolation=r;else throw new Z(`Invalid interpolation parameter: ${r} is not implemented`)}getConfig(){const e={factor:this.factor,interpolation:this.interpolation},t=super.getConfig();return Object.assign(e,t),e}computeOutputShape(e){e=Gt(e);const t=e[2];return[this.imgHeight,-1,t]}call(e,t){return me(()=>{const r=ft(e);this.imgHeight=r.shape[r.shape.length-3];const s=r.shape[r.shape.length-2];this.widthFactor=tx([1],1+this.widthLower,1+this.widthUpper,"float32",this.randomGenerator.next());let o=this.widthFactor.dataSync()[0]*s;o=Math.round(o);const i=[this.imgHeight,o];switch(this.interpolation){case"bilinear":return nl.resizeBilinear(e,i);case"nearest":return nl.resizeNearestNeighbor(e,i);default:throw new Error(`Interpolation is ${this.interpolation}
but only ${[...E2]} are supported`)}})}}QD.className="RandomWidth";_e(QD);const jK=ye();jK.registerFlag("KEEP_INTERMEDIATE_TENSORS",()=>!1,n=>{n&&console.warn("Keep intermediate tensors is ON. This will print the values of all intermediate tensors during model inference. Not all models support this mode. For details, check e2e/benchmarks/ model_config.js. This significantly impacts performance.")});var R2;(function(n){n[n.DT_INVALID=0]="DT_INVALID",n[n.DT_FLOAT=1]="DT_FLOAT",n[n.DT_DOUBLE=2]="DT_DOUBLE",n[n.DT_INT32=3]="DT_INT32",n[n.DT_UINT8=4]="DT_UINT8",n[n.DT_INT16=5]="DT_INT16",n[n.DT_INT8=6]="DT_INT8",n[n.DT_STRING=7]="DT_STRING",n[n.DT_COMPLEX64=8]="DT_COMPLEX64",n[n.DT_INT64=9]="DT_INT64",n[n.DT_BOOL=10]="DT_BOOL",n[n.DT_QINT8=11]="DT_QINT8",n[n.DT_QUINT8=12]="DT_QUINT8",n[n.DT_QINT32=13]="DT_QINT32",n[n.DT_BFLOAT16=14]="DT_BFLOAT16",n[n.DT_QINT16=15]="DT_QINT16",n[n.DT_QUINT16=16]="DT_QUINT16",n[n.DT_UINT16=17]="DT_UINT16",n[n.DT_COMPLEX128=18]="DT_COMPLEX128",n[n.DT_HALF=19]="DT_HALF",n[n.DT_RESOURCE=20]="DT_RESOURCE",n[n.DT_VARIANT=21]="DT_VARIANT",n[n.DT_UINT32=22]="DT_UINT32",n[n.DT_UINT64=23]="DT_UINT64",n[n.DT_FLOAT_REF=101]="DT_FLOAT_REF",n[n.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",n[n.DT_INT32_REF=103]="DT_INT32_REF",n[n.DT_UINT8_REF=104]="DT_UINT8_REF",n[n.DT_INT16_REF=105]="DT_INT16_REF",n[n.DT_INT8_REF=106]="DT_INT8_REF",n[n.DT_STRING_REF=107]="DT_STRING_REF",n[n.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",n[n.DT_INT64_REF=109]="DT_INT64_REF",n[n.DT_BOOL_REF=110]="DT_BOOL_REF",n[n.DT_QINT8_REF=111]="DT_QINT8_REF",n[n.DT_QUINT8_REF=112]="DT_QUINT8_REF",n[n.DT_QINT32_REF=113]="DT_QINT32_REF",n[n.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF",n[n.DT_QINT16_REF=115]="DT_QINT16_REF",n[n.DT_QUINT16_REF=116]="DT_QUINT16_REF",n[n.DT_UINT16_REF=117]="DT_UINT16_REF",n[n.DT_COMPLEX128_REF=118]="DT_COMPLEX128_REF",n[n.DT_HALF_REF=119]="DT_HALF_REF",n[n.DT_RESOURCE_REF=120]="DT_RESOURCE_REF",n[n.DT_VARIANT_REF=121]="DT_VARIANT_REF",n[n.DT_UINT32_REF=122]="DT_UINT32_REF",n[n.DT_UINT64_REF=123]="DT_UINT64_REF"})(R2||(R2={}));var A2;(function(n){(function(e){e[e.LEGACY=0]="LEGACY",e[e.V1=1]="V1",e[e.V2=2]="V2"})(n.CheckpointFormatVersion||(n.CheckpointFormatVersion={}))})(A2||(A2={}));var _2;(function(n){n[n.FAIL=0]="FAIL",n[n.SHORTEST=1]="SHORTEST",n[n.LONGEST=2]="LONGEST"})(_2||(_2={}));function Ye(n,e){Array.isArray(n)||(n=[n]),n.forEach(t=>{t!=null&&U(t.dtype!=="complex64",()=>`${e} does not support complex64 tensors in the CPU backend.`)})}const HK=jR;class Bv extends hS{nextDataId(){return Bv.nextDataId++}constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new yE(this,na())}write(e,t,r){this.firstUse&&(this.firstUse=!1,ye().get("IS_NODE")&&go(`
============================
Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, visit https://github.com/tensorflow/tfjs-node for more details.
============================`));const s={id:this.nextDataId()};return this.data.set(s,{values:e,dtype:r,refCount:1}),s}makeTensorInfo(e,t,r){let s;if(t==="string"&&r!=null&&r.length>0&&tg(r[0])){const o=r.map(i=>su(i));s=this.write(o,e,t)}else s=this.write(r,e,t);return{dataId:s,shape:e,dtype:t}}refCount(e){return this.data.has(e)?this.data.get(e).refCount:0}incRef(e){const t=this.data.get(e);t.refCount++}decRef(e){if(this.data.has(e)){const t=this.data.get(e);t.refCount--}}move(e,t,r,s,o){this.data.set(e,{values:t,dtype:s,refCount:o})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){const{dtype:t,complexTensorInfos:r}=this.data.get(e);if(t==="complex64"){const s=this.readSync(r.real.dataId),o=this.readSync(r.imag.dataId);return ol(s,o)}return K4(this.data.get(e).values,t)}bufferSync(e){const t=this.readSync(e.dataId);if(e.dtype==="string")try{const r=t.map(s=>au(s));return Nt(e.shape,e.dtype,r)}catch{throw new Error("Failed to decode encoded string bytes into utf-8")}return Nt(e.shape,e.dtype,t)}makeOutput(e,t,r){return na().makeTensorFromTensorInfo(this.makeTensorInfo(t,r,e),this)}disposeData(e,t=!1){if(this.data.has(e)){if(this.data.get(e).refCount--,!t&&this.data.get(e).refCount>0)return!1;const{complexTensorInfos:r}=this.data.get(e);r!=null&&(this.disposeData(r.real.dataId,!0),this.disposeData(r.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){const t=Cs();return e(),{kernelMs:Cs()-t}}memory(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}}where(e){Ye([e],"where");const t=this.readSync(e.dataId);return HK(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}}Bv.nextDataId=0;function JD(n){const e=new Float32Array(n.length);for(let t=0;t<n.length;++t)e[t]=Math.abs(n[t]);return e}const qK=n=>{const{x:e}=n.inputs,t=n.backend;Ye(e,"abs");let r=new Float32Array(Se(e.shape));const s=t.data.get(e.dataId).values;return r=JD(s),t.makeOutput(r,e.shape,e.dtype)},KK={kernelName:v1,backendName:"cpu",kernelFunc:qK};function Gn(n){return(e,t,r,s,o)=>{const i=gt(e,t),a=i.length,l=tt(i),c=Se(i),d=Vr(o,c),p=e.length,m=t.length,y=tt(e),v=tt(t),b=uf(e,i),w=uf(t,i);if(b.length+w.length===0)for(let k=0;k<d.length;++k)d[k]=n(r[k%r.length],s[k%s.length]);else for(let k=0;k<d.length;++k){const I=Sf(k,a,l),N=I.slice(-p);b.forEach(P=>N[P]=0);const T=ca(N,p,y),A=I.slice(-m);w.forEach(P=>A[P]=0);const O=ca(A,m,v);d[k]=n(r[T],s[O])}return[d,i]}}function Hs(n){const{inputs:e,backend:t}=n,{real:r,imag:s}=e,o=t.data.get(r.dataId).values,i=t.data.get(s.dataId).values,a=t.makeTensorInfo(r.shape,"complex64"),l=t.data.get(a.dataId);return l.complexTensorInfos={real:t.makeTensorInfo(r.shape,"float32",o),imag:t.makeTensorInfo(s.shape,"float32",i)},a}const XK={kernelName:IS,backendName:"cpu",kernelFunc:Hs};function r1(n,e,t="float32"){if(t==="complex64"){const s=r1(n,e,"float32"),o=r1(n,e,"float32");return Hs({inputs:{real:s,imag:o},backend:n})}const r=Gr(Se(e),t);return n.makeTensorInfo(e,t,r)}function wa(n){const{inputs:e,backend:t}=n,{x:r}=e;return t.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}const YK={kernelName:Cg,backendName:"cpu",kernelFunc:wa};function nh(n){const{inputs:e,backend:t}=n,{input:r}=e,s=t.data.get(r.dataId).complexTensorInfos.real,o=t.data.get(s.dataId).values;return t.makeTensorInfo(s.shape,s.dtype,o)}const QK={kernelName:XS,backendName:"cpu",kernelFunc:nh};function ZD(n,e,t,r){if(r==="int32"){const s=Int32Array.from(n);return[e,"int32",s]}if(r==="bool"){const s=ah([0],t),[o,i]=Gn((a,l)=>a!==l?1:0)(e,[],n,s,"bool");return[i,"bool",o]}throw new Error(`Error in Cast: failed to cast ${t} to ${r}`)}function du(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{dtype:o}=r;if(o==="complex64"){if(s.dtype==="complex64")return wa({inputs:{x:s},backend:t});const d=r1(t,s.shape,s.dtype),p=du({inputs:{x:s},backend:t,attrs:{dtype:"float32"}}),m=Hs({inputs:{real:p,imag:d},backend:t});return t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(p),m}if(s.dtype==="complex64"){const d=nh({inputs:{input:s},backend:t}),p=du({inputs:{x:d},backend:t,attrs:{dtype:o}});return t.disposeIntermediateTensorInfo(d),p}if(!wE(s.dtype,o)){const d=wa({inputs:{x:s},backend:t});return{dataId:d.dataId,shape:d.shape,dtype:o}}const i=t.data.get(s.dataId).values,[a,l,c]=ZD(i,s.shape,s.dtype,o);return t.makeTensorInfo(a,l,c)}const JK={kernelName:ug,backendName:"cpu",kernelFunc:du};function lr(n,e,t,r){return t==null?({inputs:s,backend:o})=>{const{a:i,b:a}=s,l=o;Ye([i,a],n);const c=l.data.get(i.dataId).values,d=l.data.get(a.dataId).values,p=i.dtype==="string"?il(c):c,m=i.dtype==="string"?il(d):d,y=r||i.dtype,[v,b]=e(i.shape,a.shape,p,m,y);return l.makeTensorInfo(b,y,v)}:({inputs:s,backend:o})=>{const{a:i,b:a}=s,l=o;if(i.dtype==="complex64"||a.dtype==="complex64"){const c=du({inputs:{x:i},backend:l,attrs:{dtype:"complex64"}}),d=l.data.get(c.dataId),p=d.complexTensorInfos.real,m=d.complexTensorInfos.imag,y=l.data.get(p.dataId).values,v=l.data.get(m.dataId).values,b=du({inputs:{x:a},backend:l,attrs:{dtype:"complex64"}}),w=l.data.get(b.dataId),k=w.complexTensorInfos.real,I=w.complexTensorInfos.imag,N=l.data.get(k.dataId).values,T=l.data.get(I.dataId).values,[A,O,P]=t(i.shape,a.shape,y,v,N,T),B=l.makeTensorInfo(P,"float32",A),z=l.makeTensorInfo(P,"float32",O),L=Hs({inputs:{real:B,imag:z},backend:l});return l.disposeIntermediateTensorInfo(c),l.disposeIntermediateTensorInfo(b),l.disposeIntermediateTensorInfo(B),l.disposeIntermediateTensorInfo(z),L}else{const c=l.data.get(i.dataId).values,d=l.data.get(a.dataId).values,p=r||i.dtype,[m,y]=e(i.shape,a.shape,c,d,p);return l.makeTensorInfo(y,p,m)}}}function _I(n){return(e,t,r,s,o,i)=>{const a=gt(e,t),l=Se(a),c=a.length,d=tt(a),p=Vr("float32",l),m=Vr("float32",l),y=uf(e,a),v=uf(t,a),b=ol(r,s),w=ol(o,i),k=e.length,I=tt(e),N=t.length,T=tt(t);if(y.length+v.length===0)for(let A=0;A<p.length;A++){const O=A%b.length,P=A%w.length,B=n(b[O*2],b[O*2+1],w[P*2],w[P*2+1]);p[A]=B.real,m[A]=B.imag}else for(let A=0;A<p.length;A++){const O=Sf(A,c,d),P=O.slice(-k);y.forEach(H=>P[H]=0);const B=ca(P,k,I),z=O.slice(-N);v.forEach(H=>z[H]=0);const L=ca(z,N,T),_=n(b[B*2],b[B*2+1],w[L*2],w[L*2+1]);p[A]=_.real,m[A]=_.imag}return[p,m,a]}}const eO=Gn(((n,e)=>n+e)),ZK=_I(((n,e,t,r)=>({real:n+t,imag:e+r}))),df=lr(kf,eO,ZK),e7={kernelName:kf,backendName:"cpu",kernelFunc:df};function DI(n,e,t,r,s){const o=Se(r),i=Gr(s,t);for(let a=0;a<n.length;a++){const l=n[a];if(l<0)throw new Error("Input x must be non-negative!");l>=s||(o>0?i[l]+=e[a]:i[l]+=1)}return i}function tO(n,e,t,r=!1){const s=n.shape[0],o=n.shape[1],i=Nt([s,t],e.dtype);for(let a=0;a<s;a++)for(let l=0;l<o;l++){const c=n.get(a,l);if(c<0)throw new Error("Input x must be non-negative!");c>=t||(r?i.set(1,a,c):e.size>0?i.set(i.get(a,c)+e.get(a,l),a,c):i.set(i.get(a,c)+1,a,c))}return i}const nO=Gn(((n,e)=>n&e)),t7=lr(kS,nO),n7={kernelName:kS,backendName:"cpu",kernelFunc:t7};function ba(n){return(e,t,r)=>{const s=Mn(t,e.length);for(let o=0;o<e.length;++o)s[o]=n(e[o],r);return s}}function sn(n,e,t){const r=ba(e);return Su(n,r,t)}function Su(n,e,t){return({inputs:r,attrs:s,backend:o})=>{const{x:i}=r;Ye(i,n);const a=o,l=a.data.get(i.dataId).values;let c;if(i.dtype==="string"){if(!Array.isArray(l))throw new Error("String tensor's value was not an instance of Array");c=il(l)}else c=l;const d=t||i.dtype,p=e(c,d,s);return a.makeTensorInfo(i.shape,d,p)}}const rO=ba(n=>Math.ceil(n)),r7=Su(cg,rO),s7={kernelName:cg,backendName:"cpu",kernelFunc:r7};function sO(n,e,t,r){const s=Mn(t,Se(e));if(r&&t!=="string"){let o=0;n.forEach(i=>{const a=Se(i.shape);s.set(i.vals,o),o+=a})}else{let o=0;n.forEach(i=>{const a=t==="string"?il(i.vals):i.vals;let l=0;for(let c=0;c<i.shape[0];++c){const d=c*e[1]+o;for(let p=0;p<i.shape[1];++p)s[d+p]=a[l++]}o+=i.shape[1]})}return s}const oO=Gn((n,e)=>n===e?1:0),iO=lr(O1,oO,null,"bool"),o7={kernelName:O1,backendName:"cpu",kernelFunc:iO};const aO=ba(n=>Math.exp(n)),lO=Su(xg,aO,"float32"),i7={kernelName:xg,backendName:"cpu",kernelFunc:lO};const uO=ba(n=>Math.expm1(n)),a7=Su(yg,uO),l7={kernelName:yg,backendName:"cpu",kernelFunc:a7};const cO=ba(n=>Math.floor(n)),u7=Su(vg,cO),c7={kernelName:vg,backendName:"cpu",kernelFunc:u7};const hO=Gn((n,e)=>Math.floor(n/e)),h7=lr(wg,hO,null,"int32"),d7={kernelName:wg,backendName:"cpu",kernelFunc:h7};function dO(n,e,t,r,s,o,i,a,l){const c=Nt([r,o],t);for(let d=0;d<r;d++){const p=[];let m=0;for(let y=0;y<s;y++){const v=n[d*s+y];m+=v*i[y],p.push(v)}if(m<0||m>=l/o)throw new Error(`Invalid indices: ${p} does not index into ${a}`);for(let y=0;y<o;y++)c.values[d*o+y]=e.get(...e.indexToLoc(m*o+y))}return c}function fO(n,e,t){const r=Nt(t,n.dtype);for(let s=0;s<r.size;++s){const i=r.indexToLoc(s).slice(),a=i[0],l=i[2],c=e.locToIndex([a,l]);i[2]=e.values[c];const d=n.locToIndex(i);0<=d&&d<n.values.length&&(r.values[s]=n.values[d])}return r}const pO=Gn((n,e)=>n>e?1:0),f7=lr(M1,pO,null,"bool"),p7={kernelName:M1,backendName:"cpu",kernelFunc:f7};const mO=Gn((n,e)=>n>=e?1:0),m7=lr(bg,mO,null,"bool"),g7={kernelName:bg,backendName:"cpu",kernelFunc:m7};const gO=Gn((n,e)=>n<e?1:0),x7=lr(B1,gO,null,"bool"),y7={kernelName:B1,backendName:"cpu",kernelFunc:x7};const xO=Gn((n,e)=>n<=e?1:0),v7=lr(U1,xO,null,"bool"),w7={kernelName:U1,backendName:"cpu",kernelFunc:v7};function yO(n,e,t){const r=(e-n)/(t-1),s=Gr(t,"float32");s[0]=n;for(let o=1;o<s.length;o++)s[o]=s[o-1]+r;return s}const vO=ba(n=>Math.log(n)),b7=Su($g,vO),C7={kernelName:$g,backendName:"cpu",kernelFunc:b7};function wO(n,e,t,r){const s=Vr(r,Se(t));for(let o=0;o<s.length;++o){const i=o*e;let a=n[i];for(let l=0;l<e;++l){const c=n[i+l];(Number.isNaN(c)||c>a)&&(a=c)}s[o]=a}return s}const bO=Gn(((n,e)=>Math.max(n,e))),S7=lr(Tg,bO),k7={kernelName:Tg,backendName:"cpu",kernelFunc:S7};const CO=Gn(((n,e)=>Math.min(n,e))),I7=lr(Eg,CO),$7={kernelName:Eg,backendName:"cpu",kernelFunc:I7};const OI=Gn(((n,e)=>n*e)),N7=_I(((n,e,t,r)=>({real:n*t-e*r,imag:n*r+e*t}))),Uv=lr(Ag,OI,N7),T7={kernelName:Ag,backendName:"cpu",kernelFunc:Uv};function SO(n,e,t){const r=mu(-1,t);return OI([],e,r,n,t)}function E7(n){const{inputs:e,backend:t}=n,{x:r}=e;Ye(r,"neg");const s=t.data.get(r.dataId).values,[o,i]=SO(s,r.shape,r.dtype);return t.makeTensorInfo(i,r.dtype,o)}const R7={kernelName:J1,backendName:"cpu",kernelFunc:E7};const kO=Gn(((n,e)=>n!==e?1:0)),A7=lr(Z1,kO,null,"bool"),_7={kernelName:Z1,backendName:"cpu",kernelFunc:A7};function FI(n,e,t,r,s){const o=e.length,i=Se(e),a=tt(e),l=tt(s),c=Vr(t,Se(s));for(let d=0;d<i;++d){const p=Sf(d,o,a),m=new Array(p.length);for(let v=0;v<m.length;v++)m[v]=p[r[v]];const y=ca(m,o,l);c[y]=n[d]}return c}function Ns(n){const{inputs:e,attrs:t,backend:r}=n,{x:s}=e,{perm:o}=t;Ye(s,"transpose");const i=s.shape.length,a=new Array(i);for(let p=0;p<a.length;p++)a[p]=s.shape[o[p]];const l=r.data.get(s.dataId).values,c=FI(l,s.shape,s.dtype,o,a);return{dataId:r.write(c,a,s.dtype),shape:a,dtype:s.dtype}}const D7={kernelName:ef,backendName:"cpu",kernelFunc:Ns};function IO(n,e,t,r){const[s,o]=yr(n,r),i=Ys(e,"int32"),a=Gr(Se(s),i),l=Se(o);for(let c=0;c<a.length;++c){const d=c*l;let p=1;for(let m=0;m<l;++m)p*=t[d+m];a[c]=p}return{outVals:a,outShape:s,outDtype:i}}function O7(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o,keepDims:i}=r;Ye(s,"prod");const a=s.shape.length,l=Tt(o,s.shape),c=En(l,a);let d=l,p=s;const m=[];c!=null&&(p=Ns({inputs:{x:s},backend:t,attrs:{perm:c}}),m.push(p),d=Wn(d.length,a));const y=t.data.get(p.dataId).values,{outVals:v,outShape:b,outDtype:w}=IO(p.shape,p.dtype,y,d);let k=b;return i&&(k=Yn(b,l)),m.forEach(I=>t.disposeIntermediateTensorInfo(I)),t.makeTensorInfo(k,w,v)}const F7={kernelName:ov,backendName:"cpu",kernelFunc:O7};function P7(n,e,t){n.forEach((r,s)=>{if(r<0||r>=t){const o=Sf(s,e.length,tt(e)).join(",");throw new Error(`indices[${o}] = ${r} is not in [0, ${t})`)}})}function L7(n,e){for(let t=0;t<n.length;++t){const r=n[t],s=t===n.length-1?e:n[t+1].length;if(r.length===0)throw new Error("Ragged splits may not be empty");if(r[0]<0)throw new Error("Ragged splits must be non-negative");if(r[r.length-1]>s)throw new Error("Ragged splits must not point past values");for(let o=1;o<r.length;++o)if(r[o-1]>r[o])throw new Error("Ragged splits must be sorted in ascending order")}}function M7(n,e,t,r){const s=[];let o=0;const i=e.length-1+t.length,a=new Array(i).fill(null).map(()=>[0]);L7(t,r);let l=1;for(let c=0;c<e.length-1;++c){l*=e[c];const d=e[c+1];for(let p=1;p<l+1;++p)a[c].push(p*d)}for(let c=0;c<n.length;++c){let d=n[c],p=n[c]+1;for(let m=0;m<t.length;++m){const y=t[m],v=m+e.length-1;if(v>=0){const b=a[v],w=b[b.length-1]-y[d];for(let k=d;k<p;++k)a[v].push(y[k+1]+w)}d=y[d],p=y[p]}p!==d&&(s.push([d,p]),o+=p-d)}return{outSplits:a,valueSlices:s,numValues:o}}function z7(n){const e=[];for(let t=0;t<n.length;++t){const r=n[t].length,s=Mn("int32",r);e.push(s),n[t].forEach((o,i)=>s[i]=o)}return e}function D2(n,e){const t=n.slice(0,e);for(;t.length<e;)t.push(1);for(let r=e;r<n.length;r++)t[e-1]*=n[r];return t}function B7(n,e,t,r,s,o){const i=D2(e,2)[1],a=D2(o,2)[1];let l=0;for(const c of t)for(let d=c[0];d<c[1];++d){for(let p=0;p<r;++p)s[l*a+p]=n[d*i+p];++l}}function U7(n,e,t,r,s){const o=e.slice();o[0]=s;const i=Mn(t,Se(o)),a=n.length,l=a===0?0:a/e[0];return B7(n,e,r,l,i,o),[i,o]}function $O(n,e,t,r,s,o,i,a){if(n.length===0)throw new Error("paramsNestedSplits must be non empty");if(e[0].length===0)throw new Error("Split tensors must not be scalars");const l=e[0][0]-1;if(P7(o,i,l),r.length===0)throw new Error("params.rank must be nonzero");const c=r[0],{outSplits:d,valueSlices:p,numValues:m}=M7(o,i,n,c),y=z7(d),v=U7(t,r,s,p,m);return[y,v[0],v[1]]}const O2=2147483647;function NO(n,e,t,r,s,o,i){if(e.length>1)throw new Error("starts must be a scalar or vector");if(s.length>1)throw new Error("limits must be a scalar or vector");if(i.length>1)throw new Error("deltas must be a scalar or vector");const a=e.length===0,l=s.length===0,c=i.length===0,d=[];a||d.push(e[0]),l||d.push(s[0]),c||d.push(i[0]);for(let w=1;w<d.length;++w)if(d[w]!==d[w-1])throw new Error("starts, limits, and deltas must have the same shape");const p=d.length===0?1:d[0],m=Mn("int32",p+1);m[0]=0;for(let w=0;w<p;++w){const k=a?n[0]:n[w],I=l?r[0]:r[w],N=c?o[0]:o[w];if(N===0)throw new Error("Requires delta != 0");let T;if(N>0&&I<k||N<0&&I>k)T=0;else if(T=Math.ceil(Math.abs((I-k)/N)),T>O2)throw new Error(`Requires ((limit - start) / delta) <= ${O2}`);m[w+1]=m[w]+T}const y=m[p],v=Mn(t,y);let b=0;for(let w=0;w<p;++w){const k=m[w+1]-m[w];let I=a?n[0]:n[w];const N=c?o[0]:o[w];for(let T=0;T<k;++T)v[b++]=I,I+=N}return[m,v]}var Wo=vi;class s1{constructor(e,t,r,s,o,i,a,l,c,d){this.shape=e,this.shapeShape=t,this.values=r,this.valuesShape=s,this.valuesDType=o,this.defaultValue=i,this.defaultValueShape=a,this.rowPartitionValues=l,this.rowPartitionValuesShapes=c,this.rowPartitionTypes=dA(d),this.raggedRank=fA(this.rowPartitionTypes)}getRowPartitionTypeByDimension(e){return this.rowPartitionTypes[0]===Wo.FIRST_DIM_SIZE?this.rowPartitionTypes[e+1]:this.rowPartitionTypes[e]}getRowPartitionTensor(e){return this.rowPartitionTypes[0]===Wo.FIRST_DIM_SIZE?this.rowPartitionValues[e+1]:this.rowPartitionValues[e]}getMaxWidth(e){const t=this.getRowPartitionTensor(e-1);switch(this.getRowPartitionTypeByDimension(e-1)){case Wo.VALUE_ROWIDS:return s1.getMaxWidthValueRowID(t);case Wo.ROW_SPLITS:return s1.getMaxWidthRowSplit(t);default:throw new Error(`Cannot handle partition type ${Wo[this.getRowPartitionTypeByDimension(e-1)]}`)}}static getMaxWidthRowSplit(e){const t=e.length;if(t===0||t===1)return 0;let r=0;for(let s=0;s<t-1;++s){const o=e[s+1]-e[s];o>r&&(r=o)}return r}static getMaxWidthValueRowID(e){const t=e.length;if(t===0)return 0;let r=0,s=e[0],o=0;for(let i=1;i<t;++i){const a=e[i];a!==s&&(s=a,o=Math.max(i-r,o),r=i)}return Math.max(t-r,o)}tensorShapeFromTensor(e,t,r=!0){if(t.length===0){if(e[0]===-1)return[];throw new Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.")}return P2(e,r)}calculateOutputSize(e){const t=this.valuesShape,r=this.defaultValueShape;pA(r,t);const s=this.tensorShapeFromTensor(this.shape,this.shapeShape),i=hA(this.raggedRank,s,t);i[0]<0&&(i[0]=e);for(let a=1;a<=this.raggedRank;++a)i[a]<0&&(i[a]=this.getMaxWidth(a));return i}calculateFirstParentOutputIndex(e,t,r){const s=Math.min(e,r),o=[];let i=0;for(let a=0;a<s;++a,i+=t)o.push(i);for(let a=s;a<e;++a)o.push(-1);return U(o.length===e,()=>"Final length of result must be equal to firstDimension."),o}calculateOutputIndexRowSplit(e,t,r,s){const o=e.length,i=[];for(let a=0;a<o-1;++a){const l=e[a+1]-e[a];let c=Math.min(s,l),d=t[a];d===-1&&(c=0);for(let p=0;p<c;++p)i.push(d),d+=r;for(let p=0;p<l-c;++p)i.push(-1)}if(o>0&&i.length!==e[o-1])throw new Error("Invalid row split size.");return i}calculateOutputIndexValueRowID(e,t,r,s){const o=e.length,i=[];if(o===0)return[];let a=0,l=e[0];if(l>=t.length)throw new Error(`Got currentValueRowId=${l}, which is not less than ${t.length}`);let c=t[l];i.push(c);for(let d=1;d<o;++d){const p=e[d];if(p===l)c>=0&&(++a,a<s?c+=r:c=-1);else{if(a=0,l=p,p>=t.length)throw new Error(`Got nextValueRowId=${p} which is not less than ${t.length}`);c=t[p]}i.push(c)}if(i.length!==e.length)throw new Error("Invalid row ids.");return i}calculateOutputIndex(e,t,r,s){const o=this.getRowPartitionTensor(e),i=this.getRowPartitionTypeByDimension(e);switch(i){case Wo.VALUE_ROWIDS:return this.calculateOutputIndexValueRowID(o,t,r,s);case Wo.ROW_SPLITS:if(o.length-1>t.length)throw new Error(`Row partition size is greater than output size: ${o.length-1} > ${t.length}`);return this.calculateOutputIndexRowSplit(o,t,r,s);default:throw new Error(`Unsupported partition type: ${Wo[i]}`)}}getFirstDimensionSize(){const e=this.rowPartitionValues[0];if(this.rowPartitionTypes.length===0)throw new Error("No row_partition_types given.");const t=this.rowPartitionTypes[0];switch(t){case Wo.FIRST_DIM_SIZE:return e[0];case Wo.VALUE_ROWIDS:throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");case Wo.ROW_SPLITS:return this.rowPartitionValuesShapes[0][0]-1;default:throw new Error(`Cannot handle type ${Wo[t]}`)}}compute(){if(this.rowPartitionValues[0].length<=0)throw new Error("Invalid first partition input. Tensor requires at least one element.");const t=this.getFirstDimensionSize(),r=this.calculateOutputSize(t),s=new Array(this.raggedRank+1);s[s.length-1]=1;for(let l=s.length-2;l>=0;--l)s[l]=s[l+1]*r[l+1];const o=P2(r,!1),i=Mn(this.valuesDType,Se(o));if(s[0]*r[0]>0){let l=this.calculateFirstParentOutputIndex(t,s[0],r[0]);for(let c=1;c<=this.raggedRank;++c)l=this.calculateOutputIndex(c-1,l,s[c],r[c]);this.setOutput(this.raggedRank,l,i,o)}return[o,i]}setOutput(e,t,r,s){if(r.length===0)return;const o=this.values,i=r;let a=s.slice();a=a.slice(e+1);const l=Se(a),c=t.length;let d=this.defaultValue;if(d.length!==l&&d.length!==1){const v=this.defaultValueShape;me(()=>{const b=ce(d,v);d=Nm(b,a).dataSync()})}let p=0,m=0,y=0;for(let v=0;v<=c;++v){let b=v<c?t[v]:-1;if(b===y){++y;continue}if(m<y){const w=o.subarray(p*l),k=i.subarray(m*l),I=(y-m)*l;F2(k,w,I)}if(v>=c){const w=r.length;b=Math.floor(w/l)}if(b>y)if(this.defaultValue.length===1)i.subarray(y*l,b*l).fill(this.defaultValue[0]),y=b;else for(;b>y;){const w=i.slice(y*l);F2(w,d,l),++y}b<0?(p=v+1,m=y):(p=v,m=y,y=m+1)}}}function F2(n,e,t){for(let r=0;r<t;r++)n[r]=e[r]}function P2(n,e){const t=[];for(let r of n){if(r<0){if(!e)throw new Error(`Dimension ${r} must be >= 0`);if(r<-1)throw new Error(`Dimension ${r} must be >= -1`);r=-1}t.push(r)}return t}function TO(n,e,t,r,s,o,i,a,l,c){return new s1(n,e,t,r,s,o,i,a,l,c).compute()}function EO(n,e,t,r){const s=n===e,o=n<e&&t<0,i=e<n&&t>1;if(s||o||i)return Gr(0,r);const a=Math.abs(Math.ceil((e-n)/t)),l=Gr(a,r);e<n&&t===1&&(t=-1),l[0]=n;for(let c=1;c<l.length;c++)l[c]=l[c-1]+t;return l}const RO=ba(n=>1/Math.sqrt(n)),W7=Su(Lg,RO),V7={kernelName:Lg,backendName:"cpu",kernelFunc:W7};function Fc(n,e,t,r,s,o,i,a,l,c){const d=[r/s,s],p=n.values,m=e.values;if(r===0)return Nt(t,e.dtype);const y=l instanceof Ar?l:Nt(d,e.dtype);typeof l=="string"||typeof l=="number"?y.values.fill(l):typeof l=="boolean"&&y.values.fill(+l);for(let v=0;v<o;v++){const b=[];let w=0;for(let k=0;k<i;k++){const I=p[v*i+k];b.push(I),w+=I*a[k]}if(w<0||w>=r/s)throw new Error(`Invalid indices: ${b} does not index into ${t}`);for(let k=0;k<s;k++)c?y.values[w*s+k]+=m[v*s+k]:y.values[w*s+k]=e.rank===0?m[0]:m[v*s+k]}return y}const G7=ba(n=>1/(1+Math.exp(-n))),AO=sn(Wg,n=>1/(1+Math.exp(-n))),j7={kernelName:Wg,backendName:"cpu",kernelFunc:AO};function _O(n,e,t,r,s){const o=Wk(r,e,t),i=Se(t),a=tt(r);if(o){const p=Vk(e,a);return s==="string"?n.slice(p,p+i):n.subarray(p,p+i)}const l=s==="string"?il(n):n,c=Nt(r,s,l),d=Nt(t,s);for(let p=0;p<d.size;++p){const m=d.indexToLoc(p),y=m.map((v,b)=>v+e[b]);d.set(c.get(...y),...m)}return s==="string"?OA(d.values):d.values}function rh(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{begin:o,size:i}=r;Ye(s,"slice");const[a,l]=$v(s,o,i);Bk(s,a,l);const c=t.data.get(s.dataId).values,d=_O(c,a,l,s.shape,s.dtype);return t.makeTensorInfo(l,s.dtype,d)}const H7={kernelName:hv,backendName:"cpu",kernelFunc:rh};function DO(n,e,t,r,s,o,i){const a=e[0],l=o[0],c=new Array(l),d=new Array(a),p=e[1];if(l===0){if(a!==0)throw new Error(bA(a));const w=Mn(t,0),k=Mn(s,0);return[w,[0,p],k,c,d]}let m=!0,y=0;const v=new Array(l).fill(0);for(let w=0;w<a;++w){const k=n[w*p];if(k<0)throw new Error(CA(w,k));if(k>=l)throw new Error(SA(w,k,l));++v[k],m=m&&k>=y,y=k}let b=!0;for(let w=0;w<l;++w){const k=v[w]===0;c[w]=k,b=b&&!k,v[w]=Math.max(v[w],1),w>0&&(v[w]+=v[w-1])}if(b&&m){const w=n,k=r;for(let I=0;I<a;++I)d[I]=I;return[w,[a,p],k,c,d]}else{const w=v[l-1],k=Mn(t,w*p),I=Mn(s,w),N=new Array(l).fill(0);for(let T=0;T<a;++T){const A=n[T*p],O=N[A],P=(A===0?0:v[A-1])+O;N[A]++;for(let B=0;B<p;++B)k[P*p+B]=n[T*p+B];I[P]=r[T],d[T]=P}for(let T=0;T<l;++T)if(N[T]===0){const O=T===0?0:v[T-1];k[O*p+0]=T;for(let P=1;P<p;++P)k[O*p+P]=0;I[O]=i}return[k,[w,p],I,c,d]}}function OO(n,e,t,r,s){const o=Se(r),i=e[0],a=s.length,l=[];let c=1,d=-1;for(let w=0;w<a;++w){const k=s[w];if(k===-1){if(d!==-1)throw new Error(kA(d,w));d=w,l.push(1)}else{if(k<0)throw new Error(IA(w,k));c*=k,l.push(k)}}if(d!==-1){if(c<=0)throw new Error($A());const w=Math.trunc(o/c);if(c*w!==o)throw new Error(NA(r,l));l[d]=w}if(Se(l)!==o)throw new Error(TA(r,l));const m=r.length,y=[];if(m>0){y[m-1]=1;for(let w=m-2;w>=0;--w)y[w]=y[w+1]*r[w+1]}const v=[];if(a>0){v[a-1]=1;for(let w=a-2;w>=0;--w)v[w]=v[w+1]*l[w+1]}const b=Mn(t,i*a);for(let w=0;w<i;++w){let k=0;for(let I=0;I<m;++I)k+=n[w*m+I]*y[I];for(let I=0;I<a;++I)b[w*a+I]=Math.trunc(k/v[I]),k%=v[I]}return[b,[i,a],l]}function PI(n,e,t,r,s,o=!1,i=0){const a=r.length,l=[e[0],n.length/e[0]],c=l[1],p=a>0?s[a-1]+1:0;if(p<0)throw new Error(IC());const m=e.slice();m[0]=p;const y=m.reduce((N,T)=>N*T,1),v=Mn(t,y);if(a===0)return p>0&&v.fill(i),[v,m];if(p<=0)throw new Error(IC());let b=0,w=1,k=0,I=s[b];for(;;){let N=0;if(w<a){if(N=s[w],I===N){++w;continue}if(I>=N)throw new Error(EA())}if(I<0||I>=p)throw new Error(RA(I,p));I>k&&v.fill(i,k*c,I*c);for(let T=b;T<w;++T){const A=r[T];if(A<0||A>=l[0])throw new Error(AA(T,r[T],l[0]));for(let O=0;O<c;O++)v[I*c+O]+=n[A*c+O]}if(o)for(let T=0;T<c;T++)v[I*c+T]/=w-b;if(b=w,++w,k=I+1,I=N,w>a)break}return k<p&&v.fill(i,k*c,p*c),[v,m]}const q7=ba(n=>Math.sqrt(n)),K7=sn(Gg,n=>Math.sqrt(n)),X7={kernelName:Gg,backendName:"cpu",kernelFunc:K7};const FO=Gn(((n,e)=>{const t=n-e;return t*t})),Y7=lr(jg,FO),Q7={kernelName:jg,backendName:"cpu",kernelFunc:Y7};const PO=ba((n,e)=>{const{pattern:t,replaceGlobal:r,rewrite:s}=e;return n.replace(new RegExp(t,r?"g":""),s)}),J7=Su(ZS,PO),Z7={kernelName:ZS,backendName:"cpu",kernelFunc:J7};function LO(n,e,t,r){const s=Nt(n,e.dtype);for(let o=0;o<s.size;o++){const i=s.indexToLoc(o),a=new Array(i.length);for(let l=0;l<a.length;l++)a[l]=i[l]*t[l]+r[l];s.set(e.get(...a),...i)}return s}class eX{constructor(e,t,r,s,o,i){this.separator=su(e),this.nGramWidths=t,this.leftPad=su(r),this.rightPad=su(s),this.padWidth=o,this.preserveShort=i}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,t){const r=this.getPadWidth(t);return Math.max(0,e+2*r-t+1)}createNGrams(e,t,r,s,o,i){for(let a=0;a<o;++a){const l=this.getPadWidth(i),c=Math.max(0,l-a),d=Math.max(0,l-(o-(a+1))),p=i-(c+d),m=t+(c>0?0:a-l);let y=0;y+=c*this.leftPad.length;for(let I=0;I<p;++I)y+=e[m+I].length;y+=d*this.rightPad.length;const v=c+d+p-1;y+=v*this.separator.length,r[s+a]=new Uint8Array(y);const b=r[s+a];let w=0;const k=I=>I.forEach(N=>b[w++]=N);for(let I=0;I<c;++I)k(this.leftPad),k(this.separator);for(let I=0;I<p-1;++I)k(e[m+I]),k(this.separator);if(p>0){k(e[m+p-1]);for(let I=0;I<d;++I)k(this.separator),k(this.rightPad)}else{for(let I=0;I<d-1;++I)k(this.rightPad),k(this.separator);k(this.rightPad)}}}compute(e,t){const r=e.length,s=t.length;if(s>0){let l=t[0];if(l!==0)throw new Error(`First split value must be 0, got ${l}`);for(let c=1;c<s;++c){let d=t[c]>=l;if(d=d&&t[c]<=r,!d)throw new Error(`Invalid split value ${t[c]}, must be in [${l}, ${r}]`);l=t[c]}if(l!==r)throw new Error(`Last split value must be data size. Expected ${r}, got ${l}`)}const o=s-1,i=Mn("int32",s);if(r===0||s===0){const l=new Array(r);for(let c=0;c<=o;++c)i[c]=0;return[l,i]}i[0]=0;for(let l=1;l<=o;++l){const c=t[l]-t[l-1];let d=0;this.nGramWidths.forEach(p=>{d+=this.getNumNGrams(c,p)}),this.preserveShort&&c>0&&d===0&&(d=1),i[l]=i[l-1]+d}const a=new Array(i[o]);for(let l=0;l<o;++l){const c=t[l];let d=i[l];if(this.nGramWidths.forEach(p=>{const m=t[l+1]-t[l],y=this.getNumNGrams(m,p);this.createNGrams(e,c,a,d,y,p),d+=y}),this.preserveShort&&d===i[l]){const p=t[l+1]-t[l];if(p===0)continue;const m=p+2*this.padWidth;this.createNGrams(e,c,a,d,1,m)}}return[a,i]}}function MO(n,e,t,r,s,o,i,a){return new eX(t,r,s,o,i,a).compute(n,e)}function tX(n,e,t,r){if(!n.length)return;if(e.length===0){for(let o=0;o<n.length;++o)r.push(n.subarray(o,o+1));return}if(e.length===1){const o=e[0];let i=n.indexOf(o);for(;i!==-1;){const a=n.subarray(0,i);(!t||a.length!==0)&&r.push(a),n=n.subarray(i+1),i=n.indexOf(o)}(!t||n.length!==0)&&r.push(n);return}let s=0;for(let o=0;o<n.length+1;o++)if(o===n.length||e.indexOf(n[o])!==-1){const i=n.subarray(s,o);(!t||i.length!==0)&&r.push(i),s=o+1}}function zO(n,e,t){const r=n.length,s=[];let o=0,i=0;const a=new Array(r);for(let m=0;m<r;++m){const y=s.length;tX(n[m],e,t,s);const v=s.length-y;a[m]=v,o+=v,i=Math.max(i,v)}const l=Mn("int32",o*2),c=new Array(o),d=[r,i];let p=0;for(let m=0;m<r;++m)for(let y=0;y<a[m];++y)l[p*2]=m,l[p*2+1]=y,c[p]=s[p],++p;return[l,c,d]}function BO(n,e){const t=Mn("int32",n.length);for(let r=0;r<n.length;++r)t[r]=dU(n[r]).modulo(e).getLowBitsUnsigned();return t}const UO=Gn(((n,e)=>n-e)),nX=_I(((n,e,t,r)=>({real:n-t,imag:e-r}))),LI=lr(Hg,UO,nX),rX={kernelName:Hg,backendName:"cpu",kernelFunc:LI};function WO(n,e){const t=new Array(n.rank);for(let s=0;s<t.length;s++)t[s]=n.shape[s]*e[s];const r=Nt(t,n.dtype);for(let s=0;s<r.values.length;++s){const o=r.indexToLoc(s),i=new Array(n.rank);for(let l=0;l<i.length;l++)i[l]=o[l]%n.shape[l];const a=n.locToIndex(i);r.values[s]=n.values[a]}return r}const Cm=(n,e)=>{const t=e.value-n.value;return t===0?n.index-e.index:t};function VO(n,e,t=0,r=n.length-1){for(;r>t;){if(r-t>600){const a=r-t+1,l=e-t+1,c=Math.log(a),d=.5*Math.exp(2*c/3),p=.5*Math.sqrt(c*d*(a-d)/a)*Math.sign(l-a/2),m=Math.max(t,Math.floor(e-l*d/a+p)),y=Math.min(r,Math.floor(e+(a-l)*d/a+p));VO(n,e,m,y)}const s=n[e];let o=t,i=r;for(jd(n,t,e),Cm(n[r],s)>0&&jd(n,t,r);o<i;){for(jd(n,o,i),o++,i--;Cm(n[o],s)<0;)o=o+1;for(;Cm(n[i],s)>0;)i=i-1}Cm(n[t],s)===0?jd(n,t,i):(i=i+1,jd(n,i,r)),i<=e&&(t=i+1),e<=i&&(r=i-1)}}function GO(n,e,t,r,s){const o=e[e.length-1],[i,a]=[n.length/o,o],l=Vr(t,i*r),c=Vr("int32",i*r);for(let p=0;p<i;p++){const m=p*a,y=n.subarray(m,m+a);let v=new Array(y.length);y.forEach((I,N)=>v[N]={value:I,index:N}),r<v.length&&(VO(v,r),v=v.slice(0,r)),s&&v.sort(Cm);const b=p*r,w=l.subarray(b,b+r),k=c.subarray(b,b+r);for(let I=0;I<r;I++)w[I]=v[I].value,k[I]=v[I].index}const d=e.slice();return d[d.length-1]=r,[Nt(d,t,l),Nt(d,"int32",c)]}function jO(n,e,t,r){const s=Tt(e,t)[0],o=[1,t[0],1];for(let v=0;v<s;v++)o[0]*=t[v];o[1]=t[s];for(let v=s+1;v<t.length;v++)o[2]*=t[v];const i=new Map,a=new Int32Array(t[s]),l=new Ar(o,r,n),c=[],d=o[0]===1&&o[2]===1;for(let v=0;v<t[s];v++){let b;if(d)b=n[v].toString();else{const k=[];for(let I=0;I<o[0];I++)for(let N=0;N<o[2];N++)k.push(l.get(I,v,N));b=k.join(",")}const w=i.get(b);if(w!=null)a[v]=w;else{const k=i.size;i.set(b,k),a[v]=k,c.push(v)}}const p=o.slice();p[1]=i.size;const m=new Ar(p,r);c.forEach((v,b)=>{for(let w=0;w<o[0];w++)for(let k=0;k<o[2];k++)m.set(l.get(w,v,k),w,b,k)});const y=t.slice();return y[s]=p[1],{outputValues:m.values,outputShape:y,indices:a}}const sX=Object.freeze(Object.defineProperty({__proto__:null,addImpl:eO,bincountImpl:DI,bincountReduceImpl:tO,bitwiseAndImpl:nO,castImpl:ZD,ceilImpl:rO,concatImpl:sO,equalImpl:oO,expImpl:aO,expm1Impl:uO,floorDivImpl:hO,floorImpl:cO,gatherNdImpl:dO,gatherV2Impl:fO,greaterEqualImpl:mO,greaterImpl:pO,lessEqualImpl:xO,lessImpl:gO,linSpaceImpl:yO,logImpl:vO,maxImpl:wO,maximumImpl:bO,minimumImpl:CO,multiplyImpl:OI,negImpl:SO,notEqualImpl:kO,prodImpl:IO,raggedGatherImpl:$O,raggedRangeImpl:NO,raggedTensorToTensorImpl:TO,rangeImpl:EO,rsqrtImpl:RO,scatterImpl:Fc,sigmoidImpl:G7,simpleAbsImpl:JD,sliceImpl:_O,sparseFillEmptyRowsImpl:DO,sparseReshapeImpl:OO,sparseSegmentReductionImpl:PI,sqrtImpl:q7,squaredDifferenceImpl:FO,staticRegexReplaceImpl:PO,stridedSliceImpl:LO,stringNGramsImpl:MO,stringSplitImpl:zO,stringToHashBucketFastImpl:BO,subImpl:UO,tileImpl:WO,topKImpl:GO,transposeImpl:FI,uniqueImpl:jO},Symbol.toStringTag,{value:"Module"}));uR("cpu",()=>new Bv,1);const HO=sn(mg,n=>n>=0?n:Math.exp(n)-1),oX={kernelName:mg,backendName:"cpu",kernelFunc:HO};function qO(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{alpha:o}=r;Ye([s],"leakyRelu");const i=Se(s.shape),a=t.data.get(s.dataId).values,l=Vr("float32",i);for(let c=0;c<a.length;c++)l[c]=a[c]<0?o*a[c]:a[c];return t.makeTensorInfo(s.shape,"float32",l)}const iX={kernelName:z1,backendName:"cpu",kernelFunc:qO};const aX=Gn((n,e)=>n<0?e*n:n);function KO(n){const{inputs:e,backend:t}=n,{x:r,alpha:s}=e;Ye([r,s],"prelu");const o=t.data.get(r.dataId).values,i=t.data.get(s.dataId).values,[a,l]=aX(r.shape,s.shape,o,i,"float32");return t.makeTensorInfo(l,"float32",a)}const lX={kernelName:sv,backendName:"cpu",kernelFunc:KO};const XO=sn(Og,n=>Math.max(0,n)),uX={kernelName:Og,backendName:"cpu",kernelFunc:XO};const YO=sn(Fg,n=>Math.min(Math.max(0,n),6)),cX={kernelName:Fg,backendName:"cpu",kernelFunc:YO};function o1(n,e,t,r,s){if(t==="linear")return wa({inputs:{x:e},backend:n});if(t==="relu")return XO({inputs:{x:e},backend:n});if(t==="elu")return HO({inputs:{x:e},backend:n});if(t==="relu6")return YO({inputs:{x:e},backend:n});if(t==="prelu")return KO({inputs:{x:e,alpha:r},backend:n});if(t==="leakyrelu")return qO({inputs:{x:e},backend:n,attrs:{alpha:s}});if(t==="sigmoid")return AO({inputs:{x:e},backend:n});throw new Error(`Activation ${t} has not been implemented for the CPU backend.`)}function gn(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{shape:o}=r,i=Se(s.shape),a=vE(o,i),l=Se(a);U(i===l,()=>`The new shape (${a}) has ${l} elements and the old shape (${s.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`),t.incRef(s.dataId);const c=t.data.get(s.dataId);if(c.complexTensorInfos!=null){const d=c.complexTensorInfos.real,p=c.complexTensorInfos.imag;d.shape=a,p.shape=a}return{dataId:s.dataId,shape:a,dtype:s.dtype}}const hX={kernelName:iv,backendName:"cpu",kernelFunc:gn};function QO(n){const{inputs:e,backend:t,attrs:r}=n,{a:s,b:o}=e,{transposeA:i,transposeB:a}=r;Ye([s,o],"matMul");const l=s.shape.length,c=o.shape.length,d=i?s.shape[l-2]:s.shape[l-1],p=a?o.shape[c-1]:o.shape[c-2],m=i?s.shape[l-1]:s.shape[l-2],y=a?o.shape[c-2]:o.shape[c-1],v=s.shape.slice(0,-2),b=o.shape.slice(0,-2),w=Se(v),k=Se(b),N=gt(s.shape.slice(0,-2),o.shape.slice(0,-2)).concat([m,y]);U(d===p,()=>`Error in matMul: inner shapes (${d}) and (${p}) of Tensors with shapes ${s.shape} and ${o.shape} and transposeA=${i} and transposeB=${a} must match.`);const T=i?[w,d,m]:[w,m,d],A=a?[k,y,p]:[k,p,y],O=gn({inputs:{x:s},backend:t,attrs:{shape:T}}),P=gn({inputs:{x:o},backend:t,attrs:{shape:A}}),B=i?O.shape[1]:O.shape[2],z=i?O.shape[2]:O.shape[1],L=a?P.shape[1]:P.shape[2],_=Math.max(w,k),H=t.data.get(O.dataId).values,Y=t.data.get(P.dataId).values,re=tt(O.shape),te=tt(P.shape),[le,de,j]=i?[re[0],1,re[1]]:[re[0],re[1],1],[ie,se,V]=a?[1,te[1],te[0]]:[te[1],1,te[0]],X=z*L,xe=Nt([_,z,L],O.dtype),Ie=xe.values,ke=t.blockSize;for(let Ee=0;Ee<_;Ee++){const Me=Ee%w,ze=Ee%k;for(let Be=0;Be<z;Be+=ke){const Je=Math.min(Be+ke,z);for(let lt=0;lt<L;lt+=ke){const pt=Math.min(lt+ke,L);for(let bt=0;bt<B;bt+=ke){const Rt=Math.min(bt+ke,B);for(let Ot=Be;Ot<Je;Ot++)for(let Bt=lt;Bt<pt;Bt++){let At=0;for(let Yt=bt;Yt<Rt;Yt++){const ds=H[Me*le+Ot*de+Yt*j],Jt=Y[Yt*ie+Bt*se+ze*V];At+=ds*Jt}Ie[Ee*X+(Ot*L+Bt)]+=At}}}}}return t.disposeIntermediateTensorInfo(O),t.disposeIntermediateTensorInfo(P),t.makeTensorInfo(N,xe.dtype,xe.values)}const dX={kernelName:k1,backendName:"cpu",kernelFunc:QO};function fX(n){const{inputs:e,backend:t,attrs:r}=n,{a:s,b:o,bias:i,preluActivationWeights:a}=e,{transposeA:l,transposeB:c,activation:d,leakyreluAlpha:p}=r;let m,y,v;const b=[];m=QO({inputs:{a:s,b:o},attrs:{transposeA:l,transposeB:c},backend:t}),i&&(y=df({inputs:{a:m,b:i},backend:t}),b.push(m),m=y),d&&(v=o1(t,m,d,a,p),b.push(m),m=v);for(const k of b)t.disposeIntermediateTensorInfo(k);return m}const pX={kernelName:Ly,backendName:"cpu",kernelFunc:fX};const mX=sn(ng,n=>Math.acos(n)),gX={kernelName:ng,backendName:"cpu",kernelFunc:mX};const xX=sn(rg,n=>Math.acosh(n)),yX={kernelName:rg,backendName:"cpu",kernelFunc:xX};function vX(n){const{inputs:e,backend:t}=n,r=e;Ye(e,"addN");const s=r.map(a=>t.data.get(a.dataId).values),o=Nt(r[0].shape,r[0].dtype),i=o.values;for(let a=0;a<r.length;a++){const l=s[a];for(let c=0;c<i.length;c++)i[c]+=l[c]}return t.makeTensorInfo(o.shape,o.dtype,o.values)}const wX={kernelName:yS,backendName:"cpu",kernelFunc:vX};function bX(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o,keepDims:i}=r;Ye(s,"all");const a=Tt(o,s.shape);let l=a;const c=En(l,s.shape.length);let d=s;c!=null&&(d=Ns({inputs:{x:s},backend:t,attrs:{perm:c}}),l=Wn(l.length,s.shape.length)),Dr("all",l,d.shape.length);const[p,m]=yr(d.shape,l),y=Se(m),v=Gr(Se(p),d.dtype),b=t.data.get(d.dataId).values;for(let k=0;k<v.length;++k){const I=k*y;let N=b[I];for(let T=0;T<y;++T){const A=b[I+T];N=N&&A}v[k]=N}c!=null&&t.disposeIntermediateTensorInfo(d);const w=t.makeTensorInfo(p,d.dtype,v);if(i){const k=Yn(p,a),I=gn({inputs:{x:w},backend:t,attrs:{shape:k}});return t.disposeIntermediateTensorInfo(w),I}return w}const CX={kernelName:vS,backendName:"cpu",kernelFunc:bX};function SX(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o,keepDims:i}=r;Ye(s,"any");const a=Tt(o,s.shape);let l=a;const c=En(l,s.shape.length);let d=s;c!=null&&(d=Ns({inputs:{x:s},backend:t,attrs:{perm:c}}),l=Wn(l.length,s.shape.length)),Dr("any",l,d.shape.length);const[p,m]=yr(d.shape,l),y=Se(m),v=Gr(Se(p),d.dtype),b=t.data.get(d.dataId).values;for(let k=0;k<v.length;++k){const I=k*y;let N=b[I];for(let T=0;T<y;++T){const A=b[I+T];N=N||A}v[k]=N}c!=null&&t.disposeIntermediateTensorInfo(d);const w=t.makeTensorInfo(p,d.dtype,v);if(i){const k=Yn(p,a),I=gn({inputs:{x:w},backend:t,attrs:{shape:k}});return t.disposeIntermediateTensorInfo(w),I}return w}const kX={kernelName:wS,backendName:"cpu",kernelFunc:SX};function IX(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o}=r;Ye(s,"argMax");let i=Tt(o,s.shape);const a=En(i,s.shape.length);let l=s;const c=[];a!=null&&(l=Ns({inputs:{x:s},backend:t,attrs:{perm:a}}),c.push(l),i=Wn(i.length,l.shape.length)),i=[i[0]],Dr("argMax",i,l.shape.length);const[d,p]=yr(l.shape,i),m=Se(d),y=Gr(m,"int32"),v=Se(p),b=t.data.get(l.dataId).values;for(let w=0;w<y.length;++w){const k=w*v;let I=b[k],N=0;for(let T=0;T<v;++T){const A=b[k+T];A>I&&(I=A,N=T)}y[w]=N}return c.forEach(w=>t.disposeIntermediateTensorInfo(w)),t.makeTensorInfo(d,"int32",y)}const $X={kernelName:w1,backendName:"cpu",kernelFunc:IX};function NX(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o}=r;Ye(s,"argMin");let i=Tt(o,s.shape);const a=En(i,s.shape.length);let l=s;const c=[];a!=null&&(l=Ns({inputs:{x:s},backend:t,attrs:{perm:a}}),c.push(l),i=Wn(i.length,l.shape.length)),i=[i[0]],Dr("argMin",i,l.shape.length);const[d,p]=yr(l.shape,i),m=Se(d),y=Gr(m,"int32"),v=Se(p),b=t.data.get(l.dataId).values;for(let w=0;w<y.length;++w){const k=w*v;let I=b[k],N=0;for(let T=0;T<v;++T){const A=b[k+T];A<I&&(I=A,N=T)}y[w]=N}return c.forEach(w=>t.disposeIntermediateTensorInfo(w)),t.makeTensorInfo(d,"int32",y)}const TX={kernelName:b1,backendName:"cpu",kernelFunc:NX};const EX=sn(sg,n=>Math.asin(n)),RX={kernelName:sg,backendName:"cpu",kernelFunc:EX};const AX=sn(og,n=>Math.asinh(n)),_X={kernelName:og,backendName:"cpu",kernelFunc:AX};const DX=sn(ig,n=>Math.atan(n)),OX={kernelName:ig,backendName:"cpu",kernelFunc:DX};const FX=Gn((n,e)=>Math.atan2(n,e)),PX=lr(lg,FX),LX={kernelName:lg,backendName:"cpu",kernelFunc:PX};const MX=sn(ag,n=>Math.atanh(n)),zX={kernelName:ag,backendName:"cpu",kernelFunc:MX};function MI(n,e,t,r,s,o){const i=s.strideHeight,a=s.strideWidth,l=s.dilationHeight,c=s.dilationWidth,d=s.effectiveFilterHeight,p=s.effectiveFilterWidth,m=s.padInfo.top,y=s.padInfo.left,v=o==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,b=Nt(s.outShape,t),w=b.values,k=s.outShape[1]*s.outShape[2]*s.outShape[3],I=s.outShape[2]*s.outShape[3],N=s.outShape[3];for(let T=0;T<s.batchSize;++T){const A=T*k,O=T*r[0];for(let P=0;P<s.inChannels;++P)for(let B=0;B<s.outHeight;++B){const z=B*i-m,L=Math.max(0,z),_=Math.min(s.inHeight,d+z),H=A+B*I;for(let Y=0;Y<s.outWidth;++Y){const re=Y*a-y,te=Math.max(0,re),le=Math.min(s.inWidth,p+re);let de=v,j=0,ie=0;for(let V=L;V<_;V+=l){const X=O+V*r[1];for(let xe=te;xe<le;xe+=c){const Ie=X+xe*r[2],ke=n[Ie+P];o==="max"&&ke>de?de=ke:o==="avg"&&(j+=ke,ie++)}if(isNaN(de))break}const se=H+Y*N+P;w[se]=o==="avg"?j/ie:de}}}return b}function JO(n,e,t,r,s=!1,o=!1){const i=Nt(r.outShape,"int32"),a=r.strideHeight,l=r.strideWidth,c=r.dilationHeight,d=r.dilationWidth,p=r.effectiveFilterHeight,m=r.effectiveFilterWidth,y=r.padInfo.top,v=r.padInfo.left,b=Nt(e,t,n);for(let w=0;w<r.batchSize;++w)for(let k=0;k<r.inChannels;++k)for(let I=0;I<r.outHeight;++I){const N=I*a-y;let T=N;for(;T<0;)T+=c;const A=Math.min(r.inHeight,p+N);for(let O=0;O<r.outWidth;++O){const P=O*l-v;let B=P;for(;B<0;)B+=d;const z=Math.min(r.inWidth,m+P);let L=Number.NEGATIVE_INFINITY,_=-1;for(let H=T;H<A;H+=c){const Y=H-N;for(let re=B;re<z;re+=d){const te=re-P,le=b.get(w,H,re,k);le>L&&(L=le,s?_=o?((w*r.inHeight+H)*r.inWidth+re)*r.inChannels+k:(H*r.inWidth+re)*r.inChannels+k:_=Y*m+te)}}i.set(_,w,I,O,k)}}return i}function ZO(n,e,t,r,s,o){const i=s.strideDepth,a=s.strideHeight,l=s.strideWidth,c=s.dilationDepth,d=s.dilationHeight,p=s.dilationWidth,m=s.effectiveFilterDepth,y=s.effectiveFilterHeight,v=s.effectiveFilterWidth,b=s.padInfo.front,w=s.padInfo.top,k=s.padInfo.left,I=o==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,N=Nt(s.outShape,t),T=N.values,A=s.outShape[1]*s.outShape[2]*s.outShape[3]*s.outShape[4],O=s.outShape[2]*s.outShape[3]*s.outShape[4],P=s.outShape[3]*s.outShape[4],B=s.outShape[4];for(let z=0;z<s.batchSize;++z){const L=z*A,_=z*r[0];for(let H=0;H<s.inChannels;++H)for(let Y=0;Y<s.outDepth;++Y){const re=Y*i-b;let te=re;for(;te<0;)te+=c;const le=Math.min(s.inDepth,m+re),de=L+Y*O;for(let j=0;j<s.outHeight;++j){const ie=j*a-w;let se=ie;for(;se<0;)se+=d;const V=Math.min(s.inHeight,y+ie),X=de+j*P;for(let xe=0;xe<s.outWidth;++xe){const Ie=xe*l-k;let ke=Ie;for(;ke<0;)ke+=p;const Ee=Math.min(s.inWidth,v+Ie),Me=X+xe*B;let ze=I,Be=0,Je=0;for(let pt=te;pt<le;pt+=c){const bt=_+pt*r[1];for(let Rt=se;Rt<V;Rt+=d){const Ot=bt+Rt*r[2];for(let Bt=ke;Bt<Ee;Bt+=p){const At=Ot+Bt*r[3],Yt=n[At+H];if(o==="max"&&Yt>ze?ze=Yt:o==="avg"&&(Be+=Yt,Je++),isNaN(ze))break}if(isNaN(ze))break}if(isNaN(ze))break}const lt=Me+H;T[lt]=o==="avg"?Be/Math.max(Je,1):ze}}}}return N}function BX(n,e){const t=Nt(e.outShape,"int32"),r=e.strideDepth,s=e.strideHeight,o=e.strideWidth,i=e.dilationDepth,a=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterDepth,d=e.effectiveFilterHeight,p=e.effectiveFilterWidth,m=e.padInfo.front,y=e.padInfo.top,v=e.padInfo.left;for(let b=0;b<e.batchSize;++b)for(let w=0;w<e.inChannels;++w)for(let k=0;k<e.outDepth;++k){const I=k*r-m;let N=I;for(;N<0;)N+=i;const T=Math.min(e.inDepth,c+I);for(let A=0;A<e.outHeight;++A){const O=A*s-y;let P=O;for(;P<0;)P+=a;const B=Math.min(e.inHeight,d+O);for(let z=0;z<e.outWidth;++z){const L=z*o-v;let _=L;for(;_<0;)_+=l;const H=Math.min(e.inWidth,p+L);let Y=Number.NEGATIVE_INFINITY,re=-1;for(let te=N;te<T;te+=i){const le=te-I;for(let de=P;de<B;de+=a){const j=de-O;for(let ie=_;ie<H;ie+=l){const se=ie-L,V=n.get(b,te,de,ie,w);V>=Y&&(Y=V,re=le*d*p+j*d+se)}}}t.set(re,b,k,A,z,w)}}}return t}function UX(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e;Ye(s,"avgPool");const{filterSize:o,strides:i,pad:a,dimRoundingMode:l}=r,c=1;U(Hr(i,c),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const d=Xo(s.shape,o,i,c,a,l);let p;if(d.filterWidth===1&&d.filterHeight===1&&Xt(d.inShape,d.outShape))p=wa({inputs:{x:s},backend:t});else{const m=t.data.get(s.dataId).values,y=tt(s.shape),v=MI(m,s.shape,s.dtype,y,d,"avg");p=t.makeTensorInfo(d.outShape,s.dtype,v.values)}return p}const WX={kernelName:C1,backendName:"cpu",kernelFunc:UX};function VX(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{filterSize:o,strides:i,pad:a,dimRoundingMode:l,dataFormat:c}=r;Ye(s,"avgPool3d");const d=ll(s.shape,o,i,1,a,l,c),p=t.data.get(s.dataId).values,m=ZO(p,s.shape,s.dtype,tt(s.shape),d,"avg");return t.makeTensorInfo(m.shape,"float32",m.values)}const GX={kernelName:S1,backendName:"cpu",kernelFunc:VX};function jX(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,input:o}=e,{filterSize:i,strides:a,pad:l,dimRoundingMode:c}=r;Ye([s,o],"avgPool3DGrad");const d=ll(o.shape,i,a,1,l,c),p=d.strideDepth,m=d.strideHeight,y=d.strideWidth,v=d.filterDepth,b=d.filterHeight,w=d.filterWidth,k=d.dilationDepth,I=d.dilationHeight,N=d.dilationWidth,T=d.effectiveFilterDepth,A=d.effectiveFilterHeight,O=d.effectiveFilterWidth,P=T-1-d.padInfo.front,B=O-1-d.padInfo.left,z=A-1-d.padInfo.top,L=Nt(o.shape,"float32"),_=1/(v*b*w),H=t.bufferSync(s);for(let Y=0;Y<d.batchSize;++Y)for(let re=0;re<d.inChannels;++re)for(let te=0;te<d.inDepth;++te)for(let le=0;le<d.inHeight;++le)for(let de=0;de<d.inWidth;++de){const j=te-P,ie=le-z,se=de-B;let V=0;for(let X=0;X<T;X+=k){const xe=(j+X)/p;if(!(xe<0||xe>=d.outDepth||Math.floor(xe)!==xe))for(let Ie=0;Ie<A;Ie+=I){const ke=(ie+Ie)/m;if(!(ke<0||ke>=d.outHeight||Math.floor(ke)!==ke))for(let Ee=0;Ee<O;Ee+=N){const Me=(se+Ee)/y;if(Me<0||Me>=d.outWidth||Math.floor(Me)!==Me)continue;const ze=H.get(Y,xe,ke,Me,re);V+=ze}}}L.set(V*_,Y,te,le,de,re)}return t.makeTensorInfo(L.shape,L.dtype,L.values)}const HX={kernelName:CS,backendName:"cpu",kernelFunc:jX};function qX(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,input:o}=e,i=o;Ye([s,o],"avgPoolGrad");const{filterSize:a,strides:l,pad:c}=r,d=Xo(i.shape,a,l,1,c),p=d.strideHeight,m=d.strideWidth,y=d.filterHeight,v=d.filterWidth,b=d.dilationHeight,w=d.dilationWidth,k=d.effectiveFilterHeight,I=d.effectiveFilterWidth,N=I-1-d.padInfo.left,T=k-1-d.padInfo.top,A=Nt(i.shape,"float32"),O=1/(y*v),P=t.data.get(s.dataId).values,B=Nt(s.shape,"float32",P);for(let z=0;z<d.batchSize;++z)for(let L=0;L<d.inChannels;++L)for(let _=0;_<d.inHeight;++_)for(let H=0;H<d.inWidth;++H){const Y=_-T,re=H-N;let te=0;for(let le=0;le<k;le+=b){const de=(Y+le)/p;if(!(de<0||de>=d.outHeight||Math.floor(de)!==de))for(let j=0;j<I;j+=w){const ie=(re+j)/m;if(ie<0||ie>=d.outWidth||Math.floor(ie)!==ie)continue;const se=B.get(z,de,ie,L);te+=se}}A.set(te*O,z,_,H,L)}return t.makeTensorInfo(A.shape,A.dtype,A.values)}const KX={kernelName:bS,backendName:"cpu",kernelFunc:qX};function XX(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,scale:o,offset:i,mean:a,variance:l}=e;U(a.shape.length===l.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),U(i==null||a.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),U(o==null||a.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks."),Ye([s,a,l,o,i],"batchNorm");let{varianceEpsilon:c}=r;c==null&&(c=.001);const d=t.data.get(s.dataId).values,p=t.data.get(a.dataId).values,m=t.data.get(l.dataId).values,y=o?t.data.get(o.dataId).values:new Float32Array([1]),v=i?t.data.get(i.dataId).values:new Float32Array([0]),b=new Float32Array(d.length),w=v.length,k=y.length,I=m.length,N=p.length;let T=0,A=0,O=0,P=0;for(let B=0;B<d.length;++B)b[B]=v[T++]+(d[B]-p[A++])*y[O++]/Math.sqrt(m[P++]+c),T>=w&&(T=0),A>=N&&(A=0),O>=k&&(O=0),P>=I&&(P=0);return t.makeTensorInfo(s.shape,s.dtype,b)}const YX={kernelName:P1,backendName:"cpu",kernelFunc:XX};function QX(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{blockShape:o,crops:i}=r;Ye([s],"batchToSpaceND");const a=o.reduce((k,I)=>k*I),l=sx(s.shape,o,a),c=ox(l.length,o.length),d=ix(s.shape,o,a),p=Kk(i,o.length),m=Xk(d,i,o.length),y=gn({inputs:{x:s},backend:t,attrs:{shape:l}}),v=Ns({inputs:{x:y},backend:t,attrs:{perm:c}}),b=gn({inputs:{x:v},backend:t,attrs:{shape:d}}),w=rh({inputs:{x:b},backend:t,attrs:{begin:p,size:m}});return t.disposeIntermediateTensorInfo(y),t.disposeIntermediateTensorInfo(v),t.disposeIntermediateTensorInfo(b),w}const JX={kernelName:I1,backendName:"cpu",kernelFunc:QX};function ZX(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,weights:o}=e,{size:i}=r,a=t.data.get(s.dataId).values,l=t.data.get(o.dataId).values,c=DI(a,l,o.dtype,o.shape,i);return t.makeTensorInfo([i],o.dtype,c)}const e9={kernelName:SS,backendName:"cpu",kernelFunc:ZX};function t9(n){const{inputs:e,backend:t}=n,{s0:r,s1:s}=e,o=t.data.get(r.dataId).values,i=t.data.get(s.dataId).values,a=gt(Array.from(o),Array.from(i));return t.makeTensorInfo([a.length],"int32",Int32Array.from(a))}const n9={kernelName:IE,backendName:"cpu",kernelFunc:t9};const r9=sn(hg,(n,e)=>{const t=e;return n>t.clipValueMax?t.clipValueMax:n<t.clipValueMin?t.clipValueMin:n}),s9={kernelName:hg,backendName:"cpu",kernelFunc:r9};const o9=n=>{const{x:e}=n.inputs,t=n.backend,r=new Float32Array(Se(e.shape)),s=t.data.get(e.dataId),o=s.complexTensorInfos.real,i=s.complexTensorInfos.imag,a=t.data.get(o.dataId).values,l=t.data.get(i.dataId).values;for(let c=0;c<a.length;c++){const d=a[c],p=l[c];r[c]=Math.hypot(d,p)}return t.makeOutput(r,e.shape,"float32")},i9={kernelName:$1,backendName:"cpu",kernelFunc:o9};function ff(n){const{inputs:e,backend:t}=n,{input:r}=e,s=t.data.get(r.dataId).complexTensorInfos.imag,o=t.data.get(s.dataId).values;return t.makeTensorInfo(s.shape,s.dtype,o)}const a9={kernelName:US,backendName:"cpu",kernelFunc:ff};function pf(n){const{inputs:e,backend:t,attrs:r}=n,{axis:s}=r,o=Tt(s,e[0].shape)[0],i=e.map(b=>b.shape);jk(i,o);let a=da(e.map(b=>b.shape),o);if(Se(a)===0)return t.makeTensorInfo(a,e[0].dtype,[]);const l=e.filter(b=>Se(b.shape)>0);if(l.length===1)return wa({inputs:{x:l[0]},backend:t});if(l[0].dtype==="complex64"){const b=l.map(T=>nh({inputs:{input:T},backend:t})),w=l.map(T=>ff({inputs:{input:T},backend:t})),k=pf({inputs:b,backend:t,attrs:{axis:o}}),I=pf({inputs:w,backend:t,attrs:{axis:o}}),N=Hs({inputs:{real:k,imag:I},backend:t});return b.forEach(T=>t.disposeIntermediateTensorInfo(T)),w.forEach(T=>t.disposeIntermediateTensorInfo(T)),t.disposeIntermediateTensorInfo(k),t.disposeIntermediateTensorInfo(I),N}const c=l.map(b=>{const k=[-1,Se(b.shape.slice(o))];return gn({inputs:{x:b},backend:t,attrs:{shape:k}})}),d=c.map(b=>({vals:t.data.get(b.dataId).values,shape:b.shape}));a=da(c.map(b=>b.shape),1);const p=c[0].shape[0]===1,m=sO(d,a,e[0].dtype,p),y=da(l.map(b=>b.shape),o),v=t.makeTensorInfo(y,e[0].dtype,m);return c.forEach(b=>t.disposeIntermediateTensorInfo(b)),v}const l9={kernelName:N1,backendName:"cpu",kernelFunc:pf};function eF(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:o}=e,{strides:i,pad:a,dataFormat:l,dilations:c,dimRoundingMode:d}=r;Ye([s,o],"conv2d");const p=ul(l),m=_r(s.shape,o.shape,i,c,a,d,!1,p),y=m.filterHeight,v=m.filterWidth,b=m.dilationHeight,w=m.dilationWidth,k=m.padInfo.left,I=m.padInfo.top,N=m.dataFormat==="channelsLast",T=new Ar(m.outShape,s.dtype),A=tt(s.shape),O=tt(o.shape),P=A[0],B=N?A[1]:A[2],z=N?A[2]:1,L=N?1:A[1],_=T.strides[0],H=N?T.strides[1]:T.strides[2],Y=N?T.strides[2]:1,re=N?1:T.strides[1],te=t.data.get(s.dataId).values,le=t.data.get(o.dataId).values,de=T.values;for(let j=0;j<m.batchSize;++j){const ie=j*P,se=j*_;for(let V=0;V<m.outHeight;++V){const X=se+V*H,xe=V*m.strideHeight-I;for(let Ie=0;Ie<y;++Ie){const ke=xe+Ie*b;if(ke<0||ke>=m.inHeight)continue;const Ee=Ie*O[0],Me=ie+ke*B;for(let ze=0;ze<m.outWidth;++ze){const Be=X+ze*Y,Je=ze*m.strideWidth-k;for(let lt=0;lt<v;++lt){const pt=Je+lt*w;if(pt<0||pt>=m.inWidth)continue;const bt=Ee+lt*O[1],Rt=Me+pt*z;let Ot=bt;for(let Bt=0;Bt<m.inChannels;++Bt){const At=te[Rt+Bt*L];for(let Yt=0;Yt<m.outChannels;++Yt)de[Be+Yt*re]+=At*le[Ot+Yt];Ot+=m.outChannels}}}}}}return t.makeTensorInfo(T.shape,T.dtype,de)}const u9={kernelName:T1,backendName:"cpu",kernelFunc:eF};function c9(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,dy:o}=e,{strides:i,pad:a,dataFormat:l,dimRoundingMode:c,filterShape:d}=r;Ye([s,o],"conv2dBackpropFilter");const p=ul(l),m=_r(s.shape,d,i,1,a,c,!1,p),{strideHeight:y,strideWidth:v,filterHeight:b,filterWidth:w}=m,k=m.dataFormat==="channelsLast",I=new Ar(m.filterShape,"float32"),N=m.padInfo.left,T=m.padInfo.top,A=t.data.get(s.dataId).values,O=t.data.get(o.dataId).values,P=new Ar(s.shape,s.dtype,A),B=new Ar(o.shape,o.dtype,O);for(let z=0;z<b;++z){const L=Math.max(0,Math.ceil((T-z)/y)),_=Math.min(m.outHeight,(m.inHeight+T-z)/y);for(let H=0;H<w;++H){const Y=Math.max(0,Math.ceil((N-H)/v)),re=Math.min(m.outWidth,(m.inWidth+N-H)/v);for(let te=0;te<m.inChannels;++te)for(let le=0;le<m.outChannels;++le){let de=0;for(let j=0;j<m.batchSize;++j)for(let ie=L;ie<_;++ie){const se=z+ie*y-T;for(let V=Y;V<re;++V){const X=H+V*v-N;k?de+=P.get(j,se,X,te)*B.get(j,ie,V,le):de+=P.get(j,te,se,X)*B.get(j,le,ie,V)}}I.set(de,z,H,te,le)}}}return t.makeTensorInfo(I.shape,I.dtype,I.values)}const h9={kernelName:$S,backendName:"cpu",kernelFunc:c9};function d9(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,filter:o}=e,{inputShape:i,strides:a,pad:l,dataFormat:c,dimRoundingMode:d}=r;Ye([s,o],"conv2dBackpropInput");const p=tt(o.shape),m=tt(s.shape);let y=ul(c);const v=_r(i,o.shape,a,1,l,d,!1,y),b=new Ar(v.inShape,"float32"),w=b.values,k=t.data.get(s.dataId).values,I=t.data.get(o.dataId).values,[N,T,A]=p,{batchSize:O,filterHeight:P,filterWidth:B,inChannels:z,inHeight:L,inWidth:_,outChannels:H,outHeight:Y,outWidth:re,strideHeight:te,strideWidth:le}=v;y=v.dataFormat;const de=P-1-v.padInfo.top,j=B-1-v.padInfo.left,ie=y==="channelsLast",se=b.strides[0],V=ie?b.strides[1]:b.strides[2],X=ie?b.strides[2]:1,xe=ie?1:b.strides[1],Ie=m[0],ke=ie?m[1]:m[2],Ee=ie?m[2]:1,Me=ie?1:m[1];for(let ze=0;ze<O;++ze)for(let Be=0;Be<z;++Be)for(let Je=0;Je<L;++Je){const lt=Je-de,pt=Math.max(0,Math.ceil(lt/te)),bt=Math.min(Y,(P+lt)/te);for(let Rt=0;Rt<_;++Rt){const Ot=Rt-j,Bt=Math.max(0,Math.ceil(Ot/le)),At=Math.min(re,(B+Ot)/le);let Yt=0;for(let Jt=pt;Jt<bt;++Jt){const cn=Jt*te-lt;for(let Rn=Bt;Rn<At;++Rn){const fs=Rn*le-Ot,Xr=Ie*ze+ke*Jt+Ee*Rn,vr=N*(P-1-cn)+T*(B-1-fs)+A*Be;for(let Zs=0;Zs<H;++Zs){const wr=k[Xr+Me*Zs],Qn=I[vr+Zs];Yt+=wr*Qn}}}const ds=se*ze+V*Je+X*Rt+xe*Be;w[ds]=Yt}}return t.makeTensorInfo(b.shape,b.dtype,b.values)}const f9={kernelName:E1,backendName:"cpu",kernelFunc:d9};function p9(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:o}=e,{strides:i,pad:a,dilations:l}=r;Ye([s,o],"conv3d");const c=xu(s.shape,o.shape,i,l,a),{filterDepth:d,filterHeight:p,filterWidth:m,dilationDepth:y,dilationHeight:v,dilationWidth:b,padInfo:w}=c,k=w.front,I=w.left,N=w.top,T=new Ar(c.outShape,s.dtype),A=t.data.get(s.dataId).values,O=t.data.get(o.dataId).values,P=T.values,B=tt(s.shape),z=tt(o.shape);for(let L=0;L<c.batchSize;++L){const _=L*B[0],H=L*T.strides[0];for(let Y=0;Y<c.outDepth;++Y){const re=H+Y*T.strides[1],te=Y*c.strideDepth-k;for(let le=0;le<d;++le){const de=te+le*y;if(de<0||de>=c.inDepth)continue;const j=le*z[0],ie=_+de*B[1];for(let se=0;se<c.outHeight;++se){const V=re+se*T.strides[2],X=se*c.strideHeight-N;for(let xe=0;xe<p;++xe){const Ie=X+xe*v;if(Ie<0||Ie>=c.inHeight)continue;const ke=j+xe*z[1],Ee=ie+Ie*B[2];for(let Me=0;Me<c.outWidth;++Me){const ze=V+Me*c.outChannels,Be=Me*c.strideWidth-I;for(let Je=0;Je<m;++Je){const lt=Be+Je*b;if(lt<0||lt>=c.inWidth)continue;const pt=ke+Je*z[2],bt=Ee+lt*c.inChannels;let Rt=pt;for(let Ot=0;Ot<c.inChannels;++Ot){const Bt=A[bt+Ot];for(let At=0;At<c.outChannels;++At)P[ze+At]+=Bt*O[Rt+At];Rt+=c.outChannels}}}}}}}}return t.makeTensorInfo(T.shape,T.dtype,T.values)}const m9={kernelName:R1,backendName:"cpu",kernelFunc:p9};function g9(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,dy:o}=e,{strides:i,pad:a,filterShape:l}=r;Ye([s,o],"conv3dBackpropFilterV2");const c=tt(s.shape),d=tt(o.shape),p=xu(s.shape,l,i,1,a),m=p.strideDepth,y=p.strideHeight,v=p.strideWidth,b=p.filterDepth,w=p.filterHeight,k=p.filterWidth,I=new Ar(p.filterShape,"float32"),N=I.values,[T,A,O,P]=I.strides,B=t.data.get(o.dataId).values,[z,L,_,H]=d,Y=t.data.get(s.dataId).values,[re,te,le,de]=c,j=p.padInfo.front,ie=p.padInfo.left,se=p.padInfo.top;for(let V=0;V<b;++V){const X=Math.max(0,Math.ceil((j-V)/m)),xe=Math.min(p.outDepth,(p.inDepth+j-V)/m),Ie=V*T;for(let ke=0;ke<w;++ke){const Ee=Math.max(0,Math.ceil((se-ke)/y)),Me=Math.min(p.outHeight,(p.inHeight+se-ke)/y),ze=ke*A+Ie;for(let Be=0;Be<k;++Be){const Je=Math.max(0,Math.ceil((ie-Be)/v)),lt=Math.min(p.outWidth,(p.inWidth+ie-Be)/v),pt=Be*O+ze;for(let bt=0;bt<p.inChannels;++bt){const Rt=bt*P+pt;for(let Ot=0;Ot<p.outChannels;++Ot){let Bt=0;for(let At=0;At<p.batchSize;++At){const Yt=At*re,ds=At*z;for(let Jt=X;Jt<xe;++Jt){const Rn=(V+Jt*m-j)*te+Yt,fs=Jt*L+ds;for(let Xr=Ee;Xr<Me;++Xr){const Zs=(ke+Xr*y-se)*le+Rn,wr=Xr*_+fs;for(let Qn=Je;Qn<lt;++Qn){const eo=(Be+Qn*v-ie)*de+Zs,to=Qn*H+wr;Bt+=Y[eo+bt]*B[to+Ot]}}}}N[Rt+Ot]=Bt}}}}}return t.makeTensorInfo(I.shape,I.dtype,I.values)}const x9={kernelName:NS,backendName:"cpu",kernelFunc:g9};function y9(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,filter:o}=e,{pad:i,strides:a,inputShape:l}=r;Ye([s],"conv3dBackpropInputV2");const c=tt(s.shape),d=tt(o.shape),p=xu(l,o.shape,a,1,i),m=new Ar(p.inShape,"float32"),y=m.values,[v,b,w,k]=m.strides,I=t.data.get(s.dataId).values,[N,T,A,O]=c,P=t.data.get(o.dataId).values,[B,z,L,_]=d,{batchSize:H,filterDepth:Y,filterHeight:re,filterWidth:te,inChannels:le,inDepth:de,inHeight:j,inWidth:ie,outChannels:se,outDepth:V,outHeight:X,outWidth:xe,strideDepth:Ie,strideHeight:ke,strideWidth:Ee}=p,Me=Y-1-p.padInfo.front,ze=re-1-p.padInfo.top,Be=te-1-p.padInfo.left;for(let Je=0;Je<H;++Je)for(let lt=0;lt<le;++lt)for(let pt=0;pt<de;++pt){const bt=pt-Me,Rt=Math.max(0,Math.ceil(bt/Ie)),Ot=Math.min(V,(Y+bt)/Ie);for(let Bt=0;Bt<j;++Bt){const At=Bt-ze,Yt=Math.max(0,Math.ceil(At/ke)),ds=Math.min(X,(re+At)/ke);for(let Jt=0;Jt<ie;++Jt){const cn=Jt-Be,Rn=Math.max(0,Math.ceil(cn/Ee)),fs=Math.min(xe,(te+cn)/Ee);let Xr=0;for(let vr=Rt;vr<Ot;++vr){const Zs=vr*Ie-bt;for(let wr=Yt;wr<ds;++wr){const Qn=wr*ke-At;for(let So=Rn;So<fs;++So){const eo=So*Ee-cn,to=N*Je+T*vr+A*wr+O*So,Iu=B*(Y-1-Zs)+z*(re-1-Qn)+L*(te-1-eo)+_*lt;for(let Jo=0;Jo<se;++Jo){const hl=I[to+Jo],$u=P[Iu+Jo];Xr+=hl*$u}}}}y[v*Je+b*pt+w*Bt+k*Jt+lt]=Xr}}}return t.makeTensorInfo(m.shape,m.dtype,m.values)}const v9={kernelName:TS,backendName:"cpu",kernelFunc:y9};const w9=sn(dg,n=>Math.cos(n)),b9={kernelName:dg,backendName:"cpu",kernelFunc:w9};const C9=sn(fg,n=>Math.cosh(n)),S9={kernelName:fg,backendName:"cpu",kernelFunc:C9};function k9(n){const{inputs:e,backend:t,attrs:r}=n,{image:s,boxes:o,boxInd:i}=e,{cropSize:a,method:l,extrapolationValue:c}=r,[d,p,m,y]=s.shape,v=o.shape[0],[b,w]=a,k=Nt([v,b,w,y],"float32"),I=t.data.get(o.dataId).values,N=t.data.get(i.dataId).values,T=t.data.get(s.dataId).values,A=tt(s.shape),O=tt(k.shape);for(let P=0;P<v;P++){const B=P*4,z=I[B],L=I[B+1],_=I[B+2],H=I[B+3],Y=N[P];if(Y>=d)continue;const re=b>1?(_-z)*(p-1)/(b-1):0,te=w>1?(H-L)*(m-1)/(w-1):0;for(let le=0;le<b;le++){const de=b>1?z*(p-1)+le*re:.5*(z+_)*(p-1);if(de<0||de>p-1){for(let j=0;j<w;j++)for(let ie=0;ie<y;ie++){const se=ie+j*O[2]+le*O[1]+P*O[0];k.values[se]=c}continue}if(l==="bilinear"){const j=Math.floor(de),ie=Math.ceil(de),se=de-j;for(let V=0;V<w;V++){const X=w>1?L*(m-1)+V*te:.5*(L+H)*(m-1);if(X<0||X>m-1){for(let Ee=0;Ee<y;Ee++){const Me=Ee+V*O[2]+le*O[1]+P*O[0];k.values[Me]=c}continue}const xe=Math.floor(X),Ie=Math.ceil(X),ke=X-xe;for(let Ee=0;Ee<y;Ee++){let Me=Ee+xe*A[2]+j*A[1]+Y*A[0];const ze=T[Me];Me=Ee+Ie*A[2]+j*A[1]+Y*A[0];const Be=T[Me];Me=Ee+xe*A[2]+ie*A[1]+Y*A[0];const Je=T[Me];Me=Ee+Ie*A[2]+ie*A[1]+Y*A[0];const lt=T[Me],pt=ze+(Be-ze)*ke,bt=Je+(lt-Je)*ke;Me=Ee+V*O[2]+le*O[1]+P*O[0],k.values[Me]=pt+(bt-pt)*se}}}else for(let j=0;j<w;++j){const ie=w>1?L*(m-1)+j*te:.5*(L+H)*(m-1);if(ie<0||ie>m-1){for(let X=0;X<y;X++){const xe=X+j*O[2]+le*O[1]+P*O[0];k.values[xe]=c}continue}const se=Math.round(ie),V=Math.round(de);for(let X=0;X<y;X++){const xe=X+se*A[2]+V*A[1]+Y*A[0],Ie=X+j*O[2]+le*O[1]+P*O[0];k.values[Ie]=T[xe]}}}}return t.makeTensorInfo(k.shape,k.dtype,k.values)}const I9={kernelName:RS,backendName:"cpu",kernelFunc:k9};function $9(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o,exclusive:i,reverse:a}=r;Ye(s,"cumprod");const l=En([o],s.shape.length);let c=s;l!=null&&(c=Ns({inputs:{x:s},backend:t,attrs:{perm:l}}));const d=Wn(1,s.shape.length)[0];if(d!==c.shape.length-1)throw new Error(`backend.cumprod in CPU expects an inner-most axis=${c.shape.length-1} but got axis=${d}`);const p=Ys(c.dtype,"int32"),m=mS(Se(c.shape),p),y=t.data.get(c.dataId).values,v=c.shape[c.shape.length-1],b=a?(k,I)=>k+v-I-1:(k,I)=>k+I;for(let k=0;k<y.length;k+=v)for(let I=0;I<v;I++){const N=b(k,I);if(I===0)m[N]=i?1:y[N];else{const T=b(k,I-1);m[N]=i?y[T]*m[T]:y[N]*m[T]}}const w=t.makeTensorInfo(c.shape,p,m);if(l!=null){const k=yu(l),I=Ns({inputs:{x:w},backend:t,attrs:{perm:k}});return t.disposeIntermediateTensorInfo(w),t.disposeIntermediateTensorInfo(c),I}return w}const N9={kernelName:ES,backendName:"cpu",kernelFunc:$9};function T9(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o,exclusive:i,reverse:a}=r;Ye(s,"cumsum");const l=En([o],s.shape.length);let c=s;l!=null&&(c=Ns({inputs:{x:s},backend:t,attrs:{perm:l}}));const d=Wn(1,s.shape.length)[0];if(d!==c.shape.length-1)throw new Error(`backend.cumsum in CPU expects an inner-most axis=${c.shape.length-1} but got axis=${d}`);const p=Ys(c.dtype,"int32"),m=Gr(Se(c.shape),p),y=t.data.get(c.dataId).values,v=c.shape[c.shape.length-1],b=a?(k,I)=>k+v-I-1:(k,I)=>k+I;for(let k=0;k<y.length;k+=v)for(let I=0;I<v;I++){const N=b(k,I);if(I===0)m[N]=i?0:y[N];else{const T=b(k,I-1);m[N]=i?y[T]+m[T]:y[N]+m[T]}}const w=t.makeTensorInfo(c.shape,p,m);if(l!=null){const k=yu(l),I=Ns({inputs:{x:w},backend:t,attrs:{perm:k}});return t.disposeIntermediateTensorInfo(w),t.disposeIntermediateTensorInfo(c),I}return w}const E9={kernelName:A1,backendName:"cpu",kernelFunc:T9};function R9(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,weights:o}=e,{size:i,binaryOutput:a}=r;if(s.shape.length===1){const l=t.data.get(s.dataId).values,c=t.data.get(o.dataId).values,d=DI(l,c,o.dtype,o.shape,i);return t.makeTensorInfo([i],o.dtype,d)}else if(s.shape.length===2){const l=t.bufferSync(s),c=t.bufferSync(o),d=tO(l,c,i,a);return t.makeTensorInfo(d.shape,o.dtype,d.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${s.shape.length}.`)}const A9={kernelName:AS,backendName:"cpu",kernelFunc:R9};function _9(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{blockSize:o,dataFormat:i}=r;U(i==="NHWC",()=>`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${i}`);const a=s.shape[0],l=s.shape[1],c=s.shape[2],d=s.shape[3],p=l*o,m=c*o,y=d/(o*o),v=t.data.get(s.dataId).values,b=new Float32Array(a*p*m*y);let w=0;for(let k=0;k<a;++k)for(let I=0;I<p;++I){const N=Math.floor(I/o),T=I%o;for(let A=0;A<m;++A){const O=Math.floor(A/o),P=A%o,B=(T*o+P)*y;for(let z=0;z<y;++z){const _=z+B+d*(O+c*(N+l*k));b[w++]=v[_]}}}return t.makeTensorInfo([a,p,m,y],s.dtype,b)}const D9={kernelName:_S,backendName:"cpu",kernelFunc:_9};function tF(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:o}=e,{strides:i,pad:a,dilations:l,dimRoundingMode:c}=r;Ye([s,o],"depthwiseConv2DNative");const d=tt(s.shape),p=tt(o.shape);let m=l;m==null&&(m=[1,1]),U(Hr(i,m),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${m}'`);const y=_r(s.shape,o.shape,i,m,a,c,!0),{filterHeight:v,filterWidth:b,dilationHeight:w,dilationWidth:k,padInfo:I}=y,N=I.left,T=I.top,A=y.outChannels/y.inChannels,O=new Ar(y.outShape,s.dtype),P=t.data.get(s.dataId).values,B=t.data.get(o.dataId).values,z=O.values;for(let L=0;L<y.batchSize;++L){const _=L*d[0],H=L*O.strides[0];for(let Y=0;Y<y.outHeight;++Y){const re=H+Y*O.strides[1],te=Y*y.strideHeight-T;for(let le=0;le<v;++le){const de=te+le*w;if(de<0||de>=y.inHeight)continue;const j=le*p[0],ie=_+de*d[1];for(let se=0;se<y.outWidth;++se){const V=re+se*O.strides[2],X=se*y.strideWidth-N;for(let xe=0;xe<b;++xe){const Ie=X+xe*k;if(Ie<0||Ie>=y.inWidth)continue;const ke=j+xe*p[1],Ee=ie+Ie*y.inChannels;let Me=V,ze=ke;for(let Be=0;Be<y.inChannels;++Be){const Je=P[Ee+Be];for(let lt=0;lt<A;++lt)z[Me+lt]+=Je*B[ze+lt];Me+=A,ze+=A}}}}}}return t.makeTensorInfo(O.shape,O.dtype,O.values)}const O9={kernelName:_1,backendName:"cpu",kernelFunc:tF};function F9(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,dy:o}=e,{strides:i,dilations:a,pad:l,dimRoundingMode:c,filterShape:d}=r;Ye([s,o],"depthwiseConv2dNativeBackpropFilter");const p=_r(s.shape,d,i,a,l,c,!0),{strideHeight:m,strideWidth:y,filterHeight:v,filterWidth:b}=p,w=new Ar(p.filterShape,"float32"),k=p.padInfo.left,I=p.padInfo.top,N=p.outChannels/p.inChannels,T=t.data.get(s.dataId).values,A=new Ar(s.shape,s.dtype,T),O=t.data.get(o.dataId).values,P=new Ar(o.shape,o.dtype,O);for(let B=0;B<v;++B){const z=Math.max(0,Math.ceil((I-B)/m)),L=Math.min(p.outHeight,(p.inHeight+I-B)/m);for(let _=0;_<b;++_){const H=Math.max(0,Math.ceil((k-_)/y)),Y=Math.min(p.outWidth,(p.inWidth+k-_)/y);for(let re=0;re<p.outChannels;++re){const te=Math.trunc(re/N),le=re%N;let de=0;for(let j=0;j<p.batchSize;++j)for(let ie=z;ie<L;++ie){const se=B+ie*m-I;for(let V=H;V<Y;++V){const X=_+V*y-k;de+=A.get(j,se,X,te)*P.get(j,ie,V,re)}}w.set(de,B,_,te,le)}}}return t.makeTensorInfo(w.shape,w.dtype,w.values)}const P9={kernelName:DS,backendName:"cpu",kernelFunc:F9};function L9(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,filter:o}=e,{strides:i,dilations:a,pad:l,dimRoundingMode:c,inputShape:d}=r;Ye([s,o],"depthwiseConv2DNativeBackpropInput");const p=tt(s.shape),m=tt(o.shape),y=_r(d,o.shape,i,a,l,c,!0),v=new Ar(y.inShape,"float32"),b=v.values,[w,k,I]=v.strides,N=t.data.get(s.dataId).values,[T,A,O]=p,P=t.data.get(o.dataId).values,[B,z,L]=m,{batchSize:_,filterHeight:H,filterWidth:Y,inChannels:re,inHeight:te,inWidth:le,outChannels:de,outHeight:j,outWidth:ie,strideHeight:se,strideWidth:V}=y,X=H-1-y.padInfo.top,xe=Y-1-y.padInfo.left,Ie=de/re;for(let ke=0;ke<_;++ke)for(let Ee=0;Ee<re;++Ee)for(let Me=0;Me<te;++Me){const ze=Me-X,Be=Math.max(0,Math.ceil(ze/se)),Je=Math.min(j,(H+ze)/se);for(let lt=0;lt<le;++lt){const pt=lt-xe,bt=Math.max(0,Math.ceil(pt/V)),Rt=Math.min(ie,(Y+pt)/V);let Ot=0;for(let Bt=Be;Bt<Je;++Bt){const At=Bt*se-ze;for(let Yt=bt;Yt<Rt;++Yt){const ds=Yt*V-pt,Jt=T*ke+A*Bt+O*Yt,cn=B*(H-1-At)+z*(Y-1-ds)+L*Ee;for(let Rn=0;Rn<Ie;++Rn){const fs=Ee*Ie+Rn,Xr=N[Jt+fs],vr=P[cn+Rn];Ot+=Xr*vr}}}b[w*ke+k*Me+I*lt+Ee]=Ot}}return t.makeTensorInfo(v.shape,v.dtype,v.values)}const M9={kernelName:OS,backendName:"cpu",kernelFunc:L9};function z9(n){const{inputs:e,backend:t}=n,{x:r}=e,s=Se(r.shape),o=t.data.get(r.dataId).values,i=Nt([s,s],r.dtype),a=i.values;for(let c=0;c<o.length;c++)a[c*s+c]=o[c];const l=[...r.shape,...r.shape];return t.makeTensorInfo(l,i.dtype,i.values)}const B9={kernelName:$E,backendName:"cpu",kernelFunc:z9};const U9={kernelName:D1,backendName:"cpu",kernelFunc:({inputs:n,backend:e,attrs:t})=>{const{x:r,filter:s}=n,{strides:o,pad:i,dilations:a}=t,l=e,c=l.data.get(r.dataId).values,d=r.shape.length,p=l.data.get(s.dataId).values,m=s.shape.length,{batchSize:y,inHeight:v,inWidth:b,inChannels:w,outHeight:k,outWidth:I,padInfo:N,strideHeight:T,strideWidth:A,filterHeight:O,filterWidth:P,dilationHeight:B,dilationWidth:z,outShape:L}=Zg(r.shape,s.shape,o,i,"NHWC",a),_=Se(L),H=L.length,Y=Mn(r.dtype,_);for(let te=0;te<y;++te)for(let le=0;le<k;++le){const de=le*T-N.top;for(let j=0;j<I;++j){const ie=j*A-N.left;for(let se=0;se<w;++se){let V=Number.MIN_SAFE_INTEGER;for(let xe=0;xe<O;++xe){const Ie=de+xe*B;if(Ie>=0&&Ie<v)for(let ke=0;ke<P;++ke){const Ee=ie+ke*z;if(Ee>=0&&Ee<b){const Me=ca([te,Ie,Ee,se],d,tt(r.shape)),ze=ca([xe,ke,se],m,tt(s.shape)),Be=c[Me]+p[ze];Be>V&&(V=Be)}}}const X=ca([te,le,j,se],H,tt(L));Y[X]=V}}}return{dataId:l.write(ah(Y,r.dtype),L,r.dtype),shape:L,dtype:r.dtype}}};const W9={kernelName:lC,backendName:"cpu",kernelFunc:({inputs:n,backend:e,attrs:t})=>{const{x:r,filter:s,dy:o}=n,{strides:i,pad:a,dilations:l}=t,c=e,d=Ci(r.shape,c.data.get(r.dataId).values),p=Ci(s.shape,c.data.get(s.dataId).values),{batchSize:m,inHeight:y,inWidth:v,inChannels:b,outHeight:w,outWidth:k,padInfo:I,strideHeight:N,strideWidth:T,filterHeight:A,filterWidth:O,dilationHeight:P,dilationWidth:B,outShape:z}=Zg(r.shape,s.shape,i,a,"NHWC",l);U(o.rank===z.length,()=>`Error in ${lC}, dy must have the same rank as output ${z.length}, but got ${o.rank}`);const L=Ci(z,c.data.get(o.dataId).values),_=CE(s.shape,s.dtype);for(let Y=0;Y<m;++Y)for(let re=0;re<w;++re){const te=re*N-I.top;for(let le=0;le<k;++le){const de=le*T-I.left;for(let j=0;j<b;++j){let ie=Number.MIN_SAFE_INTEGER,se=0,V=0;for(let X=0;X<A;++X){const xe=te+X*P;if(xe>=0&&xe<y)for(let Ie=0;Ie<O;++Ie){const ke=de+Ie*B;if(ke>=0&&ke<v){const Ee=d[Y][xe][ke][j]+p[X][Ie][j];Ee>ie&&(ie=Ee,se=X,V=Ie)}}}_[se][V][j]+=L[Y][re][le][j]}}}return{dataId:c.write(ah(_,r.dtype),s.shape,s.dtype),shape:s.shape,dtype:s.dtype}}};const V9={kernelName:aC,backendName:"cpu",kernelFunc:({inputs:n,backend:e,attrs:t})=>{const{x:r,filter:s,dy:o}=n,{strides:i,pad:a,dilations:l}=t,c=e,d=Ci(r.shape,c.data.get(r.dataId).values),p=Ci(s.shape,c.data.get(s.dataId).values),{batchSize:m,inHeight:y,inWidth:v,inChannels:b,outHeight:w,outWidth:k,padInfo:I,strideHeight:N,strideWidth:T,filterHeight:A,filterWidth:O,dilationHeight:P,dilationWidth:B,outShape:z}=Zg(r.shape,s.shape,i,a,"NHWC",l);U(o.rank===z.length,()=>`Error in ${aC}, dy must have the same rank as output ${z.length}, but got ${o.rank}`);const L=Ci(z,c.data.get(o.dataId).values),_=CE(r.shape,r.dtype);for(let Y=0;Y<m;++Y)for(let re=0;re<w;++re){const te=re*N-I.top;for(let le=0;le<k;++le){const de=le*T-I.left;for(let j=0;j<b;++j){let ie=Number.MIN_SAFE_INTEGER,se=te<0?0:te,V=de<0?0:de;for(let X=0;X<A;++X){const xe=te+X*P;if(xe>=0&&xe<y)for(let Ie=0;Ie<O;++Ie){const ke=de+Ie*B;if(ke>=0&&ke<v){const Ee=d[Y][xe][ke][j]+p[X][Ie][j];Ee>ie&&(ie=Ee,se=xe,V=ke)}}}_[Y][se][V][j]+=L[Y][re][le][j]}}}return{dataId:c.write(ah(_,r.dtype),r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}};function G9(n){const{inputs:e,backend:t,attrs:r}=n,{image:s}=e,{canvas:o,options:i}=r,{contextOptions:a,imageOptions:l}=i||{},c=l?.alpha||1,d=a?.contextType||"2d";if(d!=="2d")throw new Error(`Context type ${a.contextType} is not supported by the CPU backend.`);const p=o.getContext(d,a?.contextAttributes||{});if(p==null)throw new Error(`Could not get the context with ${d} type.`);const[m,y]=s.shape.slice(0,2),v=s.shape.length===2?1:s.shape[2],b=t.data.get(s.dataId).values,w=s.dtype==="float32"?255:1,k=new Uint8ClampedArray(y*m*4);for(let N=0;N<m*y;++N){const T=[0,0,0,255*c];for(let O=0;O<v;O++){const P=b[N*v+O];if(s.dtype==="float32"){if(P<0||P>1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${P}.`)}else if(s.dtype==="int32"&&(P<0||P>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${P}.`);v===1?(T[0]=P*w,T[1]=P*w,T[2]=P*w):T[O]=P*w}const A=N*4;k[A+0]=Math.round(T[0]),k[A+1]=Math.round(T[1]),k[A+2]=Math.round(T[2]),k[A+3]=Math.round(T[3])}o.width=y,o.height=m;const I=new ImageData(k,y,m);return p.putImageData(I,0,0),s}const j9={kernelName:nU,backendName:"cpu",kernelFunc:G9};function mx(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o,keepDims:i}=r;Ye(s,"sum");let a;s.dtype==="bool"?a=du({inputs:{x:s},backend:t,attrs:{dtype:"int32"}}):a=wa({inputs:{x:s},backend:t});const l=a.shape.length,c=Tt(o,a.shape),d=En(c,l);let p=c,m=a;d!=null&&(m=Ns({inputs:{x:a},backend:t,attrs:{perm:d}}),p=Wn(p.length,l)),Dr("sum",p,m.shape.length);const[y,v]=yr(m.shape,p),b=Ys(m.dtype,"int32");let w=r1(t,y,b);const k=Se(v),I=t.data.get(w.dataId).values,N=t.data.get(m.dataId).values;for(let T=0;T<I.length;++T){const A=T*k;let O=0;for(let P=0;P<k;++P)O+=N[A+P];I[T]=O}if(i){const T=Yn(w.shape,c),A=w;w=gn({inputs:{x:w},backend:t,attrs:{shape:T}}),t.disposeIntermediateTensorInfo(A)}return t.disposeIntermediateTensorInfo(a),d!=null&&t.disposeIntermediateTensorInfo(m),w}const H9={kernelName:dv,backendName:"cpu",kernelFunc:mx};function q9(n){const{inputs:e,backend:t,attrs:r}=n,{equation:s}=r,o=e,{allDims:i,summedDims:a,idDims:l}=rI(s,o.length);oI(i.length,l,o);const{path:c,steps:d}=iI(a,l),p=d.length;let m=null,y=i.length;const v=[];for(let b=0;b<p;++b){for(const w of d[b]){const{permutationIndices:k,expandDims:I}=sI(y,l[w]);let N;aI(k)?N=o[w]:(N=Ns({inputs:{x:o[w]},backend:t,attrs:{perm:k}}),v.push(N));const T=N.shape.slice();for(let A=0;A<I.length;++A)T.splice(I[A],0,1);Xt(N.shape,T)||(N=gn({inputs:{x:N},backend:t,attrs:{shape:T}}),v.push(N)),m===null?m=N:(m=Uv({inputs:{a:N,b:m},backend:t}),v.push(m))}b<p-1&&(c[b]>=0&&(m=mx({inputs:{x:m},backend:t,attrs:{axis:c[b]-(i.length-y),keepDims:!1}}),v.push(m)),y--)}for(const b of v)b!==m&&t.disposeIntermediateTensorInfo(b);return m}const K9={kernelName:FS,backendName:"cpu",kernelFunc:q9};function X9(n){const{inputs:e,backend:t}=n,{dy:r,y:s}=e;Ye([r,s],"eluGrad");const o=new Float32Array(Se(s.shape)),i=t.data.get(s.dataId).values,a=t.data.get(r.dataId).values;for(let l=0;l<i.length;++l){const c=i[l];c>=0?o[l]=a[l]:o[l]=a[l]*(c+1)}return t.makeTensorInfo(s.shape,"float32",o)}const Y9={kernelName:PS,backendName:"cpu",kernelFunc:X9};const Q9=Yk,J9=Qk,Z9=Jk,eY=Zk,tY=eI,nY=tI,rY=sn(gg,n=>{const e=Math.sign(n),t=Math.abs(n),r=1/(1+Q9*t);return e*(1-((((nY*r+tY)*r+eY)*r+Z9)*r+J9)*r*Math.exp(-t*t))}),sY={kernelName:gg,backendName:"cpu",kernelFunc:rY};function i1(n){const{inputs:e,backend:t,attrs:r}=n,{input:s}=e,{dim:o}=r,i=s.shape.length,a=s.shape.slice();let l=o;return o<0&&(U(-(i+1)<=o,()=>`Axis must be in the interval [${-(i+1)}, ${i}]`),l=i+o+1),a.splice(l,0,1),gn({inputs:{x:s},backend:t,attrs:{shape:a}})}const oY={kernelName:F1,backendName:"cpu",kernelFunc:i1};const iY=Gn((n,e)=>n/e),zI=lr(pg,iY),FC={kernelName:pg,backendName:"cpu",kernelFunc:zI};function nF(n,e,t){const r=n.shape,s=r[0],o=r[1],i=t.data.get(n.dataId),a=i.complexTensorInfos.real,l=i.complexTensorInfos.imag,c=[s,o],d=Se(c),p=Vr("float32",d),m=Vr("float32",d);for(let w=0;w<s;w++){const k=rh({inputs:{x:a},backend:t,attrs:{begin:[w,0],size:[1,o]}}),I=rh({inputs:{x:l},backend:t,attrs:{begin:[w,0],size:[1,o]}}),N=Hs({inputs:{real:k,imag:I},backend:t}),{real:T,imag:A}=aY(N,e,t),O=ol(T,A);for(let P=0;P<o;P++){const B=nI(O,P);p[w*o+P]=B.real,m[w*o+P]=B.imag}t.disposeIntermediateTensorInfo(k),t.disposeIntermediateTensorInfo(I),t.disposeIntermediateTensorInfo(N)}const y=t.makeTensorInfo(c,"float32",p),v=t.makeTensorInfo(c,"float32",m),b=Hs({inputs:{real:y,imag:v},backend:t});return t.disposeIntermediateTensorInfo(y),t.disposeIntermediateTensorInfo(v),b}function aY(n,e,t){const r=Se(n.shape),s=t.data.get(n.dataId),o=t.data.get(s.complexTensorInfos.real.dataId).values,i=t.data.get(s.complexTensorInfos.imag.dataId).values;if(lY(r)){const a=PC(o,i,r,e,t),l=[n.shape[0],n.shape[1]];if(e){const c=t.makeTensorInfo(l,"float32",a.real),d=t.makeTensorInfo(l,"float32",a.imag),p=t.makeTensorInfo([],"float32",mu(r,"float32")),m=wa({inputs:{x:p},backend:t}),y=FC.kernelFunc({inputs:{a:c,b:p},backend:t}),v=FC.kernelFunc({inputs:{a:d,b:m},backend:t}),b=t.data.get(y.dataId).values,w=t.data.get(v.dataId).values;return t.disposeIntermediateTensorInfo(c),t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(m),t.disposeIntermediateTensorInfo(y),t.disposeIntermediateTensorInfo(v),{real:b,imag:w}}return a}else{const a=ol(o,i),l=uY(a,r,e);return mA(l)}}function lY(n){return(n&n-1)===0}function PC(n,e,t,r,s){if(t===1)return{real:n,imag:e};const o=ol(n,e),i=t/2,a=gA(o),l=a.real,c=a.imag,d=[l.length],p=s.makeTensorInfo(d,"float32",l),m=s.makeTensorInfo(d,"float32",c),y=Hs({inputs:{real:p,imag:m},backend:s}),v=xA(o),b=v.real,w=v.imag,k=[b.length],I=s.makeTensorInfo(k,"float32",b),N=s.makeTensorInfo(k,"float32",w),T=Hs({inputs:{real:I,imag:N},backend:s}),A=PC(l,c,i,r,s),O=A.real,P=A.imag,B=[O.length],z=s.makeTensorInfo(B,"float32",O),L=s.makeTensorInfo(B,"float32",P),_=Hs({inputs:{real:z,imag:L},backend:s}),H=PC(b,w,i,r,s),Y=H.real,re=H.imag,te=[Y.length],le=s.makeTensorInfo(te,"float32",Y),de=s.makeTensorInfo(te,"float32",re),j=Hs({inputs:{real:le,imag:de},backend:s}),ie=vA(t,r),se=[ie.real.length],V=s.makeTensorInfo(se,"float32",ie.real),X=s.makeTensorInfo(se,"float32",ie.imag),xe=Hs({inputs:{real:V,imag:X},backend:s}),Ie=Uv({inputs:{a:xe,b:j},backend:s}),ke=df({inputs:{a:_,b:Ie},backend:s}),Ee=LI({inputs:{a:_,b:Ie},backend:s}),Me=nh({inputs:{input:ke},backend:s}),ze=nh({inputs:{input:Ee},backend:s}),Be=ff({inputs:{input:ke},backend:s}),Je=ff({inputs:{input:Ee},backend:s}),lt=pf({inputs:[Me,ze],backend:s,attrs:{axis:0}}),pt=pf({inputs:[Be,Je],backend:s,attrs:{axis:0}}),bt=s.data.get(lt.dataId).values,Rt=s.data.get(pt.dataId).values;return s.disposeIntermediateTensorInfo(p),s.disposeIntermediateTensorInfo(m),s.disposeIntermediateTensorInfo(y),s.disposeIntermediateTensorInfo(I),s.disposeIntermediateTensorInfo(N),s.disposeIntermediateTensorInfo(T),s.disposeIntermediateTensorInfo(z),s.disposeIntermediateTensorInfo(L),s.disposeIntermediateTensorInfo(_),s.disposeIntermediateTensorInfo(le),s.disposeIntermediateTensorInfo(de),s.disposeIntermediateTensorInfo(j),s.disposeIntermediateTensorInfo(V),s.disposeIntermediateTensorInfo(X),s.disposeIntermediateTensorInfo(xe),s.disposeIntermediateTensorInfo(Ie),s.disposeIntermediateTensorInfo(ke),s.disposeIntermediateTensorInfo(Ee),s.disposeIntermediateTensorInfo(Me),s.disposeIntermediateTensorInfo(Be),s.disposeIntermediateTensorInfo(ze),s.disposeIntermediateTensorInfo(Je),s.disposeIntermediateTensorInfo(lt),s.disposeIntermediateTensorInfo(pt),{real:bt,imag:Rt}}function uY(n,e,t){const r=new Float32Array(e*2);for(let s=0;s<e;s++){let o=0,i=0;for(let a=0;a<e;a++){const l=wA(s*a,e,t),c=nI(n,a);o+=c.real*l.real-c.imag*l.imag,i+=c.real*l.imag+c.imag*l.real}t&&(o/=e,i/=e),yA(r,o,i,s)}return r}function cY(n){const{inputs:e,backend:t}=n,{input:r}=e,s=Se(r.shape),o=r.shape[r.shape.length-1],i=s/o,a=gn({inputs:{x:r},backend:t,attrs:{shape:[i,o]}}),l=nF(a,!1,t),c=gn({inputs:{x:l},backend:t,attrs:{shape:r.shape}});return t.disposeIntermediateTensorInfo(a),t.disposeIntermediateTensorInfo(l),c}const hY={kernelName:LS,backendName:"cpu",kernelFunc:cY};function BI(n){const{backend:e,attrs:t}=n,{shape:r,value:s,dtype:o}=t,i=o||Cf(s),a=Mn(i,Se(r));return fY(a,s,i),e.makeTensorInfo(r,i,a)}const dY={kernelName:MS,backendName:"cpu",kernelFunc:BI};function fY(n,e,t){n.fill(e)}const pY={kernelName:zS,backendName:"cpu",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{image:r}=n,s=t,o=Vr(r.dtype,Se(r.shape)),[i,a,l,c]=r.shape,d=s.data.get(r.dataId).values;for(let m=0;m<i;m++){const y=m*l*a*c;for(let v=0;v<a;v++){const b=v*(l*c);for(let w=0;w<l;w++){const k=w*c;for(let I=0;I<c;I++){const N=Math.round(l-w-1),T=y+b+k+I;let A=d[T];if(N>=0&&N<l){const O=N*c,P=y+b+O+I;A=d[P]}o[T]=A}}}}return{dataId:s.write(o,r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}};function mY(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:o,bias:i,preluActivationWeights:a}=e,{strides:l,pad:c,dataFormat:d,dilations:p,dimRoundingMode:m,activation:y,leakyreluAlpha:v}=r;let b=eF({inputs:{x:s,filter:o},backend:t,attrs:{strides:l,pad:c,dataFormat:d,dilations:p,dimRoundingMode:m}});if(i){const w=b;if(d==="NCHW"&&i.shape.length===1&&i.shape[0]!==1){const k=gn({inputs:{x:i},backend:t,attrs:{shape:[i.shape[0],1,1]}});b=df({inputs:{a:b,b:k},backend:t}),t.disposeIntermediateTensorInfo(k)}else b=df({inputs:{a:b,b:i},backend:t});t.disposeIntermediateTensorInfo(w)}if(y){const w=b;if(d==="NCHW"&&y==="prelu"&&a.shape.length===1&&a.shape[0]!==1){const k=gn({inputs:{x:a},backend:t,attrs:{shape:[a.shape[0],1,1]}});b=o1(t,b,y,k,v),t.disposeIntermediateTensorInfo(k)}else b=o1(t,b,y,a,v);t.disposeIntermediateTensorInfo(w)}return b}const gY={kernelName:My,backendName:"cpu",kernelFunc:mY};function xY(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:o,bias:i,preluActivationWeights:a}=e,{strides:l,pad:c,dataFormat:d,dilations:p,dimRoundingMode:m,activation:y,leakyreluAlpha:v}=r;let b=tF({inputs:{x:s,filter:o},backend:t,attrs:{strides:l,pad:c,dataFormat:d,dilations:p,dimRoundingMode:m}});if(i){const w=b;b=df({inputs:{a:b,b:i},backend:t}),t.disposeIntermediateTensorInfo(w)}if(y){const w=b;b=o1(t,b,y,a,v),t.disposeIntermediateTensorInfo(w)}return b}const yY={kernelName:jE,backendName:"cpu",kernelFunc:xY};function vY(n){const{inputs:e,backend:t}=n,{params:r,indices:s}=e,o=Se(r.shape),i=s.shape,a=i[i.length-1],[l,c,d,p]=zk(r,s);if(c===0)return t.makeTensorInfo(l,r.dtype,[]);const m=t.data.get(s.dataId).values,y=t.bufferSync(r),v=dO(m,y,r.dtype,c,a,d,p,r.shape,o);return t.makeTensorInfo(l,r.dtype,v.values)}const wY={kernelName:NE,backendName:"cpu",kernelFunc:vY};function bY(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,indices:o}=e,{axis:i,batchDims:a}=r;Ye([s,o],"gatherV2");const l=Tt(i,s.shape)[0],c=t.data.get(o.dataId).values,d=s.shape[l];for(let T=0;T<c.length;++T){const A=c[T];U(A<=d-1&&A>=0,()=>`GatherV2: the index value ${A} is not in [0, ${d-1}]`)}let p=a;a==null&&(p=0);const m=Se(o.shape),y=uI(s,o,l,p),v=gn({inputs:{x:s},backend:t,attrs:{shape:[y.batchSize,y.outerSize,y.dimSize,y.sliceSize]}}),b=gn({inputs:{x:o},backend:t,attrs:{shape:[y.batchSize,m/y.batchSize]}}),w=[y.batchSize,y.outerSize,m/y.batchSize,y.sliceSize],k=t.bufferSync(b),I=t.bufferSync(v),N=fO(I,k,w);return t.disposeIntermediateTensorInfo(v),t.disposeIntermediateTensorInfo(b),t.makeTensorInfo(y.outputShape,N.dtype,N.values)}const CY={kernelName:L1,backendName:"cpu",kernelFunc:bY};function SY(n){const{inputs:e,backend:t}=n,{input:r}=e,s=Se(r.shape),o=r.shape[r.shape.length-1],i=s/o,a=gn({inputs:{x:r},backend:t,attrs:{shape:[i,o]}}),l=nF(a,!0,t),c=gn({inputs:{x:l},backend:t,attrs:{shape:r.shape}});return t.disposeIntermediateTensorInfo(a),t.disposeIntermediateTensorInfo(l),c}const kY={kernelName:BS,backendName:"cpu",kernelFunc:SY};const IY=sn(Sg,n=>Number.isFinite(n)?1:0,"bool"),$Y={kernelName:Sg,backendName:"cpu",kernelFunc:IY};const NY=sn(kg,n=>Math.abs(n)===1/0?1:0,"bool"),TY={kernelName:kg,backendName:"cpu",kernelFunc:NY};const EY=sn(Ig,n=>Number.isNaN(n)?1:0,"bool"),RY={kernelName:Ig,backendName:"cpu",kernelFunc:EY};function AY(n){const{backend:e,attrs:t}=n,{start:r,stop:s,num:o}=t,i=yO(r,s,o);return e.makeTensorInfo([i.length],"float32",i)}const _Y={kernelName:TE,backendName:"cpu",kernelFunc:AY};const DY=sn(Ng,n=>Math.log1p(n)),OY={kernelName:Ng,backendName:"cpu",kernelFunc:DY};const FY=Gn((n,e)=>n&&e),PY=lr(W1,FY,null,"bool"),LY={kernelName:W1,backendName:"cpu",kernelFunc:PY};const MY=sn(V1,n=>n?0:1,"bool"),zY={kernelName:V1,backendName:"cpu",kernelFunc:MY};const BY=Gn((n,e)=>n||e),UY=lr(G1,BY,null,"bool"),WY={kernelName:G1,backendName:"cpu",kernelFunc:UY};function VY(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{depthRadius:o,bias:i,alpha:a,beta:l}=r;Ye(s,"LRN");const c=s.shape[3],d=c-1,p=t.data.get(s.dataId).values,m=Se(s.shape),y=new Float32Array(m);function v(b){const w=b%c;let k=b-w+Math.max(0,w-o);const I=b-w+Math.min(w+o,d);let N=0;for(;k<=I;k++){const T=p[k];N+=T*T}return N}for(let b=0;b<m;b++){const w=v(b),k=p[b]*Math.pow(i+a*w,-l);y[b]=k}return t.makeTensorInfo(s.shape,s.dtype,y)}const GY={kernelName:j1,backendName:"cpu",kernelFunc:VY};function jY(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,y:o,dy:i}=e,{depthRadius:a,bias:l,alpha:c,beta:d}=r;Ye(i,"LRNGrad");const p=Se(i.shape),m=i.shape[3],y=t.data.get(i.dataId).values,v=t.data.get(s.dataId).values,b=t.data.get(o.dataId).values,w=new Float32Array(p),k=p;for(let I=0;I<k;I++){const N=I%m,T=I-N+Math.max(0,N-a),A=I-N+Math.min(m,N+a+1);let O=0;for(let P=T;P<A;P++)O+=Math.pow(v[P],2);O=c*O+l;for(let P=T;P<A;P++){let B=-2*c*d*v[P]*b[I]/O;I===P&&(B+=Math.pow(O,-d)),B*=y[I],w[P]+=B}}return t.makeTensorInfo(i.shape,s.dtype,w)}const HY={kernelName:WS,backendName:"cpu",kernelFunc:jY};function rF(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{reductionIndices:o,keepDims:i}=r,a=t;let l=s.shape;const c=l.length,d=Tt(o,l);let p=d;const m=En(p,c);let y=a.data.get(s.dataId).values;if(m!=null){const T=new Array(c);for(let A=0;A<T.length;A++)T[A]=l[m[A]];y=FI(y,l,s.dtype,m,T),p=Wn(p.length,c),l=T}Ye(s,"max"),Dr("max",p,c);const[v,b]=yr(l,p),w=Se(b),k=wO(y,w,v,s.dtype),I=a.write(k,v,s.dtype);let N=v;return i&&(N=Yn(v,d)),{dataId:I,shape:N,dtype:s.dtype}}const qY={kernelName:H1,backendName:"cpu",kernelFunc:rF};function KY(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e;Ye(s,"maxPool");const{filterSize:o,strides:i,pad:a,dimRoundingMode:l}=r,c=1;U(Hr(i,c),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const d=Xo(s.shape,o,i,c,a,l);let p;if(d.filterWidth===1&&d.filterHeight===1&&Xt(d.inShape,d.outShape))p=wa({inputs:{x:s},backend:t});else{const m=t.data.get(s.dataId).values,y=tt(s.shape),v=MI(m,s.shape,s.dtype,y,d,"max");p=t.makeTensorInfo(d.outShape,s.dtype,v.values)}return p}const XY={kernelName:q1,backendName:"cpu",kernelFunc:KY};function YY(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{filterSize:o,strides:i,pad:a,dimRoundingMode:l,dataFormat:c}=r;Ye(s,"maxPool3d");const d=ll(s.shape,o,i,1,a,l,c),p=t.data.get(s.dataId).values,m=ZO(p,s.shape,s.dtype,tt(s.shape),d,"max");return t.makeTensorInfo(m.shape,"float32",m.values)}const QY={kernelName:K1,backendName:"cpu",kernelFunc:YY};function JY(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,input:o}=e,{filterSize:i,strides:a,pad:l,dimRoundingMode:c}=r;Ye([s,o],"maxPool3DGrad");const d=ll(o.shape,i,a,1,l,c),p=t.bufferSync(o),m=BX(p,d),y=d.strideDepth,v=d.strideHeight,b=d.strideWidth,w=d.dilationDepth,k=d.dilationHeight,I=d.dilationWidth,N=d.effectiveFilterDepth,T=d.effectiveFilterHeight,A=d.effectiveFilterWidth,O=N-1-d.padInfo.front,P=A-1-d.padInfo.left,B=T-1-d.padInfo.top,z=Nt(o.shape,"float32"),L=t.bufferSync(s);for(let _=0;_<d.batchSize;++_)for(let H=0;H<d.inChannels;++H)for(let Y=0;Y<d.inDepth;++Y)for(let re=0;re<d.inHeight;++re)for(let te=0;te<d.inWidth;++te){const le=Y-O,de=re-B,j=te-P;let ie=0;for(let se=0;se<N;se+=w){const V=(le+se)/y;if(!(V<0||V>=d.outDepth||Math.floor(V)!==V))for(let X=0;X<T;X+=k){const xe=(de+X)/v;if(!(xe<0||xe>=d.outHeight||Math.floor(xe)!==xe))for(let Ie=0;Ie<A;Ie+=I){const ke=(j+Ie)/b;if(ke<0||ke>=d.outWidth||Math.floor(ke)!==ke)continue;const Ee=N*T*A-1-m.get(_,V,xe,ke,H),Me=se*T*A+X*A+Ie,ze=Ee===Me?1:0;if(ze===0)continue;const Be=L.get(_,V,xe,ke,H);ie+=Be*ze}}}z.set(ie,_,Y,re,te,H)}return t.makeTensorInfo(z.shape,z.dtype,z.values)}const ZY={kernelName:GS,backendName:"cpu",kernelFunc:JY};function eQ(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,input:o,output:i}=e,a=o;Ye([o,i],"maxPoolGrad");const{filterSize:l,strides:c,pad:d,dimRoundingMode:p}=r,m=Xo(a.shape,l,c,1,d,p),y=t.data.get(a.dataId).values,v=Nt(m.outShape,a.dtype,JO(y,a.shape,a.dtype,m).values),b=m.strideHeight,w=m.strideWidth,k=m.dilationHeight,I=m.dilationWidth,N=m.effectiveFilterHeight,T=m.effectiveFilterWidth,A=T-1-m.padInfo.left,O=N-1-m.padInfo.top,P=Nt(a.shape,"float32"),B=t.data.get(s.dataId).values,z=Nt(s.shape,"float32",B);for(let L=0;L<m.batchSize;++L)for(let _=0;_<m.inChannels;++_)for(let H=0;H<m.inHeight;++H)for(let Y=0;Y<m.inWidth;++Y){const re=H-O,te=Y-A;let le=0;for(let de=0;de<N;de+=k){const j=(re+de)/b;if(!(j<0||j>=m.outHeight||Math.floor(j)!==j))for(let ie=0;ie<T;ie+=I){const se=(te+ie)/w;if(se<0||se>=m.outWidth||Math.floor(se)!==se)continue;const V=N*T-1-v.get(L,j,se,_),X=de*T+ie,xe=V===X?1:0;if(xe===0)continue;const Ie=z.get(L,j,se,_);le+=Ie*xe}}P.set(le,L,H,Y,_)}return t.makeTensorInfo(P.shape,P.dtype,P.values)}const tQ={kernelName:VS,backendName:"cpu",kernelFunc:eQ};function nQ(n,e,t,r,s){const o=tt(e),i=MI(n,e,t,o,s,"max"),a=JO(n,e,t,s,!0,r);return[i.values,a.values]}const rQ={kernelName:EE,backendName:"cpu",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{x:r}=n,{filterSize:s,strides:o,pad:i,includeBatchInIndex:a}=e,l=t;Ye(r,"MaxPoolWithArgmax");const c=l.data.get(r.dataId).values,d=Xo(r.shape,s,o,[1,1],i),[p,m]=nQ(c,r.shape,r.dtype,a,d),y=l.write(p,d.outShape,r.dtype),v=l.write(m,d.outShape,r.dtype);return[{dataId:y,shape:d.outShape,dtype:r.dtype},{dataId:v,shape:d.outShape,dtype:"int32"}]}};function sQ(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o,keepDims:i}=r,a=Tt(o,s.shape),c=yr(s.shape,a)[1],d=Se(c),p=[],m=t.makeTensorInfo([],"float32",new Float32Array([d]));p.push(m);const y=du({inputs:{x:s},backend:t,attrs:{dtype:"float32"}});p.push(y);const v=zI({inputs:{a:y,b:m},backend:t});p.push(v);const b=mx({inputs:{x:v},backend:t,attrs:{axis:o,keepDims:i}});return p.forEach(w=>t.disposeIntermediateTensorInfo(w)),b}const oQ={kernelName:X1,backendName:"cpu",kernelFunc:sQ};function iQ(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o,keepDims:i}=r;Ye(s,"min");const a=Tt(o,s.shape);let l=a;const c=En(l,s.shape.length);let d=s;c!=null&&(d=Ns({inputs:{x:s},backend:t,attrs:{perm:c}}),l=Wn(l.length,s.shape.length)),Dr("min",l,d.shape.length);const[p,m]=yr(d.shape,l),y=Se(m),v=Gr(Se(p),d.dtype),b=t.data.get(d.dataId).values;for(let k=0;k<v.length;++k){const I=k*y;let N=b[I];for(let T=0;T<y;++T){const A=b[I+T];(Number.isNaN(A)||A<N)&&(N=A)}v[k]=N}c!=null&&t.disposeIntermediateTensorInfo(d);const w=t.makeTensorInfo(p,d.dtype,v);if(i){const k=Yn(p,a),I=gn({inputs:{x:w},backend:t,attrs:{shape:k}});return t.disposeIntermediateTensorInfo(w),I}return w}const aQ={kernelName:Y1,backendName:"cpu",kernelFunc:iQ};function lQ(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{paddings:o,mode:i}=r;Ye(s,"mirrorPad");const a=o.map((N,T)=>N[0]+s.shape[T]+N[1]),l=o.map(N=>N[0]),c=o.map((N,T)=>N[0]+s.shape[T]),d=i==="reflect"?0:1,p=t.data.get(s.dataId).values,m=s.shape.length,y=tt(s.shape),v=Se(a),b=a.length,w=tt(a),k=Vr(s.dtype,v);for(let N=0;N<v;N++){let T=Sf(N,b,w);for(let O=0;O<b;O++)T[O]<l[O]?T[O]=l[O]*2-T[O]-d:T[O]>=c[O]&&(T[O]=(c[O]-1)*2-T[O]+d);T=T.map((O,P)=>O-l[P]);const A=ca(T,m,y);k[N]=p[A]}return{dataId:t.write(k,a,s.dtype),shape:a,dtype:s.dtype}}const uQ={kernelName:Q1,backendName:"cpu",kernelFunc:lQ};const cQ=Gn(((n,e)=>{const t=n%e;return n<0&&e<0||n>=0&&e>=0?t:(t+e)%e})),hQ=lr(Rg,cQ),dQ={kernelName:Rg,backendName:"cpu",kernelFunc:hQ};function sF(n){const{inputs:e,backend:t,attrs:r}=n,{logits:s}=e,{dim:o}=r,i=s.shape.length;let a=o;if(a===-1&&(a=i-1),a!==i-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${i} and dim was ${a}`);const l=Tt([a],s.shape),c=rF({inputs:{x:s},backend:t,attrs:{reductionIndices:l,keepDims:!1}}),d=Yn(c.shape,l),p=gn({inputs:{x:c},backend:t,attrs:{shape:d}}),m=LI({inputs:{a:s,b:p},backend:t}),y=lO({inputs:{x:m},backend:t}),v=mx({inputs:{x:y},backend:t,attrs:{axis:l,keepDims:!1}}),b=gn({inputs:{x:v},backend:t,attrs:{shape:d}}),w=zI({inputs:{a:y,b},backend:t});return t.disposeIntermediateTensorInfo(c),t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(m),t.disposeIntermediateTensorInfo(y),t.disposeIntermediateTensorInfo(v),t.disposeIntermediateTensorInfo(b),w}const fQ={kernelName:mv,backendName:"cpu",kernelFunc:sF};function pQ(n){const{inputs:e,backend:t,attrs:r}=n,{logits:s}=e,{numSamples:o,seed:i,normalized:a}=r;Ye(s,"multinomial");const l=a?s:sF({inputs:{logits:s},backend:t,attrs:{dim:-1}}),c=l.shape[0],d=l.shape[1],p=t.data.get(l.dataId).values,m=[c,o],y=Gr(Se(m),"int32");for(let v=0;v<c;++v){const b=v*d,w=new Float32Array(d-1);w[0]=p[b];for(let N=1;N<w.length;++N)w[N]=w[N-1]+p[b+N];const k=kk.alea(i.toString()),I=v*o;for(let N=0;N<o;++N){const T=k();y[I+N]=w.length;for(let A=0;A<w.length;A++)if(T<w[A]){y[I+N]=A;break}}}return a||t.disposeIntermediateTensorInfo(l),t.makeTensorInfo(m,"int32",y)}const mQ={kernelName:RE,backendName:"cpu",kernelFunc:pQ};const gQ=Dk;function xQ(n){const{inputs:e,backend:t,attrs:r}=n,{boxes:s,scores:o}=e,{maxOutputSize:i,iouThreshold:a,scoreThreshold:l}=r;Ye(s,"NonMaxSuppression");const c=t.data.get(s.dataId).values,d=t.data.get(o.dataId).values,{selectedIndices:p}=gQ(c,d,i,a,l);return t.makeTensorInfo([p.length],"int32",new Int32Array(p))}const yQ={kernelName:jS,backendName:"cpu",kernelFunc:xQ};const vQ=Ok;function wQ(n){const{inputs:e,backend:t,attrs:r}=n,{boxes:s,scores:o}=e,{maxOutputSize:i,iouThreshold:a,scoreThreshold:l,padToMaxOutputSize:c}=r;Ye(s,"NonMaxSuppressionPadded");const d=t.data.get(s.dataId).values,p=t.data.get(o.dataId).values,{selectedIndices:m,validOutputs:y}=vQ(d,p,i,a,l,c);return[t.makeTensorInfo([m.length],"int32",new Int32Array(m)),t.makeTensorInfo([],"int32",new Int32Array([y]))]}const bQ={kernelName:HS,backendName:"cpu",kernelFunc:wQ};const CQ=Fk;function SQ(n){const{inputs:e,backend:t,attrs:r}=n,{boxes:s,scores:o}=e,{maxOutputSize:i,iouThreshold:a,scoreThreshold:l,softNmsSigma:c}=r;Ye(s,"NonMaxSuppressionWithScore");const d=t.data.get(s.dataId).values,p=t.data.get(o.dataId).values,m=i,y=a,v=l,b=c,{selectedIndices:w,selectedScores:k}=CQ(d,p,m,y,v,b);return[t.makeTensorInfo([w.length],"int32",new Int32Array(w)),t.makeTensorInfo([k.length],"float32",new Float32Array(k))]}const kQ={kernelName:qS,backendName:"cpu",kernelFunc:SQ};function IQ(n){const{inputs:e,backend:t,attrs:r}=n,{indices:s}=e,{dtype:o,depth:i,onValue:a,offValue:l}=r;Ye(s,"oneHot");const c=Se(s.shape),d=new Float32Array(c*i);d.fill(l);const p=t.data.get(s.dataId).values;for(let m=0;m<c;++m)p[m]>=0&&p[m]<i&&(d[m*i+p[m]]=a);return t.makeTensorInfo([...s.shape,i],o,d)}const $Q={kernelName:tv,backendName:"cpu",kernelFunc:IQ};function a1(n){const{inputs:e,backend:t}=n,{x:r}=e;if(r.dtype==="string")throw new Error("zerosLike is not supported for string tensors");if(r.dtype==="complex64"){const s=nh({inputs:{input:r},backend:t}),o=a1({inputs:{x:s},backend:t}),i=ff({inputs:{input:r},backend:t}),a=a1({inputs:{x:i},backend:t}),l=Hs({inputs:{real:o,imag:a},backend:t});return t.disposeIntermediateTensorInfo(s),t.disposeIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(a),l}else return BI({backend:t,attrs:{shape:r.shape,value:0,dtype:r.dtype}})}const NQ={kernelName:yv,backendName:"cpu",kernelFunc:a1};function oF(n){const{inputs:e,backend:t}=n,{x:r}=e;if(r.dtype==="string")throw new Error("onesLike is not supported for string tensors");if(r.dtype==="complex64"){const s=nh({inputs:{input:r},backend:t}),o=oF({inputs:{x:s},backend:t}),i=ff({inputs:{input:r},backend:t}),a=a1({inputs:{x:i},backend:t}),l=Hs({inputs:{real:o,imag:a},backend:t});return t.disposeIntermediateTensorInfo(s),t.disposeIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(a),l}else return BI({backend:t,attrs:{shape:r.shape,value:1,dtype:r.dtype}})}const TQ={kernelName:ev,backendName:"cpu",kernelFunc:oF};function iF(n){const{inputs:e,backend:t,attrs:r}=n,{axis:s}=r;if(e.length===1)return i1({inputs:{input:e[0]},backend:t,attrs:{dim:s}});const o=e[0].shape,i=e[0].dtype;e.forEach(d=>{fS(o,d.shape,"All tensors passed to stack must have matching shapes"),U(i===d.dtype,()=>"All tensors passed to stack must have matching dtypes")});const a=[],l=e.map(d=>{const p=i1({inputs:{input:d},backend:t,attrs:{dim:s}});return a.push(p),p}),c=pf({inputs:l,backend:t,attrs:{axis:s}});return a.forEach(d=>t.disposeIntermediateTensorInfo(d)),c}const EQ={kernelName:nv,backendName:"cpu",kernelFunc:iF};function RQ(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{paddings:o,constantValue:i}=r;Ye(s,"pad");const a=o.map((I,N)=>I[0]+s.shape[N]+I[1]),l=o.map(I=>I[0]),c=t.data.get(s.dataId).values,d=Se(s.shape),p=s.shape.length,m=tt(s.shape),y=Se(a),v=a.length,b=tt(a),w=Vr(s.dtype,y);i!==0&&w.fill(i);for(let I=0;I<d;I++){const T=Sf(I,p,m).map((O,P)=>O+l[P]),A=ca(T,v,b);w[A]=c[I]}return{dataId:t.write(w,a,s.dtype),shape:a,dtype:s.dtype}}const aF={kernelName:rv,backendName:"cpu",kernelFunc:RQ};const AQ=Gn((n,e)=>Math.pow(n,e)),_Q=lr(_g,AQ),DQ={kernelName:_g,backendName:"cpu",kernelFunc:_Q};function OQ(n){const{inputs:e,backend:t,attrs:r}=n,{paramsNestedSplits:s,paramsDenseValues:o,indices:i}=e,{outputRaggedRank:a}=r,l=s.map(k=>t.data.get(k.dataId).values),c=s.map(k=>k.shape),d=t.data.get(o.dataId).values,p=t.data.get(i.dataId).values,[m,y,v]=$O(l,c,d,o.shape,o.dtype,p,i.shape),b=m.map(k=>t.makeTensorInfo([k.length],"int32",k)),w=t.makeTensorInfo(v,o.dtype,y);return b.concat([w])}const FQ={kernelName:AE,backendName:"cpu",kernelFunc:OQ};function PQ(n){const{inputs:e,backend:t}=n,{starts:r,limits:s,deltas:o}=e,i=t.data.get(r.dataId).values,a=t.data.get(s.dataId).values,l=t.data.get(o.dataId).values,[c,d]=NO(i,r.shape,r.dtype,a,s.shape,l,o.shape),p=t.makeTensorInfo([c.length],"int32",c),m=t.makeTensorInfo([d.length],r.dtype,d);return[p,m]}const LQ={kernelName:_E,backendName:"cpu",kernelFunc:PQ};function MQ(n){const{inputs:e,backend:t,attrs:r}=n,{shape:s,values:o,defaultValue:i,rowPartitionTensors:a}=e,{rowPartitionTypes:l}=r,c=t.data.get(s.dataId).values,d=t.data.get(o.dataId).values,p=t.data.get(i.dataId).values,m=a.map(w=>t.data.get(w.dataId).values),y=a.map(w=>w.shape),[v,b]=TO(c,s.shape,d,o.shape,o.dtype,p,i.shape,m,y,l);return t.makeTensorInfo(v,o.dtype,b)}const zQ={kernelName:DE,backendName:"cpu",kernelFunc:MQ};function BQ(n){const{backend:e,attrs:t}=n,{start:r,stop:s,dtype:o,step:i}=t,a=EO(r,s,i,o);return e.makeTensorInfo([a.length],o,a)}const UQ={kernelName:KS,backendName:"cpu",kernelFunc:BQ};const WQ=sn(Dg,n=>1/n),VQ={kernelName:Dg,backendName:"cpu",kernelFunc:WQ};function GQ(n){const{inputs:e,backend:t,attrs:r}=n,{images:s}=e,{alignCorners:o,halfPixelCenters:i,size:a}=r;Ye(s,"resizeBilinear");const l=tt(s.shape),[c,d]=a,[p,m,y,v]=s.shape,b=t.data.get(s.dataId).values,w=new Float32Array(Se([p,c,d,v])),k=[o&&c>1?m-1:m,o&&d>1?y-1:y],I=[o&&c>1?c-1:c,o&&d>1?d-1:d];let N=0;const T=k[0]/I[0],A=k[1]/I[1];for(let O=0;O<p;O++)for(let P=0;P<c;P++){let B;i?B=T*(P+.5)-.5:B=T*P;const z=Math.max(0,Math.floor(B)),L=B-z,_=Math.min(m-1,Math.ceil(B)),H=O*l[0]+z*l[1],Y=O*l[0]+_*l[1];for(let re=0;re<d;re++){let te;i?te=A*(re+.5)-.5:te=A*re;const le=Math.max(0,Math.floor(te)),de=te-le,j=Math.min(y-1,Math.ceil(te)),ie=H+le*l[2],se=Y+le*l[2],V=H+j*l[2],X=Y+j*l[2];for(let xe=0;xe<v;xe++){const Ie=b[ie+xe],ke=b[se+xe],Ee=b[V+xe],Me=b[X+xe],ze=Ie+(Ee-Ie)*de,Be=ke+(Me-ke)*de,Je=ze+(Be-ze)*L;w[N++]=Je}}}return t.makeTensorInfo([p,c,d,v],"float32",w)}const jQ={kernelName:lv,backendName:"cpu",kernelFunc:GQ};function HQ(n){const{inputs:e,backend:t,attrs:r}=n,{images:s,dy:o}=e,{alignCorners:i}=r;Ye([o,s],"resizeBilinearGrad");const a=tt(s.shape),[l,c,d,p]=s.shape,[,m,y]=o.shape,v=new Float32Array(l*c*d*p),b=[i&&m>1?c-1:c,i&&y>1?d-1:d],w=[i&&m>1?m-1:m,i&&y>1?y-1:y],k=b[0]/w[0],I=b[1]/w[1],N=t.data.get(o.dataId).values;let T=0;for(let A=0;A<l;A++){const O=A*a[0];for(let P=0;P<m;P++){const B=P*k,z=Math.floor(B),L=Math.min(Math.ceil(B),c-1),_=O+z*a[1],H=O+L*a[1],Y=B-z,re=1-Y;for(let te=0;te<y;te++){const le=te*I,de=Math.floor(le),j=Math.min(Math.ceil(le),d-1),ie=le-de,se=1-ie,V=_+de*a[2],X=_+j*a[2],xe=H+de*a[2],Ie=H+j*a[2],ke=re*se,Ee=re*ie,Me=Y*se,ze=Y*ie;for(let Be=0;Be<p;Be++){const Je=N[T++];v[V+Be]+=Je*ke,v[X+Be]+=Je*Ee,v[xe+Be]+=Je*Me,v[Ie+Be]+=Je*ze}}}}return t.makeTensorInfo([l,d,c,p],"float32",v)}const qQ={kernelName:QS,backendName:"cpu",kernelFunc:HQ};function KQ(n){const{inputs:e,backend:t,attrs:r}=n,{images:s}=e,{alignCorners:o,halfPixelCenters:i,size:a}=r;Ye(s,"resizeNearestNeighbor");const l=tt(s.shape),[c,d]=a,[p,m,y,v]=s.shape,b=t.data.get(s.dataId).values,w=new Float32Array(p*c*d*v),k=[o&&c>1?m-1:m,o&&d>1?y-1:y],I=[o&&c>1?c-1:c,o&&d>1?d-1:d],N=k[0]/I[0],T=k[1]/I[1];let A=0;for(let O=0;O<p;O++){const P=O*l[0];for(let B=0;B<c;B++){const z=i?N*(B+.5):N*B;let L=Math.min(m-1,o?Math.round(z):Math.floor(z));i&&(L=Math.max(0,L));const _=P+L*l[1];for(let H=0;H<d;H++){const Y=i?T*(H+.5):T*H;let re=Math.min(y-1,o?Math.round(Y):Math.floor(Y));i&&(re=Math.max(0,re));const te=_+re*l[2];for(let le=0;le<v;le++){const de=b[te+le];w[A++]=de}}}}return t.makeTensorInfo([p,c,d,v],s.dtype,w)}const XQ={kernelName:av,backendName:"cpu",kernelFunc:KQ};function YQ(n){const{inputs:e,backend:t,attrs:r}=n,{images:s,dy:o}=e,{alignCorners:i}=r;Ye([o,s],"resizeNearestNeighborGrad");const a=tt(s.shape),l=tt(o.shape),[c,d,p,m]=s.shape,[,y,v]=o.shape,b=new Float32Array(c*d*p*m),w=t.data.get(o.dataId).values,k=[i&&y>1?d-1:d,i&&v>1?p-1:p],I=[i&&y>1?y-1:y,i&&v>1?v-1:v],N=k[0]/I[0],T=k[1]/I[1],A=1/N,O=1/T,P=Math.ceil(A)*2+2,B=Math.ceil(O)*2+2;for(let z=0;z<c;z++){const L=z*a[0];for(let _=0;_<d;_++){const H=L+_*a[1],Y=Math.floor(_*A),re=Math.floor(Y-P/2);for(let te=0;te<p;te++){const le=H+te*a[2],de=Math.floor(te*O),j=Math.floor(de-B/2);for(let ie=0;ie<m;ie++){let se=0;for(let V=0;V<P;V++){const X=V+re;if(X<0||X>=y)continue;const xe=L+X*l[1],Ie=X*N,ke=Math.min(d-1,i?Math.round(Ie):Math.floor(Ie));if(_===ke)for(let Ee=0;Ee<B;Ee++){const Me=Ee+j;if(Me<0||Me>=v)continue;const ze=xe+Me*l[2],Be=Me*T,Je=Math.min(p-1,i?Math.round(Be):Math.floor(Be));te===Je&&(se+=w[ze+ie])}}b[le+ie]=se}}}}return t.makeTensorInfo(s.shape,s.dtype,b)}const QQ={kernelName:YS,backendName:"cpu",kernelFunc:YQ};function JQ(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{dims:o}=r;Ye(s,"reverse");const i=s.shape.length,a=Tt(o,s.shape);if(i===0)return wa({inputs:{x:s},backend:t});const l=new Ar(s.shape,s.dtype),c=t.bufferSync(s);for(let d=0;d<l.size;d++){const p=l.indexToLoc(d),m=p.slice();a.forEach(y=>m[y]=s.shape[y]-1-m[y]),l.set(c.get(...m),...p)}return t.makeTensorInfo(l.shape,l.dtype,l.values)}const ZQ={kernelName:uv,backendName:"cpu",kernelFunc:JQ};const eJ={kernelName:sk,backendName:"cpu",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{image:r}=n,{radians:s,fillValue:o,center:i}=e,a=t,l=Vr(r.dtype,Se(r.shape)),[c,d,p,m]=r.shape,[y,v]=qk(i,d,p),b=255,w=Math.sin(s),k=Math.cos(s),I=a.data.get(r.dataId).values;for(let T=0;T<c;T++){const A=T*p*d*m;for(let O=0;O<d;O++){const P=O*(p*m);for(let B=0;B<p;B++){const z=B*m;for(let L=0;L<m;L++){const _=[c,O,B,L],H=_[2],Y=_[1];let re=(H-y)*k-(Y-v)*w,te=(H-y)*w+(Y-v)*k;re=Math.round(re+y),te=Math.round(te+v);let le=o;if(typeof o!="number"&&(L===3?le=b:le=o[L]),re>=0&&re<p&&te>=0&&te<d){const j=te*(p*m),ie=re*m,se=A+j+ie+L;le=I[se]}const de=A+P+z+L;l[de]=le}}}}return{dataId:a.write(l,r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}};const tJ=sn(Pg,n=>{const e=Math.floor(n);return n-e<.5?Math.floor(n):n-e>.5?Math.ceil(n):e%2===0?e:e+1}),nJ={kernelName:Pg,backendName:"cpu",kernelFunc:tJ};function rJ(n){const{inputs:e,backend:t,attrs:r}=n,{indices:s,updates:o}=e,{shape:i}=r,{sliceRank:a,numUpdates:l,sliceSize:c,strides:d,outputSize:p}=ch(o,s,i),m=!0,y=t.bufferSync(s),v=t.bufferSync(o),b=Fc(y,v,i,p,c,l,a,d,0,m);return t.makeTensorInfo(i,b.dtype,b.values)}const sJ={kernelName:OE,backendName:"cpu",kernelFunc:rJ};function oJ(n,e){let t=0,r=n.length,s=0;for(;t<r;)s=Math.floor((t+r)/2),n[s]<e?t=s+1:r=s;return r}function iJ(n,e){let t=0,r=n.length,s=0;for(;t<r;)s=Math.floor((t+r)/2),n[s]<=e?t=s+1:r=s;return r}function aJ(n,e,t,r,s,o){const i=Mn("int32",t*s);for(let a=0;a<t;++a){const l=n.slice(a*r,(a+1)*r),c=a*s;for(let d=0;d<s;++d)i[c+d]=o==="left"?oJ(l,e[d+c]):iJ(l,e[d+c])}return i}function lJ(n){const{inputs:e,backend:t,attrs:r}=n,{sortedSequence:s,values:o}=e,{side:i}=r,a=t.data.get(s.dataId).values,l=t.data.get(o.dataId).values,c=aJ(a,l,s.shape[0],s.shape[1],o.shape[1],i);return t.makeTensorInfo(o.shape,"int32",c)}const uJ={kernelName:PE,backendName:"cpu",kernelFunc:lJ};function cJ(n){const{inputs:e,backend:t}=n,{condition:r,t:s,e:o}=e;Ye([r,s,o],"select");const i=r.shape.length,a=t.data.get(r.dataId).values,l=t.data.get(s.dataId).values,c=t.data.get(o.dataId).values,d=Ys(s.dtype,o.dtype),p=Gr(Se(s.shape),d);let m=0;const y=i===0||i>1||s.shape.length===1?1:Se(s.shape.slice(1));for(let v=0;v<a.length;v++)for(let b=0;b<y;b++)a[v]===1?p[m++]=l[v]:p[m++]=c[v];return t.makeTensorInfo(s.shape,d,p)}const hJ={kernelName:cv,backendName:"cpu",kernelFunc:cJ};const dJ=Tv,fJ=Ev,pJ=sn(Mg,n=>n>=0?fJ*n:dJ*(Math.exp(n)-1)),mJ={kernelName:Mg,backendName:"cpu",kernelFunc:pJ};const gJ=sn(Ug,n=>n<0?-1:n>0?1:0),xJ={kernelName:Ug,backendName:"cpu",kernelFunc:gJ};const yJ=sn(zg,n=>Math.sin(n)),vJ={kernelName:zg,backendName:"cpu",kernelFunc:yJ};const wJ=sn(Bg,n=>Math.sinh(n)),bJ={kernelName:Bg,backendName:"cpu",kernelFunc:wJ};const CJ=11920928955078125e-23,L2=Math.log(CJ)+2,SJ=sn(Vg,n=>{const e=n>-L2,t=n<L2,r=Math.exp(n);let s;return t?s=r:e?s=n:s=Math.log(1+r),s}),kJ={kernelName:Vg,backendName:"cpu",kernelFunc:SJ};function IJ(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{blockShape:o,paddings:i}=r;Ye([s],"spaceToBatchND");const a=Se(o),l=[[0,0]];l.push(...i);for(let O=1+o.length;O<s.shape.length;++O)l.push([0,0]);const c=aF.kernelFunc({inputs:{x:s},backend:t,attrs:{paddings:l,constantValue:0}}),d=sx(c.shape,o,a,!1),p=ox(d.length,o.length,!1),m=ix(c.shape,o,a,!1),b=gn({inputs:{x:c},backend:t,attrs:{shape:d}}),I=Ns({inputs:{x:b},backend:t,attrs:{perm:p}}),A=gn({inputs:{x:I},backend:t,attrs:{shape:m}});return t.disposeIntermediateTensorInfo(c),t.disposeIntermediateTensorInfo(b),t.disposeIntermediateTensorInfo(I),A}const $J={kernelName:fv,backendName:"cpu",kernelFunc:IJ};function NJ(n){const{inputs:e,backend:t}=n,{indices:r,values:s,denseShape:o,defaultValue:i}=e;if(o.shape.length!==1)throw new Error(`Dense shape must be a vector, saw:
${o.shape}`);if(r.shape.length!==2)throw new Error(`Indices must be a matrix, saw:
${r.shape}`);if(s.shape.length!==1)throw new Error(`Values must be a vector, saw:
${s.shape}`);if(i.shape.length!==0)throw new Error(`Default value must be a scalar, saw:
${i.shape}`);const a=t.data.get(r.dataId).values,l=t.data.get(s.dataId).values,c=t.data.get(o.dataId).values,d=t.data.get(i.dataId).values[0],[p,m,y,v,b]=DO(a,r.shape,r.dtype,l,s.dtype,c,d);return[t.makeTensorInfo(m,r.dtype,p),t.makeTensorInfo([m[0]],s.dtype,y),t.makeTensorInfo([v.length],"bool",new Uint8Array(v.map(w=>Number(w)))),t.makeTensorInfo([b.length],r.dtype,new Int32Array(b))]}const TJ={kernelName:LE,backendName:"cpu",kernelFunc:NJ};function EJ(n){const{inputs:e,backend:t}=n,{inputIndices:r,inputShape:s,newShape:o}=e;if(r.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape
${r.shape}`);if(s.shape.length!==1)throw new Error(`Input shape should be a vector but received shape
${s.shape}`);if(o.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${o.shape}`);const i=Array.from(t.data.get(s.dataId).values),a=t.data.get(r.dataId).values,l=Array.from(t.data.get(o.dataId).values),[c,d,p]=OO(a,r.shape,r.dtype,i,l);return[t.makeTensorInfo(d,r.dtype,c),t.makeTensorInfo([p.length],o.dtype,new Int32Array(p))]}const RJ={kernelName:ME,backendName:"cpu",kernelFunc:EJ};function AJ(n){const{inputs:e,backend:t}=n,{data:r,indices:s,segmentIds:o}=e;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(s.shape.length!==1)throw new Error(`Indices should be a vector but received shape
${s.shape}`);if(o.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
${o.shape}`);if(s.shape[0]!==o.shape[0])throw new Error("segmentIds and indices should have same size.");const i=t.data.get(r.dataId).values,a=t.data.get(s.dataId).values,l=t.data.get(o.dataId).values,[c,d]=PI(i,r.shape,r.dtype,a,l,!0);return t.makeTensorInfo(d,r.dtype,c)}const _J={kernelName:zE,backendName:"cpu",kernelFunc:AJ};function DJ(n){const{inputs:e,backend:t}=n,{data:r,indices:s,segmentIds:o}=e;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(s.shape.length!==1)throw new Error(`Indices should be a vector but received shape
${s.shape}`);if(o.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
${o.shape}`);if(s.shape[0]!==o.shape[0])throw new Error("segmentIds and indices should have same size.");const i=t.data.get(r.dataId).values,a=t.data.get(s.dataId).values,l=t.data.get(o.dataId).values,[c,d]=PI(i,r.shape,r.dtype,a,l);return t.makeTensorInfo(d,r.dtype,c)}const OJ={kernelName:BE,backendName:"cpu",kernelFunc:DJ};function FJ(n){const{inputs:e,backend:t,attrs:r}=n,{sparseIndices:s,sparseValues:o,defaultValue:i}=e,{outputShape:a}=r,{sliceRank:l,numUpdates:c,sliceSize:d,strides:p,outputSize:m}=ch(o,s,a),y=!1,v=t.bufferSync(s);let b;switch(o.dtype){case"bool":{const w=t.bufferSync(o),k=!!t.data.get(i.dataId).values[0];b=Fc(v,w,a,m,d,c,l,p,k,y);break}case"float32":{const w=t.bufferSync(o),k=t.data.get(i.dataId).values[0];b=Fc(v,w,a,m,d,c,l,p,k,y);break}case"int32":{const w=t.bufferSync(o),k=t.data.get(i.dataId).values[0];b=Fc(v,w,a,m,d,c,l,p,k,y);break}case"string":{const w=t.bufferSync(o),k=au(t.data.get(i.dataId).values[0]);b=Fc(v,w,a,m,d,c,l,p,k,y);break}default:throw new Error(`Unsupported type ${o.dtype}`)}return t.makeTensorInfo(a,b.dtype,b.values)}const PJ={kernelName:UE,backendName:"cpu",kernelFunc:FJ};function LJ(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{numOrSizeSplits:o,axis:i}=r,a=Tt(i,s.shape)[0],l=lI(s,o,a),c=new Array(s.shape.length).fill(0),d=s.shape.slice();return l.map(p=>{const m=[...d];m[a]=p;const y=rh({inputs:{x:s},backend:t,attrs:{begin:c,size:m}});return c[a]+=p,y})}const MJ={kernelName:pv,backendName:"cpu",kernelFunc:LJ};const zJ={kernelName:JS,backendName:"cpu",kernelFunc:({inputs:n,backend:e})=>{const{x:t}=n,r=e;Ye(t,"square");const s=r.data.get(t.dataId).values,o=new Float32Array(s.length);for(let a=0;a<s.length;++a){const l=s[a];o[a]=l*l}return{dataId:r.write(o,t.shape,t.dtype),shape:t.shape,dtype:t.dtype}}};const BJ=sn(Yg,(n,e)=>{const t=e;return isNaN(n)?NaN:n>0?1:t.alpha}),UJ={kernelName:Yg,backendName:"cpu",kernelFunc:BJ};function WJ(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{begin:o,end:i,strides:a,beginMask:l,endMask:c,ellipsisMask:d,newAxisMask:p,shrinkAxisMask:m}=r;Ye(s,"stridedSlice");const{finalShapeSparse:y,finalShape:v,isIdentity:b,sliceDim0:w,isSimpleSlice:k,begin:I,end:N,strides:T}=Gk(s.shape,o,i,a,l,c,d,p,m);let A;if(b)A=gn({inputs:{x:s},backend:t,attrs:{shape:v}});else if(w||k){U(s.shape.length>=1,()=>`Input must have rank at least 1, got: ${s.shape.length}`);const O=Uk(I,N,T),P=rh({inputs:{x:s},backend:t,attrs:{begin:I,size:O}});A=gn({inputs:{x:P},backend:t,attrs:{shape:v}}),t.disposeIntermediateTensorInfo(P)}else{const O=t.bufferSync(s),P=LO(y,O,T,I);A=t.makeTensorInfo(v,P.dtype,P.values)}return A}const VJ={kernelName:ek,backendName:"cpu",kernelFunc:WJ};function GJ(n){const{inputs:e,backend:t,attrs:r}=n,{separator:s,nGramWidths:o,leftPad:i,rightPad:a,padWidth:l,preserveShortSequences:c}=r,{data:d,dataSplits:p}=e,m=t.data.get(d.dataId).values,y=t.data.get(p.dataId).values,[v,b]=MO(m,y,s,o,i,a,l,c);return[t.makeTensorInfo([v.length],"string",v),t.makeTensorInfo(p.shape,"int32",b)]}const jJ={kernelName:WE,backendName:"cpu",kernelFunc:GJ};function HJ(n){const{inputs:e,backend:t,attrs:r}=n,{skipEmpty:s}=r,{input:o,delimiter:i}=e;if(o.dtype!=="string")throw new Error("Input must be of datatype string");if(o.shape.length!==1)throw new Error(`Input must be a vector, got shape: ${o.shape}`);if(i.shape.length!==0)throw new Error(`Delimiter must be a scalar, got shape: ${i.shape}`);const a=t.data.get(o.dataId).values,l=t.data.get(i.dataId).values[0],[c,d,p]=zO(a,l,s),m=d.length;return[t.makeTensorInfo([m,2],"int32",c),t.makeTensorInfo([m],"string",d),t.makeTensorInfo([2],"int32",new Int32Array(p))]}const qJ={kernelName:VE,backendName:"cpu",kernelFunc:HJ};function KJ(n){const{inputs:e,backend:t,attrs:r}=n,{numBuckets:s}=r,{input:o}=e;if(o.dtype!=="string")throw new Error("Input must be of datatype string");if(s<=0)throw new Error("Number of buckets must be at least 1");const i=t.data.get(o.dataId).values,a=BO(i,s);return t.makeTensorInfo(o.shape,"int32",a)}const XJ={kernelName:GE,backendName:"cpu",kernelFunc:KJ};const YJ=sn(qg,n=>Math.tan(n)),QJ={kernelName:qg,backendName:"cpu",kernelFunc:YJ};const JJ=sn(Kg,n=>Math.tanh(n)),ZJ={kernelName:Kg,backendName:"cpu",kernelFunc:JJ};function eZ(n){const{inputs:e,backend:t}=n,{tensor:r,indices:s,updates:o}=e,{sliceRank:i,numUpdates:a,sliceSize:l,strides:c,outputSize:d}=ch(o,s,r.shape),p=!1,m=t.bufferSync(s),y=t.bufferSync(o),v=t.bufferSync(r),b=Fc(m,y,r.shape,d,l,a,i,c,v,p);return t.makeTensorInfo(r.shape,b.dtype,b.values)}const tZ={kernelName:FE,backendName:"cpu",kernelFunc:eZ};function nZ(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{reps:o}=r;Ye(s,"tile");const i=WO(t.bufferSync(s),o);return t.makeTensorInfo(i.shape,i.dtype,i.values)}const rZ={kernelName:Xg,backendName:"cpu",kernelFunc:nZ};function sZ(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{k:o,sorted:i}=r;Ye(s,"topk");const a=t.data.get(s.dataId).values,[l,c]=GO(a,s.shape,s.dtype,o,i);return[t.makeTensorInfo(l.shape,l.dtype,l.values),t.makeTensorInfo(c.shape,c.dtype,c.values)]}const oZ={kernelName:tk,backendName:"cpu",kernelFunc:sZ};function iZ(n){const{inputs:e,attrs:t,backend:r}=n,{image:s,transforms:o}=e,{interpolation:i,fillMode:a,fillValue:l,outputShape:c}=t,[d,p,m,y]=s.shape,[v,b]=c??[p,m],w=[d,v,b,y],k=tt(s.shape),I=k[0],N=k[1],T=k[2],A=tt(w),O=A[0],P=A[1],B=A[2],z=Vr(s.dtype,Se(w));z.fill(l);const L=r.data.get(s.dataId).values,_=r.data.get(o.dataId).values;for(let Y=0;Y<d;++Y){const re=o.shape[0]===1?_:_.subarray(Y*8,Y*8+8);for(let te=0;te<v;++te)for(let le=0;le<b;++le)for(let de=0;de<y;++de){let j;const ie=re[6]*le+re[7]*te+1;if(ie===0)continue;const se=(re[0]*le+re[1]*te+re[2])/ie,V=(re[3]*le+re[4]*te+re[5])/ie,X=M2(se,m,a),xe=M2(V,p,a);switch(i){case"nearest":j=dZ(L,p,m,I,N,T,Y,xe,X,de,l);break;case"bilinear":j=fZ(L,p,m,I,N,T,Y,xe,X,de,l);break;default:throw new Error(`Error in Transform: Expect 'nearest' or 'bilinear', but got ${i}`)}const Ie=Y*O+te*P+le*B+de;z[Ie]=j}return r.makeTensorInfo(w,s.dtype,z)}return{dataId:r.write(z,w,s.dtype),shape:s.shape,dtype:s.dtype}}const aZ={kernelName:nk,backendName:"cpu",kernelFunc:iZ};function M2(n,e,t){switch(t){case"reflect":return lZ(n,e);case"wrap":return uZ(n,e);case"nearest":return hZ(n,e);case"constant":default:return cZ(n)}}function lZ(n,e){let t=n;if(t<0)if(e<=1)t=0;else{const r=2*e;t<r&&(t=r*Math.trunc(-t/r)+t),t=t<-e?t+r:-t-1}else if(t>e-1)if(e<=1)t=0;else{const r=2*e;t-=r*Math.trunc(t/r),t>=e&&(t=r-t-1)}return Gc(0,t,e-1)}function uZ(n,e){let t=n;if(t<0)if(e<=1)t=0;else{const r=e-1;t+=e*(Math.trunc(-t/r)+1)}else if(t>e-1)if(e<=1)t=0;else{const r=e-1;t-=e*Math.trunc(t/r)}return Gc(0,t,e-1)}function cZ(n,e){return n}function hZ(n,e){return Gc(0,n,e-1)}function Sm(n,e,t,r,s,o,i,a,l,c,d){const p=i*r+a*s+l*o+c;return 0<=a&&a<e&&0<=l&&l<t?n[p]:d}function dZ(n,e,t,r,s,o,i,a,l,c,d){const p=Math.round(a),m=Math.round(l);return Sm(n,e,t,r,s,o,i,p,m,c,d)}function fZ(n,e,t,r,s,o,i,a,l,c,d){const p=Math.floor(a),m=Math.floor(l),y=p+1,v=m+1,b=(v-l)*Sm(n,e,t,r,s,o,i,p,m,c,d)+(l-m)*Sm(n,e,t,r,s,o,i,p,v,c,d),w=(v-l)*Sm(n,e,t,r,s,o,i,y,m,c,d)+(l-m)*Sm(n,e,t,r,s,o,i,y,v,c,d);return(y-a)*b+(a-p)*w}function pZ(n){const{inputs:e,attrs:t,backend:r}=n,{axis:s}=t,{x:o}=e;Ye(o,"unique");const i=r.data.get(o.dataId).values,{outputValues:a,outputShape:l,indices:c}=jO(i,s,o.shape,o.dtype);return[r.makeTensorInfo(l,o.dtype,a),r.makeTensorInfo([c.length],"int32",c)]}const mZ={kernelName:rk,backendName:"cpu",kernelFunc:pZ};function gZ(n){const{inputs:e,backend:t,attrs:r}=n,{value:s}=e;let{axis:o}=r;o<0&&(o+=s.shape.length);const i=s.shape.length,a=s.shape[o],l=new Array(i-1);let c=0;for(let y=0;y<i;y++)y!==o&&(l[c++]=s.shape[y]);const d=new Array(i).fill(0),p=s.shape.slice();p[o]=1;const m=new Array(a);for(let y=0;y<m.length;y++){d[o]=y;const v=rh({inputs:{x:s},backend:t,attrs:{begin:d,size:p}});m[y]=gn({inputs:{x:v},backend:t,attrs:{shape:l}}),t.disposeIntermediateTensorInfo(v)}return m}const xZ={kernelName:gv,backendName:"cpu",kernelFunc:gZ};function yZ(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,segmentIds:o}=e,{numSegments:i}=r;Ye(s,"unsortedSegmentSum");const a=s.shape.length,l=o.shape.length,c=[],d=[],p=a-l;let m=o;for(let v=0;v<p;++v){const b=i1({inputs:{input:m},backend:t,attrs:{dim:v+1}});m=b,d.push(b)}for(let v=0;v<i;++v){const b=mu(v,"int32"),w=t.makeTensorInfo([],"int32",b),k=iO({inputs:{a:w,b:m},backend:t}),I=du({inputs:{x:k},backend:t,attrs:{dtype:"float32"}}),N=Uv({inputs:{a:I,b:s},backend:t}),T=mx({inputs:{x:N},backend:t,attrs:{axis:0,keepDims:!1}});c.push(T),d.push(w),d.push(k),d.push(I),d.push(N),d.push(T)}const y=iF({inputs:c,backend:t,attrs:{axis:0}});return d.forEach(v=>t.disposeIntermediateTensorInfo(v)),y}const vZ={kernelName:xv,backendName:"cpu",kernelFunc:yZ};const wZ=[pX,KK,gX,yX,e7,wX,CX,kX,$X,TX,RX,_X,OX,LX,zX,WX,GX,HX,KX,dX,YX,JX,e9,n7,n9,JK,s7,s9,XK,i9,l9,u9,h9,f9,m9,x9,v9,b9,S9,I9,N9,E9,A9,D9,O9,P9,M9,B9,U9,W9,V9,j9,K9,oX,Y9,o7,sY,i7,oY,l7,hY,dY,pY,c7,d7,gY,yY,wY,CY,p7,g7,YK,kY,a9,$Y,TY,RY,iX,y7,w7,_Y,C7,OY,LY,zY,WY,GY,HY,qY,k7,XY,QY,ZY,tQ,rQ,oQ,aQ,$7,uQ,dQ,mQ,T7,R7,yQ,bQ,kQ,_7,$Q,TQ,EQ,aF,DQ,lX,F7,FQ,LQ,zQ,UQ,QK,FC,VQ,uX,cX,hX,jQ,qQ,XQ,QQ,ZQ,eJ,nJ,V7,sJ,uJ,hJ,mJ,j7,xJ,vJ,bJ,H7,fQ,kJ,$J,TJ,RJ,_J,OJ,PJ,MJ,X7,zJ,Q7,Z7,UJ,VJ,jJ,qJ,XJ,rX,H9,QJ,ZJ,tZ,rZ,oZ,aZ,D7,mZ,xZ,vZ,NQ];for(const n of wZ)HE(n);const _c={},ly={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function bZ(n,e){_c[n]=e}function Ni(n,e){if(!(n in _c)||e!=null){const r=SZ(n,e);if(r!==null)_c[n]=r;else return console.log("Could not get context for WebGL version",n),null}const t=_c[n];return t==null||t.isContextLost()?(delete _c[n],Ni(n)):(t.disable(t.DEPTH_TEST),t.disable(t.STENCIL_TEST),t.disable(t.BLEND),t.disable(t.DITHER),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SAMPLE_COVERAGE),t.enable(t.SCISSOR_TEST),t.enable(t.CULL_FACE),t.cullFace(t.BACK),_c[n])}function CZ(n){if(!ye().getBool("IS_SAFARI")&&typeof OffscreenCanvas<"u"&&n===2)return new OffscreenCanvas(300,150);if(typeof document<"u")return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}function SZ(n,e){if(n!==1&&n!==2)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const t=e??CZ(n);return t.addEventListener("webglcontextlost",r=>{r.preventDefault(),delete _c[n]},!1),ye().getBool("SOFTWARE_WEBGL_ENABLED")&&(ly.failIfMajorPerformanceCaveat=!1),n===1?t.getContext("webgl",ly)||t.getContext("experimental-webgl",ly):t.getContext("webgl2",ly)}var jm;(function(n){n[n.DENSE=0]="DENSE",n[n.SHARED_BATCH=1]="SHARED_BATCH"})(jm||(jm={}));var xo;(function(n){n[n.RENDER=0]="RENDER",n[n.UPLOAD=1]="UPLOAD",n[n.PIXELS=2]="PIXELS",n[n.DOWNLOAD=3]="DOWNLOAD"})(xo||(xo={}));var Rr;(function(n){n[n.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",n[n.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",n[n.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",n[n.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",n[n.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"})(Rr||(Rr={}));function gx(n,e){return[e,n]}function kZ(n,e){return n*e}function uy(n){const e=Se(n),t=Math.ceil(e/4);return rC(t)}function Rf(n,e){return[Math.max(1,Math.ceil(e/2)),Math.max(1,Math.ceil(n/2))]}function IZ(n,e){const[t,r]=Rf(n,e);return t*r*4}function UI(n,e){const t=n;let r,s,o,i,a,l,c,d,p,m;return ye().getNumber("WEBGL_VERSION")===2?(r=t.R32F,s=t.R16F,o=t.RGBA16F,i=t.RGBA32F,a=t.RED,c=4,d=1,p=t.HALF_FLOAT,m=t.FLOAT,l=t.RGBA8):(r=n.RGBA,s=n.RGBA,o=n.RGBA,i=t.RGBA,a=n.RGBA,c=4,d=4,p=e!=null?e.HALF_FLOAT_OES:null,m=n.FLOAT,l=n.RGBA),{internalFormatFloat:r,internalFormatHalfFloat:s,internalFormatPackedHalfFloat:o,internalFormatPackedFloat:i,textureFormatFloat:a,downloadTextureFormat:l,downloadUnpackNumChannels:c,defaultNumChannels:d,textureTypeHalfFloat:p,textureTypeFloat:m}}function Ve(n,e){const t=e();return ye().getBool("DEBUG")&&$Z(n),t}function $Z(n){const e=n.getError();if(e!==n.NO_ERROR)throw new Error("WebGL Error: "+RZ(n,e))}const NZ=596e-10,TZ=65504;function EZ(n){return!!(ye().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||n===0||NZ<Math.abs(n)&&Math.abs(n)<TZ)}function RZ(n,e){switch(e){case n.NO_ERROR:return"NO_ERROR";case n.INVALID_ENUM:return"INVALID_ENUM";case n.INVALID_VALUE:return"INVALID_VALUE";case n.INVALID_OPERATION:return"INVALID_OPERATION";case n.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case n.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case n.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return`Unknown error code ${e}`}}function cy(n,e){return cl(n,()=>n.getExtension(e),'Extension "'+e+'" not supported on this browser.')}function AZ(n,e){const t=cl(n,()=>n.createShader(n.VERTEX_SHADER),"Unable to create vertex WebGLShader.");if(Ve(n,()=>n.shaderSource(t,e)),Ve(n,()=>n.compileShader(t)),n.getShaderParameter(t,n.COMPILE_STATUS)===!1)throw console.log(n.getShaderInfoLog(t)),new Error("Failed to compile vertex shader.");return t}function _Z(n,e){const t=cl(n,()=>n.createShader(n.FRAGMENT_SHADER),"Unable to create fragment WebGLShader.");if(Ve(n,()=>n.shaderSource(t,e)),Ve(n,()=>n.compileShader(t)),ye().get("ENGINE_COMPILE_ONLY"))return t;if(n.getShaderParameter(t,n.COMPILE_STATUS)===!1)throw lF(e,n.getShaderInfoLog(t)),new Error("Failed to compile fragment shader.");return t}const DZ=/ERROR: [0-9]+:([0-9]+):/g;function lF(n,e){const t=DZ.exec(e);if(t==null){console.log(`Couldn't parse line number in error: ${e}`),console.log(n);return}const r=+t[1],s=n.split(`
`),o=s.length.toString().length+2,i=s.map((p,m)=>Zd((m+1).toString(),o)+p);let a=0;for(let p=0;p<i.length;p++)a=Math.max(i[p].length,a);const l=i.slice(0,r-1),c=i.slice(r-1,r),d=i.slice(r);console.log(l.join(`
`)),console.log(e.split(`
`)[0]),console.log(`%c ${Zd(c[0],a)}`,"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(d.join(`
`))}function OZ(n){return cl(n,()=>n.createProgram(),"Unable to create WebGLProgram.")}function FZ(n,e){if(Ve(n,()=>n.linkProgram(e)),!ye().get("ENGINE_COMPILE_ONLY")&&n.getProgramParameter(e,n.LINK_STATUS)===!1)throw console.log(n.getProgramInfoLog(e)),new Error("Failed to link vertex and fragment shaders.")}function Fb(n,e){if(Ve(n,()=>n.validateProgram(e)),n.getProgramParameter(e,n.VALIDATE_STATUS)===!1)throw console.log(n.getProgramInfoLog(e)),new Error("Shader program validation failed.")}function PZ(n,e){const t=cl(n,()=>n.createBuffer(),"Unable to create WebGLBuffer");return Ve(n,()=>n.bindBuffer(n.ARRAY_BUFFER,t)),Ve(n,()=>n.bufferData(n.ARRAY_BUFFER,e,n.STATIC_DRAW)),t}function LZ(n,e){const t=cl(n,()=>n.createBuffer(),"Unable to create WebGLBuffer");return Ve(n,()=>n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t)),Ve(n,()=>n.bufferData(n.ELEMENT_ARRAY_BUFFER,e,n.STATIC_DRAW)),t}function MZ(n){return cl(n,()=>n.createTexture(),"Unable to create WebGLTexture.")}function zZ(n,e){const t=ye().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(n<=0||e<=0){const r=`[${n}x${e}]`;throw new Error("Requested texture size "+r+" is invalid.")}if(n>t||e>t){const r=`[${n}x${e}]`,s=`[${t}x${t}]`;throw new Error("Requested texture size "+r+" greater than WebGL maximum on this browser / GPU "+s+".")}}function BZ(n){return cl(n,()=>n.createFramebuffer(),"Unable to create WebGLFramebuffer.")}function z2(n,e,t,r,s,o,i){const a=n.getAttribLocation(e,t);return a===-1?!1:(Ve(n,()=>n.bindBuffer(n.ARRAY_BUFFER,r)),Ve(n,()=>n.vertexAttribPointer(a,s,n.FLOAT,!1,o,i)),Ve(n,()=>n.enableVertexAttribArray(a)),!0)}function UZ(n,e,t){HZ(n,t),Ve(n,()=>n.activeTexture(n.TEXTURE0+t)),Ve(n,()=>n.bindTexture(n.TEXTURE_2D,e))}function WZ(n,e,t){return cl(n,()=>n.getUniformLocation(e,t),'uniform "'+t+'" not present in program.')}function VZ(n,e,t){return n.getUniformLocation(e,t)}function GZ(n,e,t,r){Ve(n,()=>UZ(n,e,r)),Ve(n,()=>n.uniform1i(t,r))}function Pb(n,e,t){Ve(n,()=>n.bindFramebuffer(n.FRAMEBUFFER,t)),Ve(n,()=>n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0))}function B2(n,e){Ve(n,()=>n.bindFramebuffer(n.FRAMEBUFFER,e)),Ve(n,()=>n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,null,0))}function hy(n){const e=n.checkFramebufferStatus(n.FRAMEBUFFER);if(e!==n.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+jZ(n,e))}function jZ(n,e){switch(e){case n.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case n.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case n.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case n.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return`unknown error ${e}`}}function cl(n,e,t){const r=Ve(n,()=>e());if(r==null)throw new Error(t);return r}function HZ(n,e){const t=n.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=e+n.TEXTURE0;if(r<n.TEXTURE0||r>t){const s=`[gl.TEXTURE0, gl.TEXTURE${t}]`;throw new Error(`textureUnit must be in ${s}.`)}}function mf(n,e=2){return Se(n.slice(0,n.length-e))}function gf(n){if(n.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[n.length>1?n[n.length-2]:1,n[n.length-1]]}function dy(n){let e=[1,1,1];return n.length===0||n.length===1&&n[0]===1||(e=[mf(n),...gf(n)]),e}function qZ(n,e=!1){let t=ye().getNumber("WEBGL_MAX_TEXTURE_SIZE"),r=ye().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");r===1/0&&ye().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE")&&(r=t/2),e&&(t=t*2,r=r*2,n=n.map((a,l)=>l>=n.length-2?dS(n[l]):n[l]),n.length===1&&(n=[2,n[0]])),n.length!==2&&(n=pu(n).newShape);let s=Se(n),o=null;n.length<=1&&s<=t?o=[1,s]:n.length===2&&n[0]<=t&&n[1]<=t?o=n:n.length===3&&n[0]*n[1]<=t&&n[2]<=t?o=[n[0]*n[1],n[2]]:n.length===3&&n[0]<=t&&n[1]*n[2]<=t?o=[n[0],n[1]*n[2]]:n.length===4&&n[0]*n[1]*n[2]<=t&&n[3]<=t?o=[n[0]*n[1]*n[2],n[3]]:n.length===4&&n[0]<=t&&n[1]*n[2]*n[3]<=t&&(o=[n[0],n[1]*n[2]*n[3]]);const i=o!=null&&Math.max(...o)>r&&Math.min(...o)<=(e?2:1)&&Math.min(...o)>0;if(o==null||i)if(e){const a=mf(n);let l=2,c=2;n.length&&([l,c]=gf(n)),s=a*(l/2)*(c/2),o=rC(s).map(d=>d*2)}else o=rC(s);return o}function fy(n){return n%2===0}function l1(n,e){if(n=n.slice(-2),e=e.slice(-2),Xt(n,e)||!n.length||!e.length||n[0]===0||n[1]===0||e[0]===0||e[1]===0)return!0;if(n.length!==e.length){const t=n[n.length-1],r=e[e.length-1];if(t===r||fy(t)&&fy(r)&&(n[0]===1||e[0]===1))return!0}return n[1]===e[1]&&fy(n[0])&&fy(e[0])}let Lb,Mb;function KZ(n){if(Lb==null){const e=Ni(n);Lb=e.getParameter(e.MAX_TEXTURE_SIZE)}return Lb}function XZ(n){if(Mb==null){const e=Ni(n);Mb=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,Mb)}function YZ(n){if(n===0)return 0;let e;const t=Ni(n);return Ho(t,"EXT_disjoint_timer_query_webgl2")&&n===2?e=2:Ho(t,"EXT_disjoint_timer_query")?e=1:e=0,e}function Ho(n,e){return n.getExtension(e)!=null}function U2(n){try{if(Ni(n)!=null)return!0}catch(e){return console.log("Error when getting WebGL context: ",e),!1}return!1}function QZ(n){if(n===0)return!1;const e=Ni(n);if(n===1){if(!Ho(e,"OES_texture_float"))return!1}else if(!Ho(e,"EXT_color_buffer_float"))return!1;return LC(e)}function JZ(n){if(n===0)return!1;const e=Ni(n);if(n===1){if(!Ho(e,"OES_texture_float")||!Ho(e,"WEBGL_color_buffer_float"))return!1}else{if(Ho(e,"EXT_color_buffer_float"))return LC(e);const r="EXT_color_buffer_half_float";if(Ho(e,r)){const s=e.getExtension(r);return ZZ(e,s)}return!1}return LC(e)}function LC(n){const e=UI(n),t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t),n.texImage2D(n.TEXTURE_2D,0,e.internalFormatFloat,1,1,0,e.textureFormatFloat,e.textureTypeFloat,null);const o=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,o),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0);const i=n.checkFramebufferStatus(n.FRAMEBUFFER)===n.FRAMEBUFFER_COMPLETE;return n.bindTexture(n.TEXTURE_2D,null),n.bindFramebuffer(n.FRAMEBUFFER,null),n.deleteTexture(t),n.deleteFramebuffer(o),i}function ZZ(n,e){const t=UI(n,e),r=n.createTexture();n.bindTexture(n.TEXTURE_2D,r),n.texImage2D(n.TEXTURE_2D,0,t.internalFormatHalfFloat,1,1,0,t.textureFormatFloat,t.textureTypeHalfFloat,null);const i=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,i),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,r,0);const a=n.checkFramebufferStatus(n.FRAMEBUFFER)===n.FRAMEBUFFER_COMPLETE;return n.bindTexture(n.TEXTURE_2D,null),n.bindFramebuffer(n.FRAMEBUFFER,null),n.deleteTexture(r),n.deleteFramebuffer(i),a}function eee(n){return n!==2?!1:Ni(n).fenceSync!=null}function xx(n,e){Array.isArray(n)||(n=[n]),n.forEach(t=>{t!=null&&U(t.dtype!=="complex64",()=>`${e} does not support complex64 tensors in the WebGL backend.`)})}const Qe=ye();Qe.registerFlag("HAS_WEBGL",()=>Qe.getNumber("WEBGL_VERSION")>0);Qe.registerFlag("WEBGL_VERSION",()=>U2(2)?2:U2(1)?1:0);Qe.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",()=>!1);Qe.registerFlag("WEBGL_BUFFER_SUPPORTED",()=>Qe.get("WEBGL_VERSION")===2);Qe.registerFlag("WEBGL_CPU_FORWARD",()=>!0);Qe.registerFlag("WEBGL_FORCE_F16_TEXTURES",()=>!1);Qe.registerFlag("WEBGL_PACK",()=>Qe.getBool("HAS_WEBGL"));Qe.registerFlag("WEBGL_PACK_NORMALIZATION",()=>Qe.getBool("WEBGL_PACK"));Qe.registerFlag("WEBGL_PACK_CLIP",()=>Qe.getBool("WEBGL_PACK"));Qe.registerFlag("WEBGL_PACK_DEPTHWISECONV",()=>Qe.getBool("WEBGL_PACK"));Qe.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",()=>Qe.getBool("WEBGL_PACK"));Qe.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",()=>Qe.getBool("WEBGL_PACK"));Qe.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",()=>Qe.getBool("WEBGL_PACK"));Qe.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",()=>Qe.getBool("WEBGL_PACK"));Qe.registerFlag("WEBGL_PACK_REDUCE",()=>Qe.getBool("WEBGL_PACK"));Qe.registerFlag("WEBGL_LAZILY_UNPACK",()=>Qe.getBool("WEBGL_PACK"));Qe.registerFlag("WEBGL_CONV_IM2COL",()=>Qe.getBool("WEBGL_PACK"));Qe.registerFlag("WEBGL_PACK_CONV2DTRANSPOSE",()=>Qe.getBool("WEBGL_PACK"));Qe.registerFlag("WEBGL_MAX_TEXTURE_SIZE",()=>KZ(Qe.getNumber("WEBGL_VERSION")));Qe.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",()=>XZ(Qe.getNumber("WEBGL_VERSION")));Qe.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",()=>{const n=Qe.getNumber("WEBGL_VERSION");return n===0?0:YZ(n)});Qe.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",()=>Qe.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!oR());Qe.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",()=>QZ(Qe.getNumber("WEBGL_VERSION")));Qe.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",()=>Qe.getBool("WEBGL_FORCE_F16_TEXTURES")?!1:Qe.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"));Qe.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",()=>JZ(Qe.getNumber("WEBGL_VERSION")));Qe.registerFlag("WEBGL_FENCE_API_ENABLED",()=>eee(Qe.getNumber("WEBGL_VERSION")));Qe.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",()=>Qe.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0);Qe.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",()=>-1,n=>{if(typeof n!="number")throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be a number but got ${n}.`);if(n<0&&n!==-1)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${n}.`)});Qe.registerFlag("WEBGL_FLUSH_THRESHOLD",()=>oR()?1:-1,n=>{if(typeof n!="number")throw new Error(`WEBGL_FLUSH_THRESHOLD must be a number but got ${n}.`);if(n<0&&n!==-1)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${n}.`)});Qe.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",()=>128);Qe.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",()=>!1);Qe.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",()=>1e5);Qe.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",()=>128);Qe.registerFlag("WEBGL_EXP_CONV",()=>!1);Qe.registerFlag("SOFTWARE_WEBGL_ENABLED",()=>Qe.getBool("IS_TEST"));Qe.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE",()=>1/0);Qe.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE",()=>!1);Qe.registerFlag("WEBGL2_ISNAN_CUSTOM",()=>!1);Qe.registerFlag("ENGINE_COMPILE_ONLY",()=>!1);function hs(){let n,e,t,r,s,o,i,a,l,c;return ye().getNumber("WEBGL_VERSION")===2?(n="#version 300 es",e="in",t="out",r="in",s="texture",o="outputColor",i="out vec4 outputColor;",a=ye().getBool("WEBGL2_ISNAN_CUSTOM")?`
bool isnan_custom(float val) {
uint floatToUint = floatBitsToUint(val);
return (floatToUint & 0x7fffffffu) > 0x7f800000u;
}
bvec4 isnan_custom(vec4 val) {
return bvec4(isnan_custom(val.x),
isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));
}
#define isnan(value) isnan_custom(value)
`:"",l="",c=`
#define round(value) newRound(value)
int newRound(float value) {
return int(floor(value + 0.5));
}
ivec4 newRound(vec4 value) {
return ivec4(floor(value + vec4(0.5)));
}
`):(n="",e="attribute",t="varying",r="varying",s="texture2D",o="gl_FragColor",i="",a=`
#define isnan(value) isnan_custom(value)
bool isnan_custom(float val) {
return (val > 0. || val < 1. || val == 0.) ? false : true;
}
bvec4 isnan_custom(vec4 val) {
return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));
}
`,l=`
uniform float INFINITY;
bool isinf(float val) {
return abs(val) == INFINITY;
}
bvec4 isinf(vec4 val) {
return equal(abs(val), vec4(INFINITY));
}
`,c=`
int round(float value) {
return int(floor(value + 0.5));
}
ivec4 round(vec4 value) {
return ivec4(floor(value + vec4(0.5)));
}
`),{version:n,attribute:e,varyingVs:t,varyingFs:r,texture2D:s,output:o,defineOutput:i,defineSpecialNaN:a,defineSpecialInf:l,defineRound:c}}function fh(n,e,t="index"){const r=tt(e);return r.map((s,o)=>{const i=`int ${n[o]} = ${t} / ${s}`,a=o===r.length-1?`int ${n[o+1]} = ${t} - ${n[o]} * ${s}`:`index -= ${n[o]} * ${s}`;return`${i}; ${a};`}).join("")}function Wv(n,e,t="index"){const r=tt(e);return r.map((s,o)=>{const i=`int ${n[o]} = ${t} / outShapeStrides[${o}]`,a=o===r.length-1?`int ${n[o+1]} = ${t} - ${n[o]} * outShapeStrides[${o}]`:`index -= ${n[o]} * outShapeStrides[${o}]`;return`${i}; ${a};`}).join("")}function tee(n,e){const t=n.length,r=n.map(o=>`${e}[${o}]`),s=new Array(t-1);s[t-2]=r[t-1];for(let o=t-3;o>=0;--o)s[o]=`(${s[o+1]} * ${r[o+1]})`;return s}function nee(n,e,t="index"){const r=n.map((o,i)=>i),s=tee(r,e);return s.map((o,i)=>{const a=`int ${n[i]} = ${t} / ${s[i]}`,l=i===s.length-1?`int ${n[i+1]} = ${t} - ${n[i]} * ${s[i]}`:`index -= ${n[i]} * ${s[i]}`;return`${a}; ${l};`}).join("")}function WI(n){const e=tt(n).map(t=>t.toString());return`
int getFlatIndex(ivec3 coords) {
return coords.x * ${e[0]} + coords.y * ${e[1]} + coords.z;
}
`}function VI(){return`
int getFlatIndex(ivec3 coords) {
return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;
}
`}const uF=`
const float FLOAT_MAX = 1.70141184e38;
const float FLOAT_MIN = 1.17549435e-38;
lowp vec4 encode_float(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;
}
`;const{getBroadcastDims:cF}=V5;function ree(n,e,t){const r=[];if(n.forEach(y=>{const v=Se(y.shapeInfo.logicalShape);if(y.shapeInfo.isUniform?r.push(`uniform float ${y.name}${v>1?`[${v}]`:""};`):(r.push(`uniform sampler2D ${y.name};`),r.push(`uniform int offset${y.name};`)),t.enableShapeUniforms){const{uniformShape:b}=GI(t.packedInputs,y.shapeInfo.logicalShape,y.shapeInfo.texShape);switch(b.length){case 1:r.push(`uniform int ${y.name}Shape;`);break;case 2:r.push(`uniform ivec2 ${y.name}Shape;`);break;case 3:r.push(`uniform ivec3 ${y.name}Shape;`);break;case 4:r.push(`uniform ivec4 ${y.name}Shape;`);break}r.push(`uniform ivec2 ${y.name}TexShape;`)}}),t.enableShapeUniforms){switch(e.logicalShape.length){case 1:r.push("uniform int outShape;");break;case 2:r.push("uniform ivec2 outShape;"),r.push("uniform int outShapeStrides;");break;case 3:r.push("uniform ivec3 outShape;"),r.push("uniform ivec2 outShapeStrides;");break;case 4:r.push("uniform ivec4 outShape;"),r.push("uniform ivec3 outShapeStrides;");break}r.push("uniform ivec2 outTexShape;")}t.customUniforms&&t.customUniforms.forEach(y=>{r.push(`uniform ${y.type} ${y.name}${y.arrayIndex?`[${y.arrayIndex}]`:""};`)});const s=r.join(`
`),o=n.map(y=>see(y,e,t.packedInputs,t.enableShapeUniforms)).join(`
`),i=e.texShape,a=hs(),l=aee(a);let c,d,p=cee(a);return e.isPacked?(c=oee(e.logicalShape,i,t.enableShapeUniforms),d=uee(a)):(c=iee(e.logicalShape,i,t.enableShapeUniforms),d=lee(a)),t.packedInputs&&(p+=pee),[p,l,d,s,c,o,t.userCode].join(`
`)}function Af(n,e=!1){const t=n.shapeInfo.logicalShape;switch(t.length){case 0:return $ee(n,e);case 1:return Tee(n,e);case 2:return Ree(n,e);case 3:return _ee(n,e);case 4:return Oee(n,e);case 5:return Fee(n);case 6:return Pee(n);default:throw new Error(`${t.length}-D input sampling is not yet supported`)}}function hF(n,e){switch(n.shapeInfo.logicalShape.length){case 0:return Iee(n);case 1:return Nee(n,e);case 2:return Eee(n,e);case 3:return Aee(n,e);default:return Dee(n,e)}}function see(n,e,t=!1,r){let s="";t?s+=hF(n,r):s+=Af(n,r);const o=n.shapeInfo.logicalShape,i=e.logicalShape;return o.length<=i.length&&(t?s+=Lee(n,e):s+=Mee(n,e)),s}function oee(n,e,t){switch(n.length){case 0:return dF();case 1:return mee(n,e,t);case 2:return See(n,e,t);case 3:return xee(n,e,t);default:return vee(n,e,t)}}function iee(n,e,t){switch(n.length){case 0:return dF();case 1:return gee(n,e,t);case 2:return kee(n,e,t);case 3:return yee(n,e,t);case 4:return wee(n,e,t);case 5:return bee(n,e);case 6:return Cee(n,e);default:throw new Error(`${n.length}-D output sampling is not yet supported`)}}function aee(n){return`
float sampleTexture(sampler2D textureSampler, vec2 uv) {
return ${n.texture2D}(textureSampler, uv).r;
}
`}function lee(n){return`
void setOutput(float val) {
${n.output} = vec4(val, 0, 0, 0);
}
`}function uee(n){return`
void setOutput(vec4 val) {
${n.output} = val;
}
`}function cee(n){return`${n.version}
precision highp float;
precision highp int;
precision highp sampler2D;
${n.varyingFs} vec2 resultUV;
${n.defineOutput}
const vec2 halfCR = vec2(0.5, 0.5);
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;
};
uniform float NAN;
${n.defineSpecialNaN}
${n.defineSpecialInf}
${n.defineRound}
int imod(int x, int y) {
return x - y * (x / y);
}
int idiv(int a, int b, float sign) {
int res = a / b;
int mod = imod(a, b);
if (sign < 0. && mod != 0) {
res -= 1;
}
return res;
}
//Based on the work of Dave Hoskins
//https://www.shadertoy.com/view/4djSRW
#define HASHSCALE1 443.8975
float random(float seed){
vec2 p = resultUV * seed;
vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1);
p3 += dot(p3, p3.yzx + 19.19);
return fract((p3.x + p3.y) * p3.z);
}
${hee}
${dee}
${fee}
`}const hee=`
vec2 uvFromFlat(int texNumR, int texNumC, int index) {
int texR = index / texNumC;
int texC = index - texR * texNumC;
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
}
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);
}
`,dee=`
vec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,
int texNumC, 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);
}
`,fee=`
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);
}
`,pee=`
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);
}
float getChannel(vec4 frag, int dim) {
float modCoord = mod(float(dim), 2.);
return modCoord == 0. ? frag.r : frag.g;
}
`;function dF(){return`
int getOutputCoords() {
return 0;
}
`}function mee(n,e,t){const r=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];return r[0]===1?t?`
int getOutputCoords() {
return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));
}
`:`
int getOutputCoords() {
return 2 * int(resultUV.x * ${r[1]}.0);
}
`:r[1]===1?t?`
int getOutputCoords() {
return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0));
}
`:`
int getOutputCoords() {
return 2 * int(resultUV.y * ${r[0]}.0);
}
`:t?`
int getOutputCoords() {
ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(packedTexShape[0], packedTexShape[1]));
return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y);
}
`:`
int getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${r[0]}, ${r[1]}));
return 2 * (resTexRC.x * ${r[1]} + resTexRC.y);
}
`}function gee(n,e,t){return e[0]===1?t?`
int getOutputCoords() {
return int(resultUV.x * float(outTexShape[1]));
}
`:`
int getOutputCoords() {
return int(resultUV.x * ${e[1]}.0);
}
`:e[1]===1?t?`
int getOutputCoords() {
return int(resultUV.y * float(outTexShape[0]));
}
`:`
int getOutputCoords() {
return int(resultUV.y * ${e[0]}.0);
}
`:t?`
int getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(outTexShape[0], outTexShape[1]));
return resTexRC.x * outTexShape[1] + resTexRC.y;
}
`:`
int getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${e[0]}, ${e[1]}));
return resTexRC.x * ${e[1]} + resTexRC.y;
}
`}function xee(n,e,t){if(t)return`
ivec3 getOutputCoords() {
ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0));
int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0));
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(packedTexShape[0], packedTexShape[1]));
int index = resTexRC.x * packedTexShape[1] + resTexRC.y;
int b = index / texelsInBatch;
index -= b * texelsInBatch;
int r = 2 * (index / texelsInLogicalRow);
int c = imod(index, texelsInLogicalRow) * 2;
return ivec3(b, r, c);
}
`;const r=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)],s=Math.ceil(n[2]/2),o=s*Math.ceil(n[1]/2);return`
ivec3 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${r[0]}, ${r[1]}));
int index = resTexRC.x * ${r[1]} + resTexRC.y;
int b = index / ${o};
index -= b * ${o};
int r = 2 * (index / ${s});
int c = imod(index, ${s}) * 2;
return ivec3(b, r, c);
}
`}function yee(n,e,t){if(t)return`
ivec3 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(outTexShape[0], outTexShape[1]));
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
${Wv(["r","c","d"],n)}
return ivec3(r, c, d);
}
`;const r=fh(["r","c","d"],n);return`
ivec3 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${e[0]}, ${e[1]}));
int index = resTexRC.x * ${e[1]} + resTexRC.y;
${r}
return ivec3(r, c, d);
}
`}function vee(n,e,t){if(t)return`
ivec4 getOutputCoords() {
ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(packedTexShape[0], packedTexShape[1]));
int index = resTexRC.x * packedTexShape[1] + resTexRC.y;
int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0));
int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0));
int texelsInBatchN = texelsInBatch * outShape[1];
int b2 = index / texelsInBatchN;
index -= b2 * texelsInBatchN;
int b = index / texelsInBatch;
index -= b * texelsInBatch;
int r = 2 * (index / texelsInLogicalRow);
int c = imod(index, texelsInLogicalRow) * 2;
return ivec4(b2, b, r, c);
}
`;const r=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)],s=Math.ceil(n[n.length-1]/2),o=s*Math.ceil(n[n.length-2]/2);let i=o,a="",l="b, r, c";for(let c=2;c<n.length-1;c++)i*=n[n.length-c-1],a=`
int b${c} = index / ${i};
index -= b${c} * ${i};
`+a,l=`b${c}, `+l;return`
ivec${n.length} getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${r[0]}, ${r[1]}));
int index = resTexRC.x * ${r[1]} + resTexRC.y;
${a}
int b = index / ${o};
index -= b * ${o};
int r = 2 * (index / ${s});
int c = imod(index, ${s}) * 2;
return ivec${n.length}(${l});
}
`}function wee(n,e,t){if(t)return`
ivec4 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(outTexShape[0], outTexShape[1]));
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
${Wv(["r","c","d","d2"],n)}
return ivec4(r, c, d, d2);
}
`;const r=fh(["r","c","d","d2"],n);return`
ivec4 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${e[0]}, ${e[1]}));
int index = resTexRC.x * ${e[1]} + resTexRC.y;
${r}
return ivec4(r, c, d, d2);
}
`}function bee(n,e){const t=fh(["r","c","d","d2","d3"],n);return`
ivec5 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx * vec2(${e[0]},
${e[1]}));
int index = resTexRC.x * ${e[1]} + resTexRC.y;
${t}
ivec5 outShape = ivec5(r, c, d, d2, d3);
return outShape;
}
`}function Cee(n,e){const t=fh(["r","c","d","d2","d3","d4"],n);return`
ivec6 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${e[0]}, ${e[1]}));
int index = resTexRC.x * ${e[1]} + resTexRC.y;
${t}
ivec6 result = ivec6(r, c, d, d2, d3, d4);
return result;
}
`}function See(n,e,t){const r=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(Xt(n,e))return t?`
ivec2 getOutputCoords() {
ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));
}
`:`
ivec2 getOutputCoords() {
return 2 * ivec2(resultUV.yx * vec2(${r[0]}, ${r[1]}));
}
`;const s=Math.ceil(n[1]/2);return t?`
ivec2 getOutputCoords() {
ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0));
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(packedTexShape[0], packedTexShape[1]));
int index = resTexRC.x * packedTexShape[1] + resTexRC.y;
int r = 2 * (index / texelsInLogicalRow);
int c = imod(index, texelsInLogicalRow) * 2;
return ivec2(r, c);
}
`:`
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${r[0]}, ${r[1]}));
int index = resTexRC.x * ${r[1]} + resTexRC.y;
int r = 2 * (index / ${s});
int c = imod(index, ${s}) * 2;
return ivec2(r, c);
}
`}function kee(n,e,t){return Xt(n,e)?t?`
ivec2 getOutputCoords() {
return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1]));
}
`:`
ivec2 getOutputCoords() {
return ivec2(resultUV.yx * vec2(${e[0]}, ${e[1]}));
}
`:n[1]===1?t?`
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(outTexShape[0], outTexShape[1]));
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
return ivec2(index, 0);
}
`:`
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${e[0]}, ${e[1]}));
int index = resTexRC.x * ${e[1]} + resTexRC.y;
return ivec2(index, 0);
}
`:n[0]===1?t?`
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(outTexShape[0], outTexShape[1]));
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
return ivec2(0, index);
}
`:`
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${e[0]}, ${e[1]}));
int index = resTexRC.x * ${e[1]} + resTexRC.y;
return ivec2(0, index);
}
`:t?`
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(outTexShape[0], outTexShape[1]));
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
int r = index / outShape[1];
int c = index - r * outShape[1];
return ivec2(r, c);
}
`:`
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${e[0]}, ${e[1]}));
int index = resTexRC.x * ${e[1]} + resTexRC.y;
int r = index / ${n[1]};
int c = index - r * ${n[1]};
return ivec2(r, c);
}
`}function ph(n){return`offset${n}`}function Iee(n){const e=n.name,t="get"+e.charAt(0).toUpperCase()+e.slice(1),r=hs();return`
vec4 ${t}() {
return ${r.texture2D}(${e}, halfCR);
}
`}function $ee(n,e){const t=n.name,r="get"+t.charAt(0).toUpperCase()+t.slice(1);if(n.shapeInfo.isUniform)return`float ${r}() {return ${t};}`;const[s,o]=n.shapeInfo.texShape;if(s===1&&o===1)return`
float ${r}() {
return sampleTexture(${t}, halfCR);
}
`;const i=ph(t);if(e)return`
float ${r}() {
vec2 uv = uvFromFlat(${t}TexShape[0], ${t}TexShape[1], ${i});
return sampleTexture(${t}, uv);
}
`;const[a,l]=n.shapeInfo.texShape;return`
float ${r}() {
vec2 uv = uvFromFlat(${a}, ${l}, ${i});
return sampleTexture(${t}, uv);
}
`}function Nee(n,e){const t=n.name,r="get"+t.charAt(0).toUpperCase()+t.slice(1),s=n.shapeInfo.texShape,o=hs();if(e)return`
vec4 ${r}(int index) {
ivec2 packedTexShape = ivec2(ceil(float(${t}TexShape[0]) / 2.0), ceil(float(${t}TexShape[1]) / 2.0));
vec2 uv = packedUVfrom1D(
packedTexShape[0], packedTexShape[1], index);
return ${o.texture2D}(${t}, uv);
}
`;const i=[Math.ceil(s[0]/2),Math.ceil(s[1]/2)];return`
vec4 ${r}(int index) {
vec2 uv = packedUVfrom1D(
${i[0]}, ${i[1]}, index);
return ${o.texture2D}(${t}, uv);
}
`}function Tee(n,e){const t=n.name,r="get"+t.charAt(0).toUpperCase()+t.slice(1);if(n.shapeInfo.isUniform)return`
float ${r}(int index) {
${_f(n)}
}
`;const s=n.shapeInfo.texShape,o=s[0],i=s[1];if(i===1&&o===1)return`
float ${r}(int index) {
return sampleTexture(${t}, halfCR);
}
`;const a=ph(t);return i===1?e?`
float ${r}(int index) {
vec2 uv = vec2(0.5, (float(index + ${a}) + 0.5) / float(${t}TexShape[0]));
return sampleTexture(${t}, uv);
}
`:`
float ${r}(int index) {
vec2 uv = vec2(0.5, (float(index + ${a}) + 0.5) / ${o}.0);
return sampleTexture(${t}, uv);
}
`:o===1?e?`
float ${r}(int index) {
vec2 uv = vec2((float(index + ${a}) + 0.5) / float(${t}TexShape[1]), 0.5);
return sampleTexture(${t}, uv);
}
`:`
float ${r}(int index) {
vec2 uv = vec2((float(index + ${a}) + 0.5) / ${i}.0, 0.5);
return sampleTexture(${t}, uv);
}
`:e?`
float ${r}(int index) {
vec2 uv = uvFromFlat(${t}TexShape[0], ${t}TexShape[1], index + ${a});
return sampleTexture(${t}, uv);
}
`:`
float ${r}(int index) {
vec2 uv = uvFromFlat(${o}, ${i}, index + ${a});
return sampleTexture(${t}, uv);
}
`}function Eee(n,e){const t=n.shapeInfo.logicalShape,r=n.name,s="get"+r.charAt(0).toUpperCase()+r.slice(1),o=n.shapeInfo.texShape,i=o[0],a=o[1],l=hs();if(o!=null&&Xt(t,o))return e?`
vec4 ${s}(int row, int col) {
vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);
return ${l.texture2D}(${r}, uv);
}
`:`
vec4 ${s}(int row, int col) {
vec2 uv = (vec2(col, row) + halfCR) / vec2(${a}.0, ${i}.0);
return ${l.texture2D}(${r}, uv);
}
`;if(e)return`
vec4 ${s}(int row, int col) {
ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0));
int valuesPerRow = int(ceil(float(${r}Shape[1]) / 2.0));
vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, col);
return ${l.texture2D}(${r}, uv);
}
`;const c=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)],d=Math.ceil(t[1]/2);return`
vec4 ${s}(int row, int col) {
vec2 uv = packedUVfrom2D(${d}, ${c[0]}, ${c[1]}, row, col);
return ${l.texture2D}(${r}, uv);
}
`}function Ree(n,e){const t=n.shapeInfo.logicalShape,r=n.name,s="get"+r.charAt(0).toUpperCase()+r.slice(1),o=n.shapeInfo.texShape;if(o!=null&&Xt(t,o)){if(e)return`
float ${s}(int row, int col) {
vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);
return sampleTexture(${r}, uv);
}
`;const m=o[0],y=o[1];return`
float ${s}(int row, int col) {
vec2 uv = (vec2(col, row) + halfCR) / vec2(${y}.0, ${m}.0);
return sampleTexture(${r}, uv);
}
`}const{newShape:i,keptDims:a}=pu(t),l=i;if(l.length<t.length){const m=Df(n,l),y=["row","col"];return`
${Af(m,e)}
float ${s}(int row, int col) {
return ${s}(${Of(y,a)});
}
`}if(n.shapeInfo.isUniform)return`
float ${s}(int row, int col) {
int index = round(dot(vec2(row, col), vec2(${t[1]}, 1)));
${_f(n)}
}
`;const c=o[0],d=o[1],p=ph(r);return d===1?e?`
float ${s}(int row, int col) {
float index = dot(vec3(row, col, ${p}), vec3(${r}Shape[1], 1, 1));
vec2 uv = vec2(0.5, (index + 0.5) / float(${r}TexShape[0]));
return sampleTexture(${r}, uv);
}
`:`
float ${s}(int row, int col) {
float index = dot(vec3(row, col, ${p}), vec3(${t[1]}, 1, 1));
vec2 uv = vec2(0.5, (index + 0.5) / ${c}.0);
return sampleTexture(${r}, uv);
}
`:c===1?e?`
float ${s}(int row, int col) {
float index = dot(vec3(row, col, ${p}), vec3(${r}Shape[1], 1, 1));
vec2 uv = vec2((index + 0.5) / float(${r}TexShape[1]), 0.5);
return sampleTexture(${r}, uv);
}
`:`
float ${s}(int row, int col) {
float index = dot(vec3(row, col, ${p}), vec3(${t[1]}, 1, 1));
vec2 uv = vec2((index + 0.5) / ${d}.0, 0.5);
return sampleTexture(${r}, uv);
}
`:e?`
float ${s}(int row, int col) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * ${r}Shape[1] + col + ${p};
vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index);
return sampleTexture(${r}, uv);
}
`:`
float ${s}(int row, int col) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * ${t[1]} + col + ${p};
vec2 uv = uvFromFlat(${c}, ${d}, index);
return sampleTexture(${r}, uv);
}
`}function Aee(n,e){const t=n.shapeInfo.logicalShape,r=n.name,s="get"+r.charAt(0).toUpperCase()+r.slice(1),o=n.shapeInfo.texShape,i=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)];if(t[0]===1){const m=t.slice(1),y=[1,2],v=Df(n,m),b=["b","row","col"];return`
${hF(v,e)}
vec4 ${s}(int b, int row, int col) {
return ${s}(${Of(b,y)});
}
`}const a=hs();if(e)return`
vec4 ${s}(int b, int row, int col) {
ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0));
int valuesPerRow = int(ceil(float(${r}Shape[2]) / 2.0));
int texelsInBatch = valuesPerRow * int(ceil(float(${r}Shape[1]) / 2.0));
vec2 uv = packedUVfrom3D(
packedTexShape[0], packedTexShape[1], texelsInBatch, valuesPerRow, b, row, col);
return ${a.texture2D}(${r}, uv);
}
`;const l=i[0],c=i[1],d=Math.ceil(t[2]/2),p=d*Math.ceil(t[1]/2);return`
vec4 ${s}(int b, int row, int col) {
vec2 uv = packedUVfrom3D(
${l}, ${c}, ${p}, ${d}, b, row, col);
return ${a.texture2D}(${r}, uv);
}
`}function _ee(n,e){const t=n.shapeInfo.logicalShape,r=n.name,s="get"+r.charAt(0).toUpperCase()+r.slice(1),o=t[1]*t[2],i=t[2],{newShape:a,keptDims:l}=pu(t),c=a;if(c.length<t.length){const b=Df(n,c),w=["row","col","depth"];return`
${Af(b,e)}
float ${s}(int row, int col, int depth) {
return ${s}(${Of(w,l)});
}
`}if(n.shapeInfo.isUniform)return`
float ${s}(int row, int col, int depth) {
int index = round(dot(vec3(row, col, depth),
vec3(${o}, ${i}, 1)));
${_f(n)}
}
`;const d=n.shapeInfo.texShape,p=d[0],m=d[1],y=n.shapeInfo.flatOffset;if(m===o&&y==null)return e?`
float ${s}(int row, int col, int depth) {
int stride1 = ${r}Shape[2];
float texR = float(row);
float texC = dot(vec2(col, depth), vec2(stride1, 1));
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${r}TexShape[1], ${r}TexShape[0]);
return sampleTexture(${r}, uv);
}
`:`
float ${s}(int row, int col, int depth) {
float texR = float(row);
float texC = dot(vec2(col, depth), vec2(${i}, 1));
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${m}.0, ${p}.0);
return sampleTexture(${r}, uv);
}
`;if(m===i&&y==null)return e?`
float ${s}(int row, int col, int depth) {
float texR = dot(vec2(row, col), vec2(${r}Shape[1], 1));
float texC = float(depth);
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);
return sampleTexture(${r}, uv);
}
`:`
float ${s}(int row, int col, int depth) {
float texR = dot(vec2(row, col), vec2(${t[1]}, 1));
float texC = float(depth);
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${m}.0, ${p}.0);
return sampleTexture(${r}, uv);
}
`;const v=ph(r);return e?`
float ${s}(int row, int col, int depth) {
// Explicitly use integer operations as dot() only works on floats.
int stride0 = ${r}Shape[1] * ${r}Shape[2];
int stride1 = ${r}Shape[2];
int index = row * stride0 + col * stride1 + depth + ${v};
vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index);
return sampleTexture(${r}, uv);
}
`:`
float ${s}(int row, int col, int depth) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * ${o} + col * ${i} + depth + ${v};
vec2 uv = uvFromFlat(${p}, ${m}, index);
return sampleTexture(${r}, uv);
}
`}function Dee(n,e){const t=n.name,r="get"+t.charAt(0).toUpperCase()+t.slice(1),s=hs();if(e)return`
vec4 ${r}(int b2, int b, int row, int col) {
int valuesPerRow = int(ceil(float(${t}Shape[3]) / 2.0));
int texelsInBatch = valuesPerRow * int(ceil(float(${t}Shape[2]) / 2.0));
int index = b * texelsInBatch + (row / 2) * valuesPerRow + (col / 2);
texelsInBatch *= ${t}Shape[1];
index = b2 * texelsInBatch + index;
ivec2 packedTexShape = ivec2(ceil(float(${t}TexShape[0]) / 2.0), ceil(float(${t}TexShape[1]) / 2.0));
int texR = index / packedTexShape[1];
int texC = index - texR * packedTexShape[1];
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(packedTexShape[1], packedTexShape[0]); return ${s.texture2D}(${t}, uv);
}
`;const o=n.shapeInfo.logicalShape,i=o.length,a=n.shapeInfo.texShape,l=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)],c=l[0],d=l[1],p=Math.ceil(o[i-1]/2);let m=p*Math.ceil(o[i-2]/2),y="int b, int row, int col",v=`b * ${m} + (row / 2) * ${p} + (col / 2)`;for(let b=2;b<i-1;b++)y=`int b${b}, `+y,m*=o[i-b-1],v=`b${b} * ${m} + `+v;return`
vec4 ${r}(${y}) {
int index = ${v};
int texR = index / ${d};
int texC = index - texR * ${d};
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${d}, ${c});
return ${s.texture2D}(${t}, uv);
}
`}function Oee(n,e){const t=n.shapeInfo.logicalShape,r=n.name,s="get"+r.charAt(0).toUpperCase()+r.slice(1),o=t[3],i=t[2]*o,a=t[1]*i,{newShape:l,keptDims:c}=pu(t);if(l.length<t.length){const I=Df(n,l),N=["row","col","depth","depth2"];return`
${Af(I,e)}
float ${s}(int row, int col, int depth, int depth2) {
return ${s}(${Of(N,c)});
}
`}if(n.shapeInfo.isUniform)return`
float ${s}(int row, int col, int depth, int depth2) {
int index = round(dot(vec4(row, col, depth, depth2),
vec4(${a}, ${i}, ${o}, 1)));
${_f(n)}
}
`;const d=n.shapeInfo.flatOffset,p=n.shapeInfo.texShape,m=p[0],y=p[1],v=`int stride2 = ${r}Shape[3];`,b=`int stride1 = ${r}Shape[2] * stride2;`,w=`int stride0 = ${r}Shape[1] * stride1;`;if(y===a&&d==null)return e?`
float ${s}(int row, int col, int depth, int depth2) {
${v}
${b}
float texR = float(row);
float texC =
dot(vec3(col, depth, depth2),
vec3(stride1, stride2, 1));
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${r}TexShape[1], ${r}TexShape[0]);
return sampleTexture(${r}, uv);
}
`:`
float ${s}(int row, int col, int depth, int depth2) {
float texR = float(row);
float texC =
dot(vec3(col, depth, depth2),
vec3(${i}, ${o}, 1));
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${y}.0, ${m}.0);
return sampleTexture(${r}, uv);
}
`;if(y===o&&d==null)return e?`
float ${s}(int row, int col, int depth, int depth2) {
float texR = dot(vec3(row, col, depth),
vec3(${r}Shape[1] * ${r}Shape[2], ${r}Shape[2], 1));
float texC = float(depth2);
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${r}TexShape[1], ${r}TexShape[0]);
return sampleTexture(${r}, uv);
}
`:`
float ${s}(int row, int col, int depth, int depth2) {
float texR = dot(vec3(row, col, depth),
vec3(${t[1]*t[2]}, ${t[2]}, 1));
float texC = float(depth2);
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${y}.0, ${m}.0);
return sampleTexture(${r}, uv);
}
`;const k=ph(r);return e?`
float ${s}(int row, int col, int depth, int depth2) {
// Explicitly use integer operations as dot() only works on floats.
${v}
${b}
${w}
int index = row * stride0 + col * stride1 +
depth * stride2 + depth2;
vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index + ${k});
return sampleTexture(${r}, uv);
}
`:`
float ${s}(int row, int col, int depth, int depth2) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * ${a} + col * ${i} +
depth * ${o} + depth2;
vec2 uv = uvFromFlat(${m}, ${y}, index + ${k});
return sampleTexture(${r}, uv);
}
`}function Fee(n){const e=n.shapeInfo.logicalShape,t=n.name,r="get"+t.charAt(0).toUpperCase()+t.slice(1),s=e[4],o=e[3]*s,i=e[2]*o,a=e[1]*i,{newShape:l,keptDims:c}=pu(e);if(l.length<e.length){const b=Df(n,l),w=["row","col","depth","depth2","depth3"];return`
${Af(b)}
float ${r}(int row, int col, int depth, int depth2, int depth3) {
return ${r}(${Of(w,c)});
}
`}if(n.shapeInfo.isUniform)return`
float ${r}(int row, int col, int depth, int depth2, int depth3) {
float index = dot(
vec4(row, col, depth, depth2),
vec4(${a}, ${i}, ${o}, ${s})) +
depth3;
${_f(n)}
}
`;const d=n.shapeInfo.flatOffset,p=n.shapeInfo.texShape,m=p[0],y=p[1];if(y===a&&d==null)return`
float ${r}(int row, int col, int depth, int depth2, int depth3) {
int texR = row;
float texC = dot(vec4(col, depth, depth2, depth3),
vec4(${i}, ${o}, ${s}, 1));
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${y}.0, ${m}.0);
return sampleTexture(${t}, uv);
}
`;if(y===s&&d==null)return`
float ${r}(int row, int col, int depth, int depth2, int depth3) {
float texR = dot(
vec4(row, col, depth, depth2),
vec4(${e[1]*e[2]*e[3]},
${e[2]*e[3]}, ${e[3]}, 1));
int texC = depth3;
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${y}.0, ${m}.0);
return sampleTexture(${t}, uv);
}
`;const v=ph(t);return`
float ${r}(int row, int col, int depth, int depth2, int depth3) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * ${a} + col * ${i} + depth * ${o} +
depth2 * ${s} + depth3 + ${v};
vec2 uv = uvFromFlat(${m}, ${y}, index);
return sampleTexture(${t}, uv);
}
`}function Pee(n){const e=n.shapeInfo.logicalShape,t=n.name,r="get"+t.charAt(0).toUpperCase()+t.slice(1),{newShape:s,keptDims:o}=pu(e);if(s.length<e.length){const w=Df(n,s),k=["row","col","depth","depth2","depth3","depth4"];return`
${Af(w)}
float ${r}(int row, int col, int depth,
int depth2, int depth3, int depth4) {
return ${r}(${Of(k,o)});
}
`}const i=e[5],a=e[4]*i,l=e[3]*a,c=e[2]*l,d=e[1]*c;if(n.shapeInfo.isUniform)return`
float ${r}(int row, int col, int depth,
int depth2, int depth3, int depth4) {
int index = round(dot(
vec4(row, col, depth, depth2),
vec4(${d}, ${c}, ${l}, ${a})) +
dot(
vec2(depth3, depth4),
vec2(${i}, 1)));
${_f(n)}
}
`;const p=n.shapeInfo.flatOffset,m=n.shapeInfo.texShape,y=m[0],v=m[1];if(v===d&&p==null)return`
float ${r}(int row, int col, int depth,
int depth2, int depth3, int depth4) {
int texR = row;
float texC = dot(vec4(col, depth, depth2, depth3),
vec4(${c}, ${l}, ${a}, ${i})) +
float(depth4);
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${v}.0, ${y}.0);
return sampleTexture(${t}, uv);
}
`;if(v===i&&p==null)return`
float ${r}(int row, int col, int depth,
int depth2, int depth3, int depth4) {
float texR = dot(vec4(row, col, depth, depth2),
vec4(${e[1]*e[2]*e[3]*e[4]},
${e[2]*e[3]*e[4]},
${e[3]*e[4]},
${e[4]})) + float(depth3);
int texC = depth4;
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${v}.0, ${y}.0);
return sampleTexture(${t}, uv);
}
`;const b=ph(t);return`
float ${r}(int row, int col, int depth,
int depth2, int depth3, int depth4) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * ${d} + col * ${c} + depth * ${l} +
depth2 * ${a} + depth3 * ${i} + depth4 + ${b};
vec2 uv = uvFromFlat(${y}, ${v}, index);
return sampleTexture(${t}, uv);
}
`}function _f(n){const e=n.name,t=Se(n.shapeInfo.logicalShape);return t<2?`return ${e};`:`
for (int i = 0; i < ${t}; i++) {
if (i == index) {
return ${e}[i];
}
}
`}function Lee(n,e){const t=n.name,r=t.charAt(0).toUpperCase()+t.slice(1),s="get"+r+"AtOutCoords",o=n.shapeInfo.logicalShape.length,i=e.logicalShape.length,a=cF(n.shapeInfo.logicalShape,e.logicalShape),l=on(i),c=i-o;let d;const p=["x","y","z","w","u","v"];o===0?d="":i<2&&a.length>=1?d="coords = 0;":d=a.map(I=>`coords.${p[I+c]} = 0;`).join(`
`);let m="";i<2&&o>0?m="coords":m=n.shapeInfo.logicalShape.map((I,N)=>`coords.${p[N+c]}`).join(", ");let y="return outputValue;";const b=Se(n.shapeInfo.logicalShape)===1,k=Se(e.logicalShape)===1;if(o===1&&!b&&!k)y=`
return vec4(outputValue.xy, outputValue.xy);
`;else if(b&&!k)i===1?y=`
return vec4(outputValue.x, outputValue.x, 0., 0.);
`:y=`
return vec4(outputValue.x);
`;else if(a.length){const I=o-2,N=o-1;a.indexOf(I)>-1&&a.indexOf(N)>-1?y="return vec4(outputValue.x);":a.indexOf(I)>-1?y="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":a.indexOf(N)>-1&&(y="return vec4(outputValue.xx, outputValue.zz);")}return`
vec4 ${s}() {
${l} coords = getOutputCoords();
${d}
vec4 outputValue = get${r}(${m});
${y}
}
`}function Mee(n,e){const t=n.name,r=t.charAt(0).toUpperCase()+t.slice(1),s="get"+r+"AtOutCoords",o=e.texShape,i=n.shapeInfo.texShape,a=n.shapeInfo.logicalShape.length,l=e.logicalShape.length;if(!n.shapeInfo.isUniform&&a===l&&n.shapeInfo.flatOffset==null&&Xt(i,o))return`
float ${s}() {
return sampleTexture(${t}, resultUV);
}
`;const c=on(l),d=cF(n.shapeInfo.logicalShape,e.logicalShape),p=l-a;let m;const y=["x","y","z","w","u","v"];a===0?m="":l<2&&d.length>=1?m="coords = 0;":m=d.map(b=>`coords.${y[b+p]} = 0;`).join(`
`);let v="";return l<2&&a>0?v="coords":v=n.shapeInfo.logicalShape.map((b,w)=>`coords.${y[w+p]}`).join(", "),`
float ${s}() {
${c} coords = getOutputCoords();
${m}
return get${r}(${v});
}
`}function on(n){if(n<=1)return"int";if(n===2)return"ivec2";if(n===3)return"ivec3";if(n===4)return"ivec4";if(n===5)return"ivec5";if(n===6)return"ivec6";throw Error(`GPU for rank ${n} is not yet supported`)}function GI(n,e,t){const{newShape:r,keptDims:s}=pu(e),o=e.length,i=n&&o===3&&e[0]===1,a=i?e.slice(1):r,l=!n&&o>1&&!Xt(e,t)&&r.length<o||i;return{useSqueezeShape:l,uniformShape:l?a:e,keptDims:s}}function Df(n,e){const t=JSON.parse(JSON.stringify(n));return t.shapeInfo.logicalShape=e,t}function Of(n,e){return e.map(t=>n[t]).join(", ")}function zee(n,e,t,r){const s=t.map((d,p)=>{const m={logicalShape:d.shape,texShape:d.isUniform?null:d.texData.texShape,isUniform:d.isUniform,isPacked:d.isUniform?!1:d.texData.isPacked,flatOffset:null};return d.texData!=null&&d.texData.slice!=null&&d.texData.slice.flatOffset>0&&(m.flatOffset=d.texData.slice.flatOffset),{name:e.variableNames[p],shapeInfo:m}}),o=s.map(d=>d.shapeInfo),i={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},a=ree(s,i,e),l=_Z(n.gl,a),c=n.createProgram(l);return ye().get("ENGINE_COMPILE_ONLY")?{program:e,fragmentShader:l,source:a,webGLProgram:c,inShapeInfos:o,outShapeInfo:i,variablesLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:(n.buildVao(c),Object.assign({program:e,fragmentShader:l,source:a,webGLProgram:c,inShapeInfos:o,outShapeInfo:i},fF(n,e,c)))}function fF(n,e,t){const r=[],s=[];let o,i,a,l=null,c=null;c=n.getUniformLocation(t,"NAN",!1),ye().getNumber("WEBGL_VERSION")===1&&(l=n.getUniformLocation(t,"INFINITY",!1));const d=!1;for(const p of e.variableNames){const m={name:p,uniform:n.getUniformLocation(t,p,d),offset:n.getUniformLocation(t,`offset${p}`,d)};e.enableShapeUniforms&&(m.shape=n.getUniformLocation(t,`${p}Shape`,d),m.texShape=n.getUniformLocation(t,`${p}TexShape`,d)),r.push(m)}if(e.enableShapeUniforms&&(o=n.getUniformLocation(t,"outShape",d),a=n.getUniformLocation(t,"outShapeStrides",d),i=n.getUniformLocation(t,"outTexShape",d)),e.customUniforms)for(const p of e.customUniforms)s.push(n.getUniformLocation(t,p.name,d));return{variablesLocations:r,customUniformLocations:s,infLoc:l,nanLoc:c,outShapeLocation:o,outShapeStridesLocation:a,outTexShapeLocation:i}}function W2(n,e){if(n.length!==e.length)throw Error(`Binary was compiled with ${n.length} inputs, but was executed with ${e.length} inputs`);n.forEach((t,r)=>{const s=t.logicalShape,o=e[r],i=o.shape;if(!Xt(s,i))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${s} and ${i} must match`);if(t.isUniform&&o.isUniform)return;const a=t.texShape,l=o.isUniform?null:o.texData.texShape;if(!Xt(a,l))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${a} and ${l} must match`)})}function Bee(n,e,t,r,s){e.program.enableShapeUniforms||(W2(e.inShapeInfos,t),W2([e.outShapeInfo],[r]));const o=r.texData.texture,i=r.texData.texShape;r.texData.isPacked?n.setOutputPackedMatrixTexture(o.texture,i[0],i[1]):n.setOutputMatrixTexture(o.texture,i[0],i[1]),n.setProgram(e.webGLProgram),n.bindVertexArray(e.webGLProgram.vao),ye().getNumber("WEBGL_VERSION")===1&&e.infLoc!==null&&n.gl.uniform1f(e.infLoc,1/0),e.nanLoc!==null&&n.gl.uniform1f(e.nanLoc,NaN);for(let l=0;l<t.length;++l){const c=t[l],{uniform:d,offset:p,shape:m,texShape:y}=e.variablesLocations[l];if(m){const{uniformShape:v}=GI(e.program.packedInputs,c.shape,c.texData.texShape);switch(v.length){case 1:n.gl.uniform1iv(m,new Int32Array(v));break;case 2:n.gl.uniform2iv(m,new Int32Array(v));break;case 3:n.gl.uniform3iv(m,new Int32Array(v));break;case 4:n.gl.uniform4iv(m,new Int32Array(v));break}}if(y&&n.gl.uniform2i(y,c.texData.texShape[0],c.texData.texShape[1]),d!=null){if(c.isUniform){if(Se(c.shape)<2)n.gl.uniform1f(d,c.uniformValues[0]);else{let v=c.uniformValues;v instanceof Float32Array||(v=new Float32Array(v)),n.gl.uniform1fv(d,v)}continue}c.texData.slice!=null&&p!=null&&n.gl.uniform1i(p,c.texData.slice.flatOffset),n.setInputMatrixTexture(c.texData.texture.texture,d,l)}}const a=e.outShapeLocation;if(a)switch(r.shape.length){case 1:n.gl.uniform1iv(a,new Int32Array(r.shape));break;case 2:n.gl.uniform2iv(a,new Int32Array(r.shape));break;case 3:n.gl.uniform3iv(a,new Int32Array(r.shape));break;case 4:n.gl.uniform4iv(a,new Int32Array(r.shape));break}if(e.outShapeStridesLocation){const l=tt(r.shape);switch(r.shape.length){case 2:n.gl.uniform1iv(e.outShapeStridesLocation,new Int32Array(l));break;case 3:n.gl.uniform2iv(e.outShapeStridesLocation,new Int32Array(l));break;case 4:n.gl.uniform3iv(e.outShapeStridesLocation,new Int32Array(l));break}}if(e.outTexShapeLocation&&n.gl.uniform2i(e.outTexShapeLocation,r.texData.texShape[0],r.texData.texShape[1]),e.program.customUniforms&&s)for(let l=0;l<e.program.customUniforms.length;++l){const c=e.program.customUniforms[l],d=e.customUniformLocations[l],p=s[l];if(c.type==="float")n.gl.uniform1fv(d,p);else if(c.type==="vec2")n.gl.uniform2fv(d,p);else if(c.type==="vec3")n.gl.uniform3fv(d,p);else if(c.type==="vec4")n.gl.uniform4fv(d,p);else if(c.type==="int")n.gl.uniform1iv(d,p);else if(c.type==="ivec2")n.gl.uniform2iv(d,p);else if(c.type==="ivec3")n.gl.uniform3iv(d,p);else if(c.type==="ivec4")n.gl.uniform4iv(d,p);else throw Error(`uniform type ${c.type} is not supported yet.`)}n.executeProgram()}function Uee(n,e,t){let r="";e.concat(t).forEach(i=>{const a=i.texData!=null&&i.texData.slice!=null&&i.texData.slice.flatOffset>0;if(n.enableShapeUniforms&&!i.isUniform){const l=i.texData.texShape,{useSqueezeShape:c,uniformShape:d,keptDims:p}=GI(n.packedInputs,i.shape,l);let m="",y="",v="";if(d.length===1&&n.packedInputs){const A=[Math.ceil(l[0]/2),Math.ceil(l[1]/2)];m=`${A[0]>1}_${A[1]>1}`}else if(d.length===2&&!n.packedInputs)y=`${d[0]>1}_${d[1]>1}`;else if(d.length>2&&!n.packedInputs){const A=tt(d);v=`${A[0]===l[1]}_${A[A.length-1]===l[1]}`}const b=i.shape.length,w=d.length===2&&Xt(i.shape,l),k=Se(i.shape)===1,I=uf(i.shape,t.shape),N=!n.packedInputs&&b===t.shape.length&&Xt(l,t.texData.texShape),T=n.packedInputs||d.length>2?"":`${l[0]>1}_${l[1]>1}`;r+=`${b}_${N}_${c?p:""}_${d.length}_${k}_${I}_${w}_${m}_${y}_${v}_${T}_${a}`}else{const l=i.isUniform?"uniform":i.texData.texShape;r+=`${i.shape}_${l}_${a}`}});const s=n.userCode;let o=n.constructor.name;return o+="_"+r+"_"+s+`${ye().getNumber("WEBGL_VERSION")}`,o}function Kr(n){return ye().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&n<=4}class Wee{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=jm.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=hs();this.outputShape=e,this.enableShapeUniforms=Kr(this.outputShape.length),this.userCode=`
ivec3 outCoordsFromFlatIndex(int index) {
${this.enableShapeUniforms?Wv(["r","c","d"],e):fh(["r","c","d"],e)}
return ivec3(r, c, d);
}
void main() {
ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));
int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);
vec4 result = vec4(0.);
for (int i=0; i<4; i++) {
int flatIndex = index + i;
ivec3 rc = outCoordsFromFlatIndex(flatIndex);
result[i] = getA(rc.x, rc.y, rc.z);
}
${t.output} = result;
}
`}}class Vee{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=jm.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=hs();this.outputShape=e,this.enableShapeUniforms=Kr(this.outputShape.length),this.userCode=`
ivec3 outCoordsFromFlatIndex(int index) {
${this.enableShapeUniforms?Wv(["r","c","d"],e):fh(["r","c","d"],e)}
return ivec3(r, c, d);
}
void main() {
ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));
int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);
vec4 result = vec4(0.);
for (int i=0; i<4; i++) {
int flatIndex = index + i;
ivec3 rc = outCoordsFromFlatIndex(flatIndex);
result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));
}
${t.output} = result;
}
`}}class Gee{constructor(e){this.variableNames=["A"],this.outTexUsage=xo.DOWNLOAD;const t=hs();this.outputShape=e,this.userCode=`
${uF}
void main() {
float x = getAAtOutCoords();
${t.output} = encode_float(x);
}
`}}class jee{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=xo.DOWNLOAD;const t=hs();this.outputShape=e,this.userCode=`
${uF}
void main() {
ivec3 coords = getOutputCoords();
float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));
${t.output} = encode_float(x);
}
`}}const Hee={R:0,G:1,B:2,A:3};class V2{constructor(e,t=!1,r="RGBA"){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];const s=hs();this.outputShape=e,this.enableShapeUniforms=Kr(this.outputShape.length);let o="result";t&&(o="floor(result * 255. + 0.5)");let i="";for(let a=0;a<r.length;a++){const l=r[a];i+=`
if(offset == ${a}) {
result = values[${Hee[l]}];
}`}this.userCode=`
${this.enableShapeUniforms?VI():WI(e)}
void main() {
ivec3 coords = getOutputCoords();
int flatIndex = getFlatIndex(coords);
float result = 0.;
int offset = imod(flatIndex, ${r.length});
flatIndex = idiv(flatIndex, ${r.length}, 1.);
int r = flatIndex / texShape[1];
if (r < texShape[0]) {
int c = imod(flatIndex, texShape[1]);
vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);
vec4 values = ${s.texture2D}(A, uv);
${i}
}
${s.output} = vec4(${o}, 0., 0., 0.);
}
`}}class qee{constructor(e,t=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.customUniforms=[{name:"texShape",type:"ivec2"}];const r=hs();this.outputShape=e,this.enableShapeUniforms=Kr(this.outputShape.length);let s="",o="result";t&&(o="floor(result * 255. + 0.5)");for(let i=0;i<=1;i++)for(let a=0;a<=1;a++){const l=i*2+a;s+=`
localCoords = coords;
if(localCoords[2] + ${a} < ${this.enableShapeUniforms?"outShape[2]":`${e[2]}`}) {
localCoords[2] += ${a};
if (localCoords[1] + ${i} < ${this.enableShapeUniforms?"outShape[1]":`${e[1]}`}) {
localCoords[1] += ${i};
flatIndex = getFlatIndex(localCoords);
offset = imod(flatIndex, 4);
flatIndex = idiv(flatIndex, 4, 1.);
int r = flatIndex / texShape[1];
int c = imod(flatIndex, texShape[1]);
vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);
values = ${r.texture2D}(A, uv);
if (offset == 0) {
result[${l}] = values[0];
} else if (offset == 1) {
result[${l}] = values[1];
} else if (offset == 2) {
result[${l}] = values[2];
} else {
result[${l}] = values[3];
}
}
}
`}this.userCode=`
${this.enableShapeUniforms?VI():WI(e)}
void main() {
ivec3 coords = getOutputCoords();
vec4 result = vec4(0.);
int flatIndex, r, c, offset;
ivec3 localCoords;
vec2 uv;
vec4 values;
${s}
${r.output} = ${o};
}
`}}function Kee(n){const e=hs(),t=`${e.version}
precision highp float;
${e.attribute} vec3 clipSpacePos;
${e.attribute} vec2 uv;
${e.varyingVs} vec2 resultUV;
void main() {
gl_Position = vec4(clipSpacePos, 1);
resultUV = uv;
}`;return AZ(n,t)}function Xee(n){const e=new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]);return PZ(n,e)}function Yee(n){const e=new Uint16Array([0,1,2,2,1,3]);return LZ(n,e)}function yx(n,e,t,r,s,o){zZ(e,t);const i=MZ(n),a=n.TEXTURE_2D;return Ve(n,()=>n.bindTexture(a,i)),Ve(n,()=>n.texParameteri(a,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE)),Ve(n,()=>n.texParameteri(a,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)),Ve(n,()=>n.texParameteri(a,n.TEXTURE_MIN_FILTER,n.NEAREST)),Ve(n,()=>n.texParameteri(a,n.TEXTURE_MAG_FILTER,n.NEAREST)),ye().getNumber("WEBGL_VERSION")===1?Ve(n,()=>n.texImage2D(a,0,r,e,t,0,s,o,null)):Ve(n,()=>n.texStorage2D(a,1,r,e,t)),Ve(n,()=>n.bindTexture(n.TEXTURE_2D,null)),{texture:i,texShape:[t,e]}}function pF(n){return n.internalFormatFloat}function Qee(n,e,t,r){const[s,o]=gx(e,t);return yx(n,s,o,pF(r),r.textureFormatFloat,n.FLOAT)}function mF(n){return n.internalFormatHalfFloat}function Jee(n,e,t,r){const[s,o]=gx(e,t);return yx(n,s,o,mF(r),r.textureFormatFloat,r.textureTypeHalfFloat)}function gF(n){return n.downloadTextureFormat}function Zee(n,e,t,r){const[s,o]=gx(e,t);return yx(n,s,o,gF(r),n.RGBA,n.UNSIGNED_BYTE)}function xF(n){return n.internalFormatPackedFloat}function ete(n,e,t,r){const[s,o]=Rf(e,t);return yx(n,s,o,xF(r),n.RGBA,n.FLOAT)}function yF(n){return n.internalFormatPackedHalfFloat}function tte(n,e,t,r){const[s,o]=Rf(e,t);return yx(n,s,o,yF(r),n.RGBA,r.textureTypeHalfFloat)}function nte(n,e,t){return Ve(n,()=>n.bindBuffer(n.ARRAY_BUFFER,t)),z2(n,e,"clipSpacePos",t,3,20,0)&&z2(n,e,"uv",t,2,20,12)}function rte(n,e,t,r,s,o){Ve(n,()=>n.bindTexture(n.TEXTURE_2D,e));let i,a,l;s instanceof Uint8Array?(i=new Uint8Array(t*r*4),a=n.UNSIGNED_BYTE,l=n.RGBA):(i=new Float32Array(t*r*4),a=n.FLOAT,l=o.internalFormatPackedFloat),i.set(s),ye().getNumber("WEBGL_VERSION")===2?Ve(n,()=>n.texSubImage2D(n.TEXTURE_2D,0,0,0,t,r,n.RGBA,a,i)):Ve(n,()=>n.texImage2D(n.TEXTURE_2D,0,l,t,r,0,n.RGBA,a,i)),Ve(n,()=>n.bindTexture(n.TEXTURE_2D,null))}function ste(n,e,t){Ve(n,()=>n.bindTexture(n.TEXTURE_2D,e)),t.data instanceof Uint8Array?ye().getNumber("WEBGL_VERSION")===2?Ve(n,()=>n.texSubImage2D(n.TEXTURE_2D,0,0,0,t.width,t.height,n.RGBA,n.UNSIGNED_BYTE,t.data)):Ve(n,()=>n.texImage2D(n.TEXTURE_2D,0,n.RGBA,t.width,t.height,0,n.RGBA,n.UNSIGNED_BYTE,t.data)):ye().getNumber("WEBGL_VERSION")===2?Ve(n,()=>n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,t)):Ve(n,()=>n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t)),Ve(n,()=>n.bindTexture(n.TEXTURE_2D,null))}function ote(n,e,t,r){const s=n.createBuffer();Ve(n,()=>n.bindBuffer(n.PIXEL_PACK_BUFFER,s));const a=4*4*e*t;return Ve(n,()=>n.bufferData(n.PIXEL_PACK_BUFFER,a,n.STREAM_READ)),Ve(n,()=>n.readPixels(0,0,t,e,n.RGBA,n.FLOAT,0)),Ve(n,()=>n.bindBuffer(n.PIXEL_PACK_BUFFER,null)),s}function ite(n,e,t){const r=n,s=new Float32Array(t);return r.bindBuffer(r.PIXEL_PACK_BUFFER,e),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,s),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),s}function ate(n,e,t,r){const[s,o]=gx(e,t),i=4,a=new Uint8Array(kZ(e*t,i));return Ve(n,()=>n.readPixels(0,0,s,o,r.downloadTextureFormat,n.UNSIGNED_BYTE,a)),new Float32Array(a.buffer)}function lte(n,e,t,r,s,o,i,a){const l=n,c=new Float32Array(IZ(o,i));return l.bindBuffer(l.PIXEL_PACK_BUFFER,e),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,c),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),c}function ute(n,e,t){const r=new Float32Array(e*t*4);return Ve(n,()=>n.readPixels(0,0,t,e,n.RGBA,n.FLOAT,r)),r}class zb{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.itemsToPoll=[];const t=ye().getNumber("WEBGL_VERSION");if(e!=null?(this.gl=e,bZ(t,e)):this.gl=Ni(t),e=this.gl,ye().getNumber("WEBGL_VERSION")===2){const o=e;this.createVertexArray=()=>Ve(o,()=>o.createVertexArray()),this.bindVertexArray=i=>Ve(o,()=>o.bindVertexArray(i)),this.deleteVertexArray=i=>Ve(o,()=>o.deleteVertexArray(i)),this.getVertexArray=()=>Ve(o,()=>o.getParameter(o.VERTEX_ARRAY_BINDING))}else if(e!=null){const o=e.getExtension("OES_vertex_array_object");if(o==null)throw new Error("All WebGL1 implementations are expected to offer OES_vertex_array_object.");this.createVertexArray=()=>Ve(e,()=>o.createVertexArrayOES()),this.bindVertexArray=i=>Ve(e,()=>o.bindVertexArrayOES(i)),this.deleteVertexArray=i=>Ve(e,()=>o.deleteVertexArrayOES(i)),this.getVertexArray=()=>Ve(e,()=>e.getParameter(o.VERTEX_ARRAY_BINDING_OES))}let r="WEBGL_color_buffer_float";const s="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),ye().getNumber("WEBGL_VERSION")===1){const o="OES_texture_float",i="OES_texture_half_float";if(this.textureFloatExtension=cy(this.gl,o),Ho(this.gl,i))this.textureHalfFloatExtension=cy(this.gl,i);else if(ye().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");if(this.colorBufferFloatExtension=this.gl.getExtension(r),Ho(this.gl,s))this.colorBufferHalfFloatExtension=cy(this.gl,s);else if(ye().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.")}else if(r="EXT_color_buffer_float",Ho(this.gl,r))this.colorBufferFloatExtension=this.gl.getExtension(r);else if(Ho(this.gl,s))this.colorBufferHalfFloatExtension=this.gl.getExtension(s);else throw new Error("GL context does not support color renderable floats");this.vertexBuffer=Xee(this.gl),this.indexBuffer=Yee(this.gl),this.framebuffer=BZ(this.gl),this.textureConfig=UI(this.gl,this.textureHalfFloatExtension)}get debug(){return ye().getBool("DEBUG")}dispose(){if(this.disposed)return;this.program!=null&&console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."),this.outputTexture!=null&&console.warn("Disposing a GPGPUContext that still has a bound output matrix texture. This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing.");const e=this.gl;Ve(e,()=>e.finish()),Ve(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),Ve(e,()=>e.deleteFramebuffer(this.framebuffer)),Ve(e,()=>e.bindBuffer(e.ARRAY_BUFFER,null)),Ve(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)),Ve(e,()=>e.deleteBuffer(this.indexBuffer)),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),Qee(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),Jee(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),Zee(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),ste(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,r,s){this.throwIfDisposed(),rte(this.gl,e,t,r,s,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),tte(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),ete(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(B2(this.gl,this.framebuffer),this.outputTexture=null),Ve(this.gl,()=>this.gl.deleteTexture(e))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,r){return this.downloadMatrixDriver(e,()=>ate(this.gl,t,r,this.textureConfig))}downloadPackedMatrixFromBuffer(e,t,r,s,o,i){return lte(this.gl,e,t,r,s,o,i,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return ite(this.gl,e,t)}createBufferFromTexture(e,t,r){this.bindTextureToFrameBuffer(e);const s=ote(this.gl,t,r,this.textureConfig);return this.unbindTextureToFrameBuffer(),s}createAndWaitForFence(){const e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let t,r;if(ye().getBool("WEBGL_FENCE_API_ENABLED")){const s=e,o=s.fenceSync(s.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),r=()=>{const i=s.clientWaitSync(o,0,0);return i===s.ALREADY_SIGNALED||i===s.CONDITION_SATISFIED},t=o}else ye().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),r=()=>this.isQueryAvailable(t,ye().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):r=()=>!0;return{query:t,isFencePassed:r}}downloadMatrixFromPackedTexture(e,t,r){return this.downloadMatrixDriver(e,()=>ute(this.gl,t,r))}createProgram(e){this.throwIfDisposed();const t=this.gl;this.vertexShader==null&&(this.vertexShader=Kee(t));const r=OZ(t);Ve(t,()=>t.attachShader(r,this.vertexShader)),Ve(t,()=>t.attachShader(r,e)),FZ(t,r);const s=Object.assign(r,{vao:this.createVertexArray()});return this.debug&&Fb(t,s),s}buildVao(e){this.setProgram(e),this.bindVertexArray(e.vao);const t=this.gl;Ve(t,()=>t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer)),nte(t,e,this.vertexBuffer)}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),e!=null&&(Ve(this.gl,()=>this.gl.deleteProgram(e)),this.deleteVertexArray(e.vao))}setProgram(e){this.throwIfDisposed(),this.program=e,this.program!=null&&this.debug&&Fb(this.gl,this.program),Ve(this.gl,()=>this.gl.useProgram(e))}getUniformLocation(e,t,r=!0){return this.throwIfDisposed(),r?WZ(this.gl,e,t):VZ(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),Ve(this.gl,()=>this.gl.getAttribLocation(e,t))}getUniformLocationNoThrow(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)}setInputMatrixTexture(e,t,r){this.throwIfDisposed(),this.throwIfNoProgram(),GZ(this.gl,e,t,r)}setOutputMatrixTexture(e,t,r){this.setOutputMatrixTextureDriver(e,r,t)}setOutputPackedMatrixTexture(e,t,r){this.throwIfDisposed();const[s,o]=Rf(t,r);this.setOutputMatrixTextureDriver(e,s,o)}setOutputMatrixWriteRegion(e,t,r,s){this.setOutputMatrixWriteRegionDriver(r,e,s,t)}setOutputPackedMatrixWriteRegion(e,t,r,s){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){this.program!=null&&Fb(this.gl,this.program),hy(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const e=this.gl;if(this.debug){const t=this.getVertexArray();console.assert(t===this.program.vao,"VAO changed between setProgram and executeProgram!"),this.debugValidate()}Ve(e,()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),Ve(this.gl,()=>this.gl.finish())}getQueryTimerExtension(){return this.disjointQueryTimerExtension==null&&(this.disjointQueryTimerExtension=cy(this.gl,ye().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(ye().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){const r=this.gl,s=this.getQueryTimerExtensionWebGL2(),o=r.createQuery();return r.beginQuery(s.TIME_ELAPSED_EXT,o),o}const e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(ye().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){const t=this.gl,r=this.getQueryTimerExtensionWebGL2();t.endQuery(r.TIME_ELAPSED_EXT);return}const e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await kN(()=>this.disposed||this.isQueryAvailable(e,ye().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))),this.getQueryTime(e,ye().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,t){if(t===0)return null;if(t===2){const r=this.gl;return r.getQueryParameter(e,r.QUERY_RESULT)/1e6}else{const r=this.getQueryTimerExtensionWebGL1();return r.getQueryObjectEXT(e,r.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,t){if(t===0)return!0;if(t===2){const r=this.gl,s=this.getQueryTimerExtensionWebGL2(),o=r.getQueryParameter(e,r.QUERY_RESULT_AVAILABLE);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(s.GPU_DISJOINT_EXT)),o&&!this.disjoint}else{const r=this.getQueryTimerExtensionWebGL1(),s=r.getQueryObjectEXT(e,r.QUERY_RESULT_AVAILABLE_EXT);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),s&&!this.disjoint}}pollFence(e){return new Promise(t=>{this.addItemToPoll(()=>e.isFencePassed(),()=>t())})}pollItems(){const e=cte(this.itemsToPoll.map(t=>t.isDoneFn));for(let t=0;t<=e;++t){const{resolveFn:r}=this.itemsToPoll[t];r()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,t){if(this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1)return;let r;"setTimeoutCustom"in ye().platform&&(r=ye().platform.setTimeoutCustom.bind(ye().platform)),kN(()=>(this.pollItems(),this.itemsToPoll.length===0),()=>0,null,r)}bindTextureToFrameBuffer(e){this.throwIfDisposed(),Pb(this.gl,e,this.framebuffer),this.debug&&hy(this.gl)}unbindTextureToFrameBuffer(){this.outputTexture!=null?(Pb(this.gl,this.outputTexture,this.framebuffer),this.debug&&hy(this.gl)):B2(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);const r=t();return this.unbindTextureToFrameBuffer(),r}setOutputMatrixTextureDriver(e,t,r){this.throwIfDisposed();const s=this.gl;Pb(s,e,this.framebuffer),this.debug&&hy(s),this.outputTexture=e,Ve(s,()=>s.viewport(0,0,t,r)),Ve(s,()=>s.scissor(0,0,t,r))}setOutputMatrixWriteRegionDriver(e,t,r,s){this.throwIfDisposed(),Ve(this.gl,()=>this.gl.scissor(e,t,r,s))}throwIfDisposed(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(this.program==null)throw new Error("No GPU program is currently set.")}}function cte(n){let e=0;for(;e<n.length&&n[e]();++e);return e-1}const{addImpl:hte,bincountImpl:vF,bincountReduceImpl:dte,bitwiseAndImpl:fte,castImpl:pte,ceilImpl:mte,concatImpl:gte,equalImpl:xte,expImpl:yte,expm1Impl:vte,floorImpl:wte,gatherNdImpl:bte,gatherV2Impl:Cte,greaterImpl:Ste,greaterEqualImpl:kte,lessImpl:Ite,lessEqualImpl:$te,linSpaceImpl:Nte,logImpl:Tte,maxImpl:Ete,maximumImpl:Rte,minimumImpl:Ate,multiplyImpl:_te,negImpl:Dte,notEqualImpl:Ote,prodImpl:Fte,raggedGatherImpl:Pte,raggedRangeImpl:Lte,raggedTensorToTensorImpl:Mte,rangeImpl:zte,rsqrtImpl:Bte,scatterImpl:Ute,sigmoidImpl:Wte,simpleAbsImpl:wF,sliceImpl:Vte,sparseFillEmptyRowsImpl:Gte,sparseReshapeImpl:jte,sparseSegmentReductionImpl:bF,sqrtImpl:Hte,staticRegexReplaceImpl:qte,stridedSliceImpl:Kte,stringNGramsImpl:Xte,stringSplitImpl:Yte,stringToHashBucketFastImpl:Qte,subImpl:Jte,tileImpl:Zte,topKImpl:ene,transposeImpl:jI,uniqueImpl:tne}=sX;function CF(n,e){return["x","y","z","w","u","v"].slice(0,e).map(t=>`${n}.${t}`)}function ls(n,e){return e===1?[n]:CF(n,e)}function nne(n,e){if(n===1)return"rc";let t="";for(let r=0;r<n;r++)t+=e[r],r<n-1&&(t+=",");return t}class rne{constructor(e){if(this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.enableShapeUniforms=Kr(this.outputShape.length),this.rank===0)this.userCode=`
void main() {
setOutput(vec4(getA(), 0., 0., 0.));
}
`;else{const t=ls("rc",this.rank),r=on(this.rank),s=this.getOutOfBoundsCondition(t),o=this.getSetup(t),i=this.getOutput(t);this.userCode=`
void main() {
${r} rc = getOutputCoords();
if(${s}) {
setOutput(vec4(0));
} else {
${o}
setOutput(vec4(${i}));
}
}
`}}getSourceCoordsArr(e){const t=[];for(let r=0;r<=1;r++)for(let s=0;s<=1;s++){let o=`${r===0?"r":"rp1"}, ${s===0?"c":"cp1"}`;for(let i=2;i<this.rank;i++)o=`${e[e.length-1-i]},`+o;t.push(o)}return t}getOutOfBoundsCondition(e){if(this.rank===1)return`rc > ${this.enableShapeUniforms?"outShape":this.outputShape[0]}`;let t="";for(let r=this.rank-2;r<this.rank;r++)t+=`${e[r]} >= ${this.enableShapeUniforms?`outShape[${r}]`:this.outputShape[r]}`,r<this.rank-1&&(t+="||");return t}getSetup(e){if(this.rank===1)return"";const t=e.slice(-2),r=this.enableShapeUniforms?`outShape[${this.rank} - 1]`:this.outputShape[this.rank-1],s=this.enableShapeUniforms?`outShape[${this.rank} - 2]`:this.outputShape[this.rank-2];return`
int r = ${t[0]};
int c = ${t[1]};
int rp1 = r + 1;
int cp1 = c + 1;
bool cEdge = cp1 >= ${r};
bool rEdge = rp1 >= ${s};
`}getOutput(e){const t=this.getSourceCoordsArr(e);return this.rank===1?`getA(rc), (rc + 1 >= ${this.enableShapeUniforms?"outShape":this.outputShape[0]} ? 0. : getA(rc + 1)), 0, 0`:`getA(${t[0]}),
cEdge ? 0. : getA(${t[1]}),
rEdge ? 0. : getA(${t[2]}),
rEdge || cEdge ? 0. : getA(${t[3]})`}}class SF{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=Kr(this.outputShape.length);let r="";for(let s=0;s<4;s++){let o="thisRC = rc;";s%2===1&&(o+="thisRC.z += 1;"),s>1&&(o+="thisRC.y += 1;"),r+=`
${o}
${s>0?"if(thisRC.y < rows && thisRC.z < cols){":""}
int flatIndex = getFlatIndex(thisRC);
ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);
vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));
result[${s}] =
getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);
${s>0?"}":""}
`}this.userCode=`
${sne(t,this.enableShapeUniforms)}
${this.enableShapeUniforms?VI():WI(e)}
void main() {
ivec3 rc = getOutputCoords();
vec4 result = vec4(0.);
ivec3 thisRC;
int rows = ${this.enableShapeUniforms?"outShape[1]":e[1]};
int cols = ${this.enableShapeUniforms?"outShape[2]":e[2]};
${r}
setOutput(result);
}
`}}function sne(n,e){return`
ivec3 inputCoordsFromReshapedOutCoords(int index) {
${e?nee(["r","c","d"],"inputShape"):fh(["r","c","d"],n)}
return ivec3(r, c, d);
}
`}class one{constructor(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.usedTextures={},this.logEnabled=!1}acquireTexture(e,t,r){const s=j2(t,r),o=H2(e,s,r);o in this.freeTextures||(this.freeTextures[o]=[]),o in this.usedTextures||(this.usedTextures[o]=[]);const i=G2(e,s,this.gpgpu.gl,this.gpgpu.textureConfig,r);if(this.freeTextures[o].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=i,this.log();const l=this.freeTextures[o].pop();return this.usedTextures[o].push(l),l}let a;return s===Rr.PACKED_2X2_FLOAT32?a=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):s===Rr.PACKED_2X2_FLOAT16?a=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):s===Rr.UNPACKED_FLOAT32?a=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):s===Rr.UNPACKED_FLOAT16?a=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):s===Rr.PACKED_4X1_UNSIGNED_BYTE&&(a=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[o].push(a),this.numUsedTextures++,this._numBytesAllocated+=i,this.log(),a}releaseTexture(e,t,r,s){if(this.freeTextures==null)return;const o=j2(r,s),i=H2(t,o,s);i in this.freeTextures||(this.freeTextures[i]=[]);const a=G2(t,o,this.gpgpu.gl,this.gpgpu.textureConfig,s),l=ye().getNumber("WEBGL_DELETE_TEXTURE_THRESHOLD");l!==-1&&this._numBytesAllocated>l?(this.gpgpu.deleteMatrixTexture(e.texture),this._numBytesAllocated-=a):(this.freeTextures[i].push(e),this.numFreeTextures++,this._numBytesFree+=a),this.numUsedTextures--;const c=this.usedTextures[i],d=c&&c.indexOf(e);if(d==null||d<0)throw new Error("Cannot release a texture that was never provided by this texture manager");c[d]=c[c.length-1],c.pop(),this.log()}log(){if(!this.logEnabled)return;const e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${e})`);const t=this._numBytesFree/this._numBytesAllocated;console.log(`Bytes allocated: ${this._numBytesAllocated}`),console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100*t)}%)`)}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(this.freeTextures!=null){for(const e in this.freeTextures)this.freeTextures[e].forEach(t=>{this.gpgpu.deleteMatrixTexture(t.texture)});for(const e in this.usedTextures)this.usedTextures[e].forEach(t=>{this.gpgpu.deleteMatrixTexture(t.texture)});this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function ine(n,e){const t=n;if(e===t.R32F)return 4;if(e===t.R16F)return 2;if(e===t.RGBA32F)return 16;if(e===n.RGBA)return 16;if(e===t.RGBA16F)return 8;if(e===t.RGBA8)return 4;throw new Error(`Unknown internal format ${e}`)}function G2(n,e,t,r,s){const o=ane(e,r);let i;if(s){const[l,c]=Rf(n[0],n[1]);i=l*c}else{const[l,c]=gx(n[0],n[1]);i=l*c}const a=ine(t,o);return i*a}function ane(n,e){switch(n){case Rr.PACKED_2X2_FLOAT32:return xF(e);case Rr.PACKED_2X2_FLOAT16:return yF(e);case Rr.UNPACKED_FLOAT32:return pF(e);case Rr.UNPACKED_FLOAT16:return mF(e);case Rr.PACKED_4X1_UNSIGNED_BYTE:return gF(e);default:throw new Error(`Unknown physical texture type ${n}`)}}function lne(n){return ye().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?n?Rr.PACKED_2X2_FLOAT32:Rr.UNPACKED_FLOAT32:n?Rr.PACKED_2X2_FLOAT16:Rr.UNPACKED_FLOAT16}function j2(n,e){if(n===xo.UPLOAD)return Rr.PACKED_2X2_FLOAT32;if(n===xo.RENDER||n==null)return lne(e);if(n===xo.DOWNLOAD||n===xo.PIXELS)return Rr.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${n}`)}function H2(n,e,t){return`${n[0]}_${n[1]}_${e}_${t}`}class la{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=Kr(this.outputShape.length),this.userCode=`
float unaryOperation(float x) {
${t}
}
void main() {
float x = getAAtOutCoords();
float y = unaryOperation(x);
setOutput(y);
}
`}}const Qo="if (isnan(x)) return x;",une="return x;",q2="return abs(x);",cne="return (x >= 0.0) ? x : (exp(x) - 1.0);",hne=Qo+`
return (x < 0.0) ? 0.0 : x;
`,dne=Qo+`
return (x < 0.0) ? 0.0 : min(6.0, x);
`,Yl="return x;",fne="return 1.0 / (1.0 + exp(-1.0 * x));";const pne="return x;",mne=`
vec4 result;
result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);
result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);
result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);
result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);
return result;
`,gne=`
vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));
bvec4 isNaN = isnan(x);
result.r = isNaN.r ? x.r : result.r;
result.g = isNaN.g ? x.g : result.g;
result.b = isNaN.b ? x.b : result.b;
result.a = isNaN.a ? x.a : result.a;
return result;
`,xne=`
vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));
bvec4 isNaN = isnan(x);
result.r = isNaN.r ? x.r : result.r;
result.g = isNaN.g ? x.g : result.g;
result.b = isNaN.b ? x.b : result.b;
result.a = isNaN.a ? x.a : result.a;
return result;
`,yne="return 1.0 / (1.0 + exp(-1.0 * x));";class tu{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=Kr(this.outputShape.length),this.userCode=`
vec4 unaryOperation(vec4 x) {
${t}
}
void main() {
vec4 x = getAAtOutCoords();
vec4 y = unaryOperation(x);
setOutput(y);
}
`}}class vne{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e,this.enableShapeUniforms=Kr(this.outputShape.length);const t=e.length,r=ls("rc",t),s=on(t),o=nne(t,r),i=r.slice(-2),a=t<=1?"rc":`vec2(${i.join(",")})`;this.userCode=`
void main() {
${s} rc = getOutputCoords();
vec4 packedInput = getA(${o});
setOutput(getChannel(packedInput, ${a}));
}
`}}const wne=jR,bne=1e-7,Cne=1e-4,py={};function Sne(n){return n in py||(py[n]={}),py[n]}const kne=ye().getNumber("CPU_HANDOFF_SIZE_THRESHOLD"),Ine=600;function $ne(){return ye().global.screen==null?1024:ye().global.screen.height*ye().global.screen.width*window.devicePixelRatio*Ine/1024/1024}class Vv extends hS{nextDataId(){return Vv.nextDataId++}constructor(e){if(super(),this.pendingRead=new WeakMap,this.pendingDisposal=new WeakSet,this.dataRefCount=new WeakMap,this.numBytesInGPU=0,this.uploadWaitMs=0,this.downloadWaitMs=0,this.lastGlFlushTime=0,this.warnedAboutMemory=!1,this.pendingDeletes=0,this.disposed=!1,!ye().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");let t;if(e!=null){if(e instanceof zb)t=e;else{const r=Ni(ye().getNumber("WEBGL_VERSION"),e);t=new zb(r)}this.binaryCache={},this.gpgpuCreatedLocally=!1}else{const r=Ni(ye().getNumber("WEBGL_VERSION"));t=new zb(r),this.binaryCache=Sne(ye().getNumber("WEBGL_VERSION")),this.gpgpuCreatedLocally=!0}this.gpgpu=t,this.canvas=this.gpgpu.gl.canvas,this.textureManager=new one(this.gpgpu),this.numMBBeforeWarning=$ne(),this.texData=new yE(this,na())}numDataIds(){return this.texData.numDataIds()-this.pendingDeletes}writeTexture(e,t,r,s,o,i){const a=this.makeTensorInfo(t,r),l=this.texData.get(a.dataId);l.isPacked=!1,l.texture={texture:e,texShape:[s,o]},l.texShape=[s,o];const c=dy(t),d=new V2(c,!1,i),p=this.runWebGLProgram(d,[a],r,[[s,o]]);return p.shape=t,l.texture=null,this.disposeIntermediateTensorInfo(a),p.dataId}write(e,t,r){if((ye().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||ye().getBool("DEBUG"))&&this.checkNumericalProblems(e),r==="complex64"&&e!=null)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");const s={id:this.nextDataId()};return this.texData.set(s,{shape:t,dtype:r,values:e,usage:xo.UPLOAD,refCount:1}),s}refCount(e){return this.texData.has(e)?this.texData.get(e).refCount:0}incRef(e){const t=this.texData.get(e);t.refCount++}decRef(e){if(this.texData.has(e)){const t=this.texData.get(e);t.refCount--}}move(e,t,r,s,o){if(ye().getBool("DEBUG")&&this.checkNumericalProblems(t),s==="complex64")throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:r,dtype:s,values:t,usage:xo.UPLOAD,refCount:o})}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}readSync(e){const t=this.texData.get(e),{values:r,dtype:s,complexTensorInfos:o,slice:i,shape:a,isPacked:l}=t;if(i!=null){let m;l?m=new tu(a,Yl):m=new la(a,Yl);const y=this.runWebGLProgram(m,[{dataId:e,shape:a,dtype:s}],s),v=this.readSync(y.dataId);return this.disposeIntermediateTensorInfo(y),v}if(r!=null)return this.convertAndCacheOnCPU(e);if(s==="string")return r;const c=this.activeTimers!=null;let d;c&&(d=Cs());let p;if(s==="complex64"){const m=this.readSync(o.real.dataId),y=this.readSync(o.imag.dataId);p=ol(m,y)}else p=this.getValuesFromTexture(e);return c&&(this.downloadWaitMs+=Cs()-d),this.convertAndCacheOnCPU(e,p)}async read(e){if(this.pendingRead.has(e)){const v=this.pendingRead.get(e);return new Promise(b=>v.push(b))}const t=this.texData.get(e),{values:r,shape:s,slice:o,dtype:i,complexTensorInfos:a,isPacked:l}=t;if(o!=null){let v;l?v=new tu(s,Yl):v=new la(s,Yl);const b=this.runWebGLProgram(v,[{dataId:e,shape:s,dtype:i}],i),w=this.read(b.dataId);return this.disposeIntermediateTensorInfo(b),w}if(r!=null)return this.convertAndCacheOnCPU(e);if(ye().getBool("DEBUG")&&!ye().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&ye().getNumber("WEBGL_VERSION")===2)throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let c=null,d;if(i!=="complex64"&&ye().get("WEBGL_BUFFER_SUPPORTED")){d=this.decode(e);const v=this.texData.get(d.dataId);c=this.gpgpu.createBufferFromTexture(v.texture.texture,...uy(s))}this.pendingRead.set(e,[]),i!=="complex64"&&await this.gpgpu.createAndWaitForFence();let p;if(i==="complex64"){const v=await Promise.all([this.read(a.real.dataId),this.read(a.imag.dataId)]),b=v[0],w=v[1];p=ol(b,w)}else if(c==null)p=this.getValuesFromTexture(e);else{const v=Se(s);p=this.gpgpu.downloadFloat32MatrixFromBuffer(c,v)}if(d!=null&&this.disposeIntermediateTensorInfo(d),c!=null){const v=this.gpgpu.gl;Ve(v,()=>v.deleteBuffer(c))}const m=this.convertAndCacheOnCPU(e,p),y=this.pendingRead.get(e);return this.pendingRead.delete(e),y.forEach(v=>v(m)),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&na().removeDataId(e,this),this.pendingDeletes--),m}readToGPU(e,t={}){const r=this.texData.get(e),{values:s,shape:o,slice:i,dtype:a,isPacked:l,texture:c}=r;if(a==="complex64")throw new Error("Does not support reading texture for complex64 dtype.");if(i!=null){let y;l?y=new tu(o,Yl):y=new la(o,Yl);const v=this.runWebGLProgram(y,[{dataId:e,shape:o,dtype:a}],a),b=this.readToGPU(v,t);return this.disposeIntermediateTensorInfo(v),b}if(c==null)throw s!=null?new Error("Data is not on GPU but on CPU."):new Error("There is no data on GPU or CPU.");const d=this.decode(e,t.customTexShape),p=na().makeTensorFromTensorInfo(d),m=this.texData.get(d.dataId);return Object.assign({tensorRef:p},m.texture)}bufferSync(e){const t=this.readSync(e.dataId);if(e.dtype==="string")try{const r=t.map(s=>au(s));return Nt(e.shape,e.dtype,r)}catch{throw new Error("Failed to decode encoded string bytes into utf-8")}return Nt(e.shape,e.dtype,t)}checkNumericalProblems(e){if(e!=null)for(let t=0;t<e.length;t++){const r=e[t];if(!EZ(r))throw ye().getBool("WEBGL_RENDER_FLOAT32_CAPABLE")?Error(`The value ${r} cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'`):Error(`The value ${r} cannot be represented on this device.`)}}getValuesFromTexture(e){const{shape:t,dtype:r,isPacked:s}=this.texData.get(e),o=Se(t);if(ye().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){const m=this.decode(e),y=this.texData.get(m.dataId),v=this.gpgpu.downloadMatrixFromPackedTexture(y.texture.texture,...uy(t)).subarray(0,o);return this.disposeIntermediateTensorInfo(m),v}const i=ye().getBool("WEBGL_PACK")&&s===!0,a=i?dy(t):t,l=i?new jee(a):new Gee(a),c=this.runWebGLProgram(l,[{shape:a,dtype:r,dataId:e}],"float32"),d=this.texData.get(c.dataId),p=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(d.texture.texture,d.texShape[0],d.texShape[1]).subarray(0,o);return this.disposeIntermediateTensorInfo(c),p}timerAvailable(){return ye().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0}time(e){const t=this.activeTimers,r=[];let s=!1;this.programTimersStack==null?(this.programTimersStack=r,s=!0):this.activeTimers.push(r),this.activeTimers=r,e();const o=jc(this.activeTimers.map(l=>l.query)).filter(l=>l!=null),i=jc(this.activeTimers.map(l=>l.name)).filter(l=>l!=null);this.activeTimers=t,s&&(this.programTimersStack=null);const a={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};return(async()=>{if(ye().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const l=await Promise.all(o);a.kernelMs=V4(l),a.getExtraProfileInfo=()=>l.map((c,d)=>({name:i[d],ms:c})).map(c=>`${c.name}: ${c.ms}`).join(", ")}else a.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,a})()}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return ye().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:Cs(),endMs:null}}endTimer(e){return ye().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=Cs(),e)}async getQueryTime(e){if(ye().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)return this.gpgpu.waitForQueryAndGetTime(e);const t=e;return t.endMs-t.startMs}disposeData(e,t=!1){if(this.pendingDisposal.has(e))return!1;if(!this.texData.has(e))return!0;if(t?this.texData.get(e).refCount=0:this.texData.get(e).refCount--,!t&&this.texData.get(e).refCount>0)return!1;if(this.pendingRead.has(e))return this.pendingDisposal.add(e),this.pendingDeletes++,!1;this.releaseGPUData(e);const{complexTensorInfos:r}=this.texData.get(e);return r!=null&&(this.disposeData(r.real.dataId,t),this.disposeData(r.imag.dataId,t)),this.texData.delete(e),!0}releaseGPUData(e){const{texture:t,dtype:r,texShape:s,usage:o,isPacked:i,slice:a}=this.texData.get(e),l=a&&a.origDataId||e,c=this.dataRefCount.get(l);c>1?this.dataRefCount.set(l,c-1):(this.dataRefCount.delete(l),t!=null&&(this.numBytesInGPU-=this.computeBytes(s,r),this.textureManager.releaseTexture(t,s,o,i)));const d=this.texData.get(e);d.texture=null,d.texShape=null,d.isPacked=!1,d.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture.texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,t=kne){return ye().getBool("WEBGL_CPU_FORWARD")&&e.every(r=>this.texData.get(r.dataId).texture==null&&Se(r.shape)<t)}getGPGPUContext(){return this.gpgpu}where(e){go("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");const t=e.dataSync();return wne(e.shape,t)}packedUnaryOp(e,t,r){const s=new tu(e.shape,t),o=this.compileAndRun(s,[e],r);return na().makeTensorFromTensorInfo(o)}abs(e){if(this.shouldExecuteOnCPU([e])&&e.dtype!=="complex64"){const s=wF(this.texData.get(e.dataId).values);return this.makeOutput(e.shape,e.dtype,s)}if(ye().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,q2,e.dtype);const t=new la(e.shape,q2),r=this.compileAndRun(t,[e]);return na().makeTensorFromTensorInfo(r)}makeTensorInfo(e,t,r){let s;if(t==="string"&&r!=null&&r.length>0&&tg(r[0])){const o=r.map(i=>su(i));s=this.write(o,e,t)}else s=this.write(r,e,t);return this.texData.get(s).usage=null,{dataId:s,shape:e,dtype:t}}makeOutput(e,t,r){return na().makeTensorFromTensorInfo(this.makeTensorInfo(e,t,r),this)}unpackTensor(e){const t=new vne(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){const t=new rne(e.shape);return this.runWebGLProgram(t,[e],e.dtype,null,!0)}packedReshape(e,t){const r=[mf(e.shape),...gf(e.shape)],s={dtype:e.dtype,shape:r,dataId:e.dataId},o=[mf(t),...gf(t)],i=new SF(o,r),a=!0,l=[r],c=this.runWebGLProgram(i,[s],e.dtype,l,a);return{dataId:c.dataId,shape:t,dtype:c.dtype}}decode(e,t){const r=this.texData.get(e),{isPacked:s,shape:o,dtype:i}=r;if(t!=null){const m=Se(o),y=t[0]*t[1]*4;U(m<=y,()=>"customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data.")}const a=dy(o);let l;s?l=new Vee(a):l=new Wee(a);const c=!0,d=[t??uy(a)],p=this.runWebGLProgram(l,[{shape:a,dtype:i,dataId:e}],i,d,c,t);return{dtype:i,shape:o,dataId:p.dataId}}runWebGLProgram(e,t,r,s,o=!1,i){const a=this.makeTensorInfo(e.outputShape,r),l=this.texData.get(a.dataId);if(e.packedOutput&&(l.isPacked=!0),e.outPackingScheme===jm.DENSE){const k=i??uy(e.outputShape);l.texShape=k.map(I=>I*2)}if(e.outTexUsage!=null&&(l.usage=e.outTexUsage),Se(a.shape)===0)return l.values=Vr(a.dtype,0),a;const c=[],d=t.map(k=>{if(k.dtype==="complex64")throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");let I=this.texData.get(k.dataId);if(I.texture==null){if(!e.packedInputs&&Se(k.shape)<=ye().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:k.shape,texData:null,isUniform:!0,uniformValues:I.values};e.packedInputs&&(I.isPacked=!0,I.shape=k.shape)}if(this.uploadToGPU(k.dataId),!!I.isPacked!=!!e.packedInputs)k=I.isPacked?this.unpackTensor(k):this.packTensor(k),c.push(k),I=this.texData.get(k.dataId);else if(I.isPacked&&!l1(I.shape,k.shape)){const N=k,T=k.shape;k.shape=I.shape,k=this.packedReshape(k,T),c.push(k),I=this.texData.get(k.dataId),N.shape=T}return{shape:k.shape,texData:I,isUniform:!1}});this.uploadToGPU(a.dataId);const p={shape:a.shape,texData:l,isUniform:!1},m=Uee(e,d,p),y=this.getAndSaveBinary(m,()=>zee(this.gpgpu,e,d,p)),v=this.activeTimers!=null;let b;v&&(b=this.startTimer()),ye().get("ENGINE_COMPILE_ONLY")||Bee(this.gpgpu,y,d,p,s),c.forEach(k=>this.disposeIntermediateTensorInfo(k)),v&&(b=this.endTimer(b),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(b)}));const w=ye().getNumber("WEBGL_FLUSH_THRESHOLD");if(w>0){const k=Cs();k-this.lastGlFlushTime>w&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=k)}if(!ye().getBool("WEBGL_LAZILY_UNPACK")&&l.isPacked&&o===!1){const k=this.unpackTensor(a);return this.disposeIntermediateTensorInfo(a),k}return a}compileAndRun(e,t,r,s,o=!1){return r=r||t[0].dtype,this.runWebGLProgram(e,t,r,s,o)}getAndSaveBinary(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){this.disposed||(ye().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach(t=>{this.gpgpu.deleteProgram(this.binaryCache[t].webGLProgram),delete this.binaryCache[t]}),this.textureManager.dispose(),this.canvas!=null&&typeof HTMLCanvasElement<"u"&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0)}floatPrecision(){return this.floatPrecisionValue==null&&(this.floatPrecisionValue=me(()=>{if(!ye().get("WEBGL_RENDER_FLOAT32_ENABLED")){const e=ye().getBool("DEBUG");ye().set("DEBUG",!1);const t=this.abs(Kt(1e-8)).dataSync()[0];if(ye().set("DEBUG",e),t>0)return 32}return 16})),this.floatPrecisionValue}epsilon(){return this.floatPrecision()===32?bne:Cne}uploadToGPU(e){const t=this.texData.get(e),{shape:r,dtype:s,values:o,texture:i,usage:a,isPacked:l}=t;if(i!=null)return;const c=this.activeTimers!=null;let d;c&&(d=Cs());let p=t.texShape;if(p==null&&(p=qZ(r,l),t.texShape=p),o!=null){const m=dy(r);let y,v=p[1],b=p[0];const w=o instanceof Uint8Array||o instanceof Uint8ClampedArray;(l||!w)&&([v,b]=Rf(p[0],p[1])),l?y=new qee(m,w):y=new V2(m,w);const k=w?[b,v]:p,I=this.makeTensorInfo(k,s),N=this.texData.get(I.dataId);w?N.usage=xo.PIXELS:N.usage=xo.UPLOAD,N.texShape=k,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(I.dataId),v,b,o);const T=[[b,v]],O=this.runWebGLProgram(y,[I],s,T,!0),P=this.texData.get(O.dataId);t.texShape=P.texShape,t.isPacked=P.isPacked,t.usage=P.usage,ye().get("ENGINE_COMPILE_ONLY")?this.disposeData(O.dataId):(t.texture=P.texture,t.values=null,this.texData.delete(O.dataId)),this.disposeIntermediateTensorInfo(I),c&&(this.uploadWaitMs+=Cs()-d)}else{const m=this.acquireTexture(p,a,s,l);t.texture=m}}convertAndCacheOnCPU(e,t){const r=this.texData.get(e),{dtype:s}=r;return t!=null&&(r.values=Nne(t,s)),r.values}acquireTexture(e,t,r,s){if(this.numBytesInGPU+=this.computeBytes(e,r),!this.warnedAboutMemory&&this.numBytesInGPU>this.numMBBeforeWarning*1024*1024){const o=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${o} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(e,t,s)}computeBytes(e,t){return e[0]*e[1]*Py(t)}checkCompileCompletion(){for(const[,e]of Object.entries(this.binaryCache))this.checkCompletion_(e)}async checkCompileCompletionAsync(){const e=[];if(this.gpgpu.parallelCompilationExtension){for(const[,t]of Object.entries(this.binaryCache))e.push(this.checkCompletionAsync_(t));return Promise.all(e)}else{for(const[,t]of Object.entries(this.binaryCache)){const r=new Promise(s=>{try{this.checkCompletion_(t),s(!0)}catch(o){throw o}});e.push(r)}return Promise.all(e)}}async checkCompletionAsync_(e){return this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR)?this.checkCompletion_(e):(await cA(),this.checkCompletionAsync_(e))}checkCompletion_(e){if(this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.gl.LINK_STATUS)===!1)throw console.log(this.gpgpu.gl.getProgramInfoLog(e.webGLProgram)),this.gpgpu.gl.getShaderParameter(e.fragmentShader,this.gpgpu.gl.COMPILE_STATUS)===!1?(lF(e.source,this.gpgpu.gl.getShaderInfoLog(e.fragmentShader)),new Error("Failed to compile fragment shader.")):new Error("Failed to link vertex and fragment shaders.");return!0}getUniformLocations(){for(const e of Object.values(this.binaryCache)){this.gpgpu.buildVao(e.webGLProgram);const{variablesLocations:t,customUniformLocations:r,infLoc:s,nanLoc:o,outShapeLocation:i,outShapeStridesLocation:a,outTexShapeLocation:l}=fF(this.gpgpu,e.program,e.webGLProgram);e.variablesLocations=t,e.customUniformLocations=r,e.infLoc=s,e.nanLoc=o,e.outShapeLocation=i,e.outShapeStridesLocation=a,e.outTexShapeLocation=l}}createTensorFromGPUData(e,t,r){e.channels=e.channels||"RGBA";const{texture:s,height:o,width:i,channels:a}=e,l=na().backend;if(!l.gpgpu.gl.isTexture(s))throw new Error("The texture is invalid. Also, please make sure the texture and the TFJS WebGL backend are using the same canvas. If you want to use your own custom canvas, you have to create and use the custom TFJS WebGL backend created from the canvas through 'new tf.MathBackendWebGL(customCanvas)'.");const c=l.writeTexture(s,t,r,o,i,a);return na().makeTensorFromDataId(c,t,r,l)}}Vv.nextDataId=0;function Nne(n,e){if(e==="float32"||e==="complex64")return n;if(e==="int32"||e==="bool"){const t=e==="int32"?new Int32Array(n.length):new Uint8Array(n.length);for(let r=0;r<t.length;++r)t[r]=Math.round(n[r]);return t}else throw new Error(`Unknown dtype ${e}`)}iR()&&uR("webgl",()=>new Vv,2);const HI=`
if (isnan(a)) return a;
if (isnan(b)) return b;
`;class sh{constructor(e,t,r){this.variableNames=["A","B"],this.outputShape=gt(t,r),this.enableShapeUniforms=Kr(this.outputShape.length),this.userCode=`
float binaryOperation(float a, float b) {
${e}
}
void main() {
float a = getAAtOutCoords();
float b = getBAtOutCoords();
setOutput(binaryOperation(a, b));
}
`}}const mh=`
result.r = isNaN.r ? NAN : result.r;
result.g = isNaN.g ? NAN : result.g;
result.b = isNaN.b ? NAN : result.b;
result.a = isNaN.a ? NAN : result.a;
`;class Ff{constructor(e,t,r,s=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=gt(t,r);const o=this.outputShape.length;this.enableShapeUniforms=Kr(o);let i="";if(s)if(o===0||Se(this.outputShape)===1)i=`
result.y = 0.;
result.z = 0.;
result.w = 0.;
`;else if(i=`
${on(o)} coords = getOutputCoords();
`,o===1)this.enableShapeUniforms?i+=`
result.y = (coords + 1) >= outShape ? 0. : result.y;
result.z = 0.;
result.w = 0.;
`:i+=`
result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;
result.z = 0.;
result.w = 0.;
`;else{const l=ls("coords",o);this.enableShapeUniforms?i+=`
bool nextRowOutOfBounds =
(${l[o-2]} + 1) >= outShape[${o} - 2];
bool nextColOutOfBounds =
(${l[o-1]} + 1) >= outShape[${o} - 1];
result.y = nextColOutOfBounds ? 0. : result.y;
result.z = nextRowOutOfBounds ? 0. : result.z;
result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;
`:i+=`
bool nextRowOutOfBounds =
(${l[o-2]} + 1) >= ${this.outputShape[o-2]};
bool nextColOutOfBounds =
(${l[o-1]} + 1) >= ${this.outputShape[o-1]};
result.y = nextColOutOfBounds ? 0. : result.y;
result.z = nextRowOutOfBounds ? 0. : result.z;
result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;
`}this.userCode=`
vec4 binaryOperation(vec4 a, vec4 b) {
${e}
}
void main() {
vec4 a = getAAtOutCoords();
vec4 b = getBAtOutCoords();
vec4 result = binaryOperation(a, b);
${i}
setOutput(result);
}
`}}function Js(n){const{inputs:e,backend:t}=n,{x:r}=e;return t.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}const Tne={kernelName:Cg,backendName:"webgl",kernelFunc:Js};function ku(n){const{inputs:e,backend:t}=n,{real:r,imag:s}=e,o=t.makeTensorInfo(r.shape,"complex64"),i=t.texData.get(o.dataId),a=Js({inputs:{x:r},backend:t}),l=Js({inputs:{x:s},backend:t});return i.complexTensorInfos={real:a,imag:l},o}const Ene={kernelName:IS,backendName:"webgl",kernelFunc:ku};const kF="return (a < 0.) ? b * a : a;",IF=`
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
`;function Rne(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{alpha:o}=r,i=t.makeTensorInfo([],"float32",mu(o,"float32")),a=ye().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Ff(IF,s.shape,i.shape):new sh(kF,s.shape,i.shape),l=t.runWebGLProgram(a,[s,i],"float32");return t.disposeIntermediateTensorInfo(i),l}const Ane={kernelName:z1,backendName:"webgl",kernelFunc:Rne};const $F="return (a < 0.) ? b * a : a;",NF=`
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
`;function _ne(n){const{inputs:e,backend:t}=n,{x:r,alpha:s}=e,o=ye().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Ff(NF,r.shape,s.shape):new sh($F,r.shape,s.shape);return t.runWebGLProgram(o,[r,s],"float32")}const Dne={kernelName:sv,backendName:"webgl",kernelFunc:_ne};const Pf="if (isnan(x)) return x;";function zt({opSnippet:n,packedOpSnippet:e,cpuKernelImpl:t,dtype:r}){return({inputs:s,backend:o})=>{const{x:i}=s,a=o,l=r||i.dtype;if(a.shouldExecuteOnCPU([i])&&t!=null){const p=a.texData.get(i.dataId),m=t(p.values,l);return a.makeTensorInfo(i.shape,l,m)}const c=ye().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&e!=null;let d;return c?d=new tu(i.shape,e):d=new la(i.shape,n),a.runWebGLProgram(d,[i],l)}}function Or({opSnippet:n,packedOpSnippet:e,checkOutOfBounds:t=!1,supportsComplex:r=!1,cpuKernelImpl:s,dtype:o}){return({inputs:i,backend:a})=>{const{a:l,b:c}=i,d=a;if(r&&l.dtype==="complex64"){const v=d.texData.get(l.dataId),b=d.texData.get(c.dataId),[w,k]=[[v.complexTensorInfos.real,b.complexTensorInfos.real],[v.complexTensorInfos.imag,b.complexTensorInfos.imag]].map(N=>{const[T,A]=N,O={dataId:T.dataId,dtype:T.dtype,shape:l.shape},P={dataId:A.dataId,dtype:A.dtype,shape:c.shape},B=new sh(n,l.shape,c.shape);return d.runWebGLProgram(B,[O,P],Ys(T.dtype,A.dtype))}),I=ku({inputs:{real:w,imag:k},backend:d});return d.disposeIntermediateTensorInfo(w),d.disposeIntermediateTensorInfo(k),I}const p=o||Ys(l.dtype,c.dtype);if((l.dtype==="string"||c.dtype==="string"||d.shouldExecuteOnCPU([l,c]))&&s!=null){const v=d.texData.get(l.dataId).values,b=d.texData.get(c.dataId).values,w=l.dtype==="string"?il(v):v,k=l.dtype==="string"?il(b):b,[I,N]=s(l.shape,c.shape,w,k,p),T=d.makeTensorInfo(N,p),A=d.texData.get(T.dataId);return A.values=I,T}const m=ye().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&e!=null;let y;return m?y=new Ff(e,l.shape,c.shape,t):y=new sh(n,l.shape,c.shape),d.runWebGLProgram(y,[l,c],p)}}function Hm(n,e=!1){if(n==="linear")return e?pne:une;if(n==="relu")return e?gne:hne;if(n==="elu")return e?mne:cne;if(n==="relu6")return e?xne:dne;if(n==="prelu")return e?NF:$F;if(n==="leakyrelu")return e?IF:kF;if(n==="sigmoid")return e?yne:fne;throw new Error(`Activation ${n} has not been implemented for the WebGL backend.`)}class TF{constructor(e,t,r,s=!1,o=!1,i=!1,a=null,l=!1,c=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=r,this.enableShapeUniforms=Kr(this.outputShape.length);const d=s?e[1]:e[2],p=Math.ceil(d/2),m=s?"i * 2, rc.y":"rc.y, i * 2",y=o?"rc.z, i * 2":"i * 2, rc.z",v=s?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],b=o?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"];let w="",k="";a&&(l?w=`vec4 activation(vec4 a) {
vec4 b = getPreluActivationWeightsAtOutCoords();
${a}
}`:c?w=`vec4 activation(vec4 a) {
vec4 b = getLeakyreluAlphaAtOutCoords();
${a}
}`:w=`vec4 activation(vec4 x) {
${a}
}`,k="result = activation(result);");const I=i?"result += getBiasAtOutCoords();":"";i&&this.variableNames.push("bias"),l&&this.variableNames.push("preluActivationWeights"),c&&this.variableNames.push("leakyreluAlpha");let N="rc.x",T="rc.x";e[0]<t[0]?N=`imod(rc.x, ${e[0]})`:t[0]<e[0]&&(T=`imod(rc.x, ${t[0]})`),this.userCode=`
${w}
// Don't use uniform for sharedDimensionPacked for performance.
const float sharedDimension = ${p}.0;
vec4 dot2x2ARowBCol(ivec3 rc) {
vec4 result = vec4(0);
int batchA = ${N};
int batchB = ${T};
for (int i = 0; i < ${p}; i++) {
vec4 a = getMatrixA(batchA, ${m});
vec4 b = getMatrixB(batchB, ${y});
// These swizzled products need to be separately added.
// See: https://github.com/tensorflow/tfjs/issues/1735
result += (${v[0]} * ${b[0]});
result += (${v[1]} * ${b[1]});
}
return result;
}
void main() {
ivec3 rc = getOutputCoords();
vec4 result = dot2x2ARowBCol(rc);
${I}
${k}
setOutput(result);
}
`}}const K2={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"};class X2{constructor(e,t,r){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=gt(t,r),this.userCode=`
float binaryOpComplex(
float areal, float aimag, float breal, float bimag) {
${e}
}
void main() {
float areal = getARealAtOutCoords();
float aimag = getAImagAtOutCoords();
float breal = getBRealAtOutCoords();
float bimag = getBImagAtOutCoords();
setOutput(binaryOpComplex(areal, aimag, breal, bimag));
}
`}}const Y2="return a * b;";function qI(n){const{inputs:e,backend:t}=n,{a:r,b:s}=e,o=Ys(r.dtype,s.dtype);if(r.dtype==="complex64"){const a=t.texData.get(r.dataId),l=t.texData.get(s.dataId),c=new X2(K2.REAL,r.shape,s.shape),d=new X2(K2.IMAG,r.shape,s.shape),p=[{dataId:a.complexTensorInfos.real.dataId,dtype:a.complexTensorInfos.real.dtype,shape:r.shape},{dataId:a.complexTensorInfos.imag.dataId,dtype:a.complexTensorInfos.imag.dtype,shape:r.shape},{dataId:l.complexTensorInfos.real.dataId,dtype:l.complexTensorInfos.real.dtype,shape:s.shape},{dataId:l.complexTensorInfos.imag.dataId,dtype:l.complexTensorInfos.imag.dtype,shape:s.shape}],m=t.runWebGLProgram(c,p,"float32"),y=t.runWebGLProgram(d,p,"float32"),v=ku({inputs:{real:m,imag:y},backend:t});return t.disposeIntermediateTensorInfo(m),t.disposeIntermediateTensorInfo(y),v}if(t.shouldExecuteOnCPU([r,s])){const a=t.texData.get(r.dataId),l=t.texData.get(s.dataId),[c,d]=_te(r.shape,s.shape,a.values,l.values,o),p=t.makeTensorInfo(d,o),m=t.texData.get(p.dataId);return m.values=c,p}let i;return ye().getBool("WEBGL_PACK_BINARY_OPERATIONS")?i=new Ff(Y2,r.shape,s.shape):i=new sh(Y2,r.shape,s.shape),t.runWebGLProgram(i,[r,s],o)}const One={kernelName:Ag,backendName:"webgl",kernelFunc:qI};function Fne(n,e,t){const r=[mf(n.shape),...gf(n.shape)],s={dtype:n.dtype,shape:r,dataId:n.dataId},o=[mf(e),...gf(e)],i=new SF(o,r),a=!0,l=[r],c=t.runWebGLProgram(i,[s],n.dtype,l,a);return{dataId:c.dataId,shape:e,dtype:c.dtype}}function Ue(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{shape:o}=r,i=t,a=Se(s.shape),l=vE(o,a),c=Se(l);U(a===c,()=>`The new shape (${l}) has ${c} elements and the old shape (${s.shape}) has ${a} elements. The new shape and old shape must have the same number of elements.`);const d=i.texData.get(s.dataId);return d.isPacked&&!l1(s.shape,l)&&!(d.texture!==null&&l1(d.shape,l))?Fne(s,l,i):(i.incRef(s.dataId),{dataId:s.dataId,shape:l,dtype:s.dtype})}const Pne={kernelName:iv,backendName:"webgl",kernelFunc:Ue};class Q2{constructor(e,t){this.variableNames=["x"];const{windowSize:r,batchSize:s,inSize:o,outSize:i}=e;this.outputShape=[s,i];const a=Math.floor(r/4)*4,l=r%4;let c="sumValue += dot(values, ones);";if(t!=null){const p=1/t;c=`sumValue += dot(values * ${of(p)?p.toPrecision(2):p}, ones);`}let d="";o%r>0&&(d=`
if (inIdx < 0 || inIdx >= ${o}) {
return 0.0;
}
`),this.userCode=`
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
float getValue(int batch, int inIdx) {
${d}
return getX(batch, inIdx);
}
void main() {
ivec2 coords = getOutputCoords();
int batch = coords[0];
int outIdx = coords[1];
int inOffset = outIdx * ${r};
float sumValue = 0.0;
for (int i = 0; i < ${a}; i += 4) {
int inIdx = inOffset + i;
vec4 values = vec4(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2),
getValue(batch, inIdx + 3)
);
${c}
}
int inIdx = inOffset + ${a};
if (${l===1}) {
vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);
${c}
} else if (${l===2}) {
vec4 values = vec4(
getValue(batch, inIdx),
getValue(batch, inIdx + 1), 0.0, 0.0);
${c}
} else if (${l===3}) {
vec4 values = vec4(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2), 0.0);
${c}
}
setOutput(sumValue);
}
`}}class Lne{constructor(e,t){this.variableNames=["x"];const{windowSize:r,batchSize:s,inSize:o,outSize:i}=e;this.outputShape=[s,i];let a="0.0",l="";t==="prod"?a="1.0":t==="min"?(a="1.0 / 1e-20",l="min"):t==="max"&&(a="-1.0 / 1e-20",l="max");let c=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="sum"?c="sumValue":t==="prod"?c="prodValue":t==="all"?c="allValue":t==="any"&&(c="anyValue");const d=Math.floor(r/4)*4,p=r%4;let m=`
if (${t==="sum"}) {
sumValue += dot(values, ones);
} else if (${t==="prod"}) {
vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);
prodValue *= tmp[0] * tmp[1];
} else {
minMaxValue = ${l}(values, minMaxValue);
if (${t==="min"} || ${t==="max"}) {
minMaxValue = ${l}(values, minMaxValue);
bvec4 isNaN = isnan(values);
if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) {
minMaxValue = vec4(NAN);
}
}
}
`,y="vec4";t==="all"?(a="1.0",m=`
bool reducedAllValue = all(values);
float floatedReducedAllValue = float(reducedAllValue);
allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);
`,y="bvec4"):t==="any"&&(a="0.0",m=`
bool reducedAnyValue = any(values);
float floatedReducedAnyValue = float(reducedAnyValue);
anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);
`,y="bvec4");let v="";o%r>0&&(v=`
if (inIdx < 0 || inIdx >= ${o}) {
return initializationValue;
}
`),this.userCode=`
const float initializationValue = ${a};
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
float getValue(int batch, int inIdx) {
${v}
return getX(batch, inIdx);
}
void main() {
ivec2 coords = getOutputCoords();
int batch = coords[0];
int outIdx = coords[1];
int inOffset = outIdx * ${r};
vec4 minMaxValue = vec4(${a});
float prodValue = 1.0;
float sumValue = 0.0;
float allValue = 1.0;
float anyValue = 0.0;
for (int i = 0; i < ${d}; i += 4) {
int inIdx = inOffset + i;
${y} values = ${y}(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2),
getValue(batch, inIdx + 3)
);
${m}
}
int inIdx = inOffset + ${d};
if (${p===1}) {
${y} values = ${y}(
getValue(batch, inIdx),
initializationValue,
initializationValue,
initializationValue
);
${m}
} else if (${p===2}) {
${y} values = ${y}(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
initializationValue,
initializationValue
);
${m}
} else if (${p===3}) {
${y} values = ${y}(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2),
initializationValue
);
${m}
}
setOutput(${c});
}
`}}function Mne(n){const e=[];for(;e.length===0||e[e.length-1].outSize!==1;){const t=e.length?e[e.length-1].outSize:n[1],r=Nv(t);e.push({inSize:t,windowSize:r,outSize:Math.ceil(t/r)})}return e}function gh(n,e,t,r){const s=Mne(n.shape);let o=n;for(let i=0;i<s.length;i++){const{inSize:a,windowSize:l,outSize:c}=s[i];let d,p;t==="mean"?d=i===0?new Q2({windowSize:l,inSize:a,batchSize:n.shape[0],outSize:c},a):new Q2({windowSize:l,inSize:a,batchSize:n.shape[0],outSize:c}):d=new Lne({windowSize:l,inSize:a,batchSize:n.shape[0],outSize:c},t),p=o,o=r.runWebGLProgram(d,[o],e),p.dataId!==n.dataId&&r.disposeIntermediateTensorInfo(p)}return o}class zne{constructor(e,t){this.variableNames=["A"];const r=new Array(e.length);for(let i=0;i<r.length;i++)r[i]=e[t[i]];this.outputShape=r,this.rank=r.length;const s=on(this.rank),o=Bne(t);this.userCode=`
void main() {
${s} resRC = getOutputCoords();
setOutput(getA(${o}));
}
`}}function Bne(n){const e=n.length;if(e>6)throw Error(`Transpose for rank ${e} is not yet supported`);const t=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(e);for(let s=0;s<n.length;s++)r[n[s]]=t[s];return r.join()}class Une{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;const r=new Array(e.length);for(let d=0;d<r.length;d++)r[d]=e[t[d]];if(this.outputShape=r,this.rank=r.length,this.rank>6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const s=on(this.rank),o=CF("rc",this.rank),i=new Array(this.rank);for(let d=0;d<t.length;d++)i[t[d]]=o[d];const a=`vec2(${i.slice(-2).join()})`,l=`++${o[this.rank-1]} < ${r[this.rank-1]}`,c=`getChannel(getA(${i.join()}), ${a})`;this.userCode=`
void main() {
${s} rc = getOutputCoords();
vec4 result = vec4(0.);
result[0] = ${c};
if(${l}) {
result[1] = ${c};
}
--${o[this.rank-1]};
if(++${o[this.rank-2]} < ${r[this.rank-2]}) {
result[2] = ${c};
if(${l}) {
result[3] = ${c};
}
}
setOutput(result);
}
`}}function Gv(n,e,t){const r=ye().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Une(n.shape,e):new zne(n.shape,e);return t.runWebGLProgram(r,[n],n.dtype)}function Wne(n,e,t,r){const s=e,o=n.shape.length,i=Tt(s,n.shape);let a=i;const l=En(a,o),c=l!=null;let d=n;c&&(d=Gv(n,l,r),a=Wn(a.length,o)),Dr("sum",a,o);const[p,m]=yr(d.shape,a);let y=p;t&&(y=Yn(p,i));const v=Se(m),w=Se(n.shape)/v,k=Ue({inputs:{x:d},attrs:{shape:[w,v]},backend:r}),I=ok(n.dtype),N=gh(k,I,"sum",r),T=Ue({inputs:{x:N},attrs:{shape:y},backend:r});return r.disposeIntermediateTensorInfo(k),r.disposeIntermediateTensorInfo(N),c&&r.disposeIntermediateTensorInfo(d),T}function jv(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o,keepDims:i}=r;return Wne(s,o,i,t)}const Vne={kernelName:dv,backendName:"webgl",kernelFunc:jv};function cs(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{perm:o}=r,i=t,a=s.shape.length,l=new Array(a);for(let d=0;d<l.length;d++)l[d]=s.shape[o[d]];let c;if(i.shouldExecuteOnCPU([s])){const p=i.texData.get(s.dataId).values,m=jI(p,s.shape,s.dtype,o,l);c=i.makeTensorInfo(l,s.dtype);const y=i.texData.get(c.dataId);y.values=m}else c=Gv(s,o,i);return c}const Gne={kernelName:ef,backendName:"webgl",kernelFunc:cs};const EF=1e3;function u1({a:n,b:e,transposeA:t,transposeB:r,backend:s,bias:o=null,preluActivationWeights:i=null,leakyreluAlpha:a=0,activation:l=null}){const c=n.shape.length,d=e.shape.length,p=t?n.shape[c-2]:n.shape[c-1],m=r?e.shape[d-1]:e.shape[d-2],y=t?n.shape[c-1]:n.shape[c-2],v=r?e.shape[d-2]:e.shape[d-1],b=n.shape.slice(0,-2),w=e.shape.slice(0,-2),k=Se(b),I=Se(w),T=gt(n.shape.slice(0,-2),e.shape.slice(0,-2)).concat([y,v]);U(p===m,()=>`Error in matMul: inner shapes (${p}) and (${m}) of Tensors with shapes ${n.shape} and ${e.shape} and transposeA=${t} and transposeB=${r} must match.`);const A=t?[k,p,y]:[k,y,p],O=r?[I,v,m]:[I,m,v],P=Ue({inputs:{x:n},backend:s,attrs:{shape:A}}),B=Ue({inputs:{x:e},backend:s,attrs:{shape:O}}),z=[P,B],L=Math.max(k,I),_=t?P.shape[1]:P.shape[2],H=o!=null,Y=i!=null,re=l==="leakyrelu",te=l!=null?Hm(l,!0):null,le=H||Y||re||te!=null;let de;if((y===1||v===1)&&_>EF&&le===!1){let ie=P,se=B;t&&(ie=cs({inputs:{x:P},backend:s,attrs:{perm:[0,2,1]}}),z.push(ie)),r&&(se=cs({inputs:{x:B},backend:s,attrs:{perm:[0,2,1]}}),z.push(se));const V=v!==1,X=v===1;let xe=ie;V&&(xe=Ue({inputs:{x:ie},backend:s,attrs:{shape:[L,_,1]}}),z.push(xe));const Ie=v===1?2:1;let ke=se;X&&(ke=Ue({inputs:{x:se},backend:s,attrs:{shape:[L,1,_]}}),z.push(ke));const Ee=qI({inputs:{a:xe,b:ke},backend:s});de=jv({inputs:{x:Ee},backend:s,attrs:{axis:Ie,keepDims:!0}}),z.push(Ee)}else{const ie=Ys(n.dtype,e.dtype),se=new TF(A,O,[L,y,v],t,r,H,te,Y,re),V=[P,B];if(o!=null&&V.push(o),Y&&V.push(i),re){const X=s.makeTensorInfo([],"float32",mu(a,"float32"));V.push(X),z.push(X)}de=s.runWebGLProgram(se,V,ie)}const j=Ue({inputs:{x:de},backend:s,attrs:{shape:T}});z.push(de);for(const ie of z)s.disposeIntermediateTensorInfo(ie);return j}function jne(n){const{inputs:e,backend:t,attrs:r}=n,{a:s,b:o,bias:i,preluActivationWeights:a}=e,{transposeA:l,transposeB:c,activation:d,leakyreluAlpha:p}=r;return u1({a:s,b:o,transposeA:l,transposeB:c,backend:t,bias:i,preluActivationWeights:a,leakyreluAlpha:p,activation:d})}const Hne={kernelName:Ly,backendName:"webgl",kernelFunc:jne};const J2="return abs(x);";function qne(n){const{inputs:e,backend:t}=n,{x:r}=e;if(t.shouldExecuteOnCPU([r])&&r.dtype!=="complex64"){const o=t.texData.get(r.dataId),i=wF(o.values);return t.makeTensorInfo(r.shape,r.dtype,i)}let s;return ye().getBool("WEBGL_PACK_UNARY_OPERATIONS")?s=new tu(r.shape,J2):s=new la(r.shape,J2),t.runWebGLProgram(s,[r],r.dtype)}const Kne={kernelName:v1,backendName:"webgl",kernelFunc:qne};const Xne=Qo+`
if (abs(x) > 1.) {
return NAN;
}
return acos(x);
`,Yne=zt({opSnippet:Xne}),Qne={kernelName:ng,backendName:"webgl",kernelFunc:Yne};const Jne=Qo+`
if (x < 1.0) return NAN;
return log(x + sqrt(x * x - 1.0));`,Zne=zt({opSnippet:Jne}),ere={kernelName:rg,backendName:"webgl",kernelFunc:Zne};const Z2="return a + b;",tre=Or({opSnippet:Z2,packedOpSnippet:Z2,supportsComplex:!0,cpuKernelImpl:hte}),nre={kernelName:kf,backendName:"webgl",kernelFunc:tre};class rre{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map((o,i)=>`T${i}`);const r=[];this.variableNames.forEach(o=>{r.push(`float v${o} = get${o}AtOutCoords();`)});const s=this.variableNames.map(o=>`v${o}`).join(" + ");this.userCode=`
void main() {
${r.join(`
`)}
float result = ${s};
setOutput(result);
}
`}}class sre{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map((o,i)=>`T${i}`);const r=[];this.variableNames.forEach(o=>{r.push(`vec4 v${o} = get${o}AtOutCoords();`)});const s=this.variableNames.map(o=>`v${o}`).join(" + ");this.userCode=`
void main() {
${r.join(`
`)}
vec4 result = ${s};
setOutput(result);
}
`}}function Ny(n){const{inputs:e,backend:t}=n,r=e;if(r.length===1)return Js({inputs:{x:r[0]},backend:t});if(r.length>ye().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){const l=Math.floor(r.length/2),c=Ny({inputs:r.slice(0,l),backend:t}),d=Ny({inputs:r.slice(l),backend:t});return Ny({inputs:[c,d],backend:t})}const s=r.map(l=>l.dtype).reduce((l,c)=>Ys(l,c)),o=r.map(l=>l.shape),a=ye().getBool("WEBGL_PACK")?new sre(r[0].shape,o):new rre(r[0].shape,o);return t.runWebGLProgram(a,r,s)}const ore={kernelName:yS,backendName:"webgl",kernelFunc:Ny};function ire(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o,keepDims:i}=r,a=s.shape.length,l=Tt(o,s.shape);let c=l;const d=En(c,a);let p=s;d!=null&&(p=cs({inputs:{x:s},backend:t,attrs:{perm:d}}),c=Wn(c.length,a)),Dr("all",c,a);const[m,y]=yr(p.shape,c),v=Se(y),b=Ue({inputs:{x:p},backend:t,attrs:{shape:[-1,v]}}),w=gh(b,b.dtype,"all",t);let k;if(i){const I=Yn(m,l);k=Ue({inputs:{x:w},backend:t,attrs:{shape:I}})}else k=Ue({inputs:{x:w},backend:t,attrs:{shape:m}});return t.disposeIntermediateTensorInfo(b),t.disposeIntermediateTensorInfo(w),d!=null&&t.disposeIntermediateTensorInfo(p),k}const are={kernelName:vS,backendName:"webgl",kernelFunc:ire};function lre(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o,keepDims:i}=r,a=s.shape.length,l=Tt(o,s.shape);let c=l;const d=En(c,a);let p=s;d!=null&&(p=cs({inputs:{x:s},backend:t,attrs:{perm:d}}),c=Wn(c.length,a)),Dr("any",c,a);const[m,y]=yr(p.shape,c),v=Se(y),b=Ue({inputs:{x:p},backend:t,attrs:{shape:[-1,v]}}),w=gh(b,b.dtype,"any",t);let k;if(i){const I=Yn(m,l);k=Ue({inputs:{x:w},backend:t,attrs:{shape:I}})}else k=Ue({inputs:{x:w},backend:t,attrs:{shape:m}});return t.disposeIntermediateTensorInfo(b),t.disposeIntermediateTensorInfo(w),d!=null&&t.disposeIntermediateTensorInfo(p),k}const ure={kernelName:wS,backendName:"webgl",kernelFunc:lre};class cre{constructor(e,t,r){this.variableNames=["A"];const{windowSize:s,batchSize:o,outSize:i}=e;r||this.variableNames.push("bestIndicesA"),this.outputShape=[o,i];const a=t==="max"?">":"<",l=r?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=`
void main() {
ivec2 coords = getOutputCoords();
int batch = coords[0];
int outIdx = coords[1];
int inOffset = outIdx * ${s};
int bestIndex = inOffset;
float bestValue = getA(batch, bestIndex);
for (int i = 0; i < ${s}; i++) {
int inIdx = ${l};
float candidate = getA(batch, inIdx);
if (candidate ${a} bestValue) {
bestValue = candidate;
bestIndex = inIdx;
}
}
setOutput(float(bestIndex));
}
`}}class hre{constructor(e,t,r,s){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,U(e.length>2,()=>`Packed arg${r.charAt(0).toUpperCase()+r.slice(1)} supports only inputs with rank above 2.`);const o=e[e.length-1],i=Math.ceil(o/t);this.outputShape=e.slice(0,-1),i>1&&this.outputShape.push(i),s||this.variableNames.push("bestIndicesA");const a=this.outputShape,l=a.length,c=on(l),d=ls("coords",l);let p,m;if(i===1){m=l+1;const B=on(m);p=`
${B} sourceLocR = ${B}(${d.join()}, 0);
++${d[l-1]};
${B} sourceLocG = ${B}(${d.join()}, 0);
++${d[l-2]};
${B} sourceLocA = ${B}(${d.join()}, 0);
--${d[l-1]};
${B} sourceLocB = ${B}(${d.join()}, 0);
--${d[l-2]};`}else m=l,p=`
${c} sourceLocR = coords;
++${d[l-1]};
${c} sourceLocG = coords;
++${d[l-2]};
${c} sourceLocA = coords;
--${d[l-1]};
${c} sourceLocB = coords;
--${d[l-2]};`;const y=["x","y","z","w","u","v"].slice(0,m),v="."+y[m-1],b=y.map(B=>"int "+B),w=ls("sourceLocR",m-1).concat("inIdx.r"),k=ls("sourceLocG",m-1).concat("inIdx.g"),I=ls("sourceLocB",m-1).concat("inIdx.b"),N=ls("sourceLocA",m-1).concat("inIdx.a"),T=r==="max"?"greaterThan":"lessThan",A=s?"":`
inIdx = round(vec4(getBestIndicesAChannel(${w.join()}),
getBestIndicesAChannel(${k.join()}),
getBestIndicesAChannel(${I.join()}),
getBestIndicesAChannel(${N.join()})));`,O=`vec4(
getAChannel(${w.join()}),
hasNextCol ? getAChannel(${k.join()}) : 0.,
hasNextRow ? getAChannel(${I.join()}) : 0.,
hasNextRow && hasNextCol ? getAChannel(${N.join()}) : 0.)`,P=s?"":`
float getBestIndicesAChannel(${b.join()}) {
return getChannel(getBestIndicesA(${y.join()}),
vec2(${y.slice(-2).join()}));
}`;this.userCode=`
float getAChannel(${b.join()}) {
return getChannel(getA(${y.join()}),
vec2(${y.slice(-2).join()}));
}
${P}
void main() {
${c} coords = getOutputCoords();
bool hasNextCol = ${d[l-1]} < ${a[l-1]-1};
bool hasNextRow = ${d[l-2]} < ${a[l-2]-1};
${p}
ivec4 srcIdx = ivec4(sourceLocR${v}, sourceLocG${v},
sourceLocB${v}, sourceLocA${v}) * ${t};
ivec4 inIdx = srcIdx;
vec4 bestIndex = vec4(inIdx);
vec4 bestValue = ${O};
for (int i = 0; i < ${t}; i++) {
inIdx = srcIdx;
${A}
vec4 candidate = ${O};
bvec4 nan = isnan(candidate);
bvec4 replace = bvec4(
vec4(${T}(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));
bestValue = vec4(replace.x ? candidate.x : bestValue.x,
replace.y ? candidate.y : bestValue.y,
replace.z ? candidate.z : bestValue.z,
replace.w ? candidate.w : bestValue.w);
bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));
srcIdx++;
}
setOutput(bestIndex);
}
`}}function RF(n,e,t,r=null){let s=e.shape[0],o=e.shape[1];r!=null&&(s=r.shape[0],o=r.shape[1]);const i=Nv(o),a={windowSize:i,inSize:o,batchSize:s,outSize:Math.ceil(o/i)},l=new cre(a,t,r==null),c=[e];r!=null&&c.push(r);const d=n.runWebGLProgram(l,c,"int32");if(d.shape[1]===1)return d;const p=RF(n,e,t,d);return n.disposeIntermediateTensorInfo(d),p}function AF(n,e,t,r=null){const s=r!=null?r.shape:e.shape,o=s[s.length-1],i=Nv(o),a=new hre(s,i,t,r==null),l=r==null?[e]:[e,r],c=n.runWebGLProgram(a,l,"int32");if(c.shape.length===e.shape.length){const d=AF(n,e,t,c);return n.disposeIntermediateTensorInfo(c),d}return c}function _F(n,e,t,r){const s=[t];if(Dr("arg"+r.charAt(0).toUpperCase()+r.slice(1),s,e.shape.length),!ye().getBool("WEBGL_PACK_REDUCE")||e.shape.length<=2){const o=[],i=n.texData.get(e.dataId),a=i!==null&&i.isPacked;let l=e;a&&(l=n.unpackTensor(e),o.push(l));const[c,d]=yr(l.shape,s),p=Se(d),m=Ue({inputs:{x:l},backend:n,attrs:{shape:[-1,p]}});o.push(m);const y=RF(n,m,r);o.push(y);const v=Ue({inputs:{x:y},backend:n,attrs:{shape:c}});return o.forEach(b=>n.disposeIntermediateTensorInfo(b)),v}return AF(n,e,r)}function dre(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o}=r;let i=Tt(o,s.shape);const a=En(i,s.shape.length);let l=s;const c=[];a!=null&&(l=cs({inputs:{x:s},backend:t,attrs:{perm:a}}),c.push(l),i=Wn(i.length,l.shape.length)),Dr("argMax",[i[0]],l.shape.length);const d=_F(t,l,i[0],"max");return c.forEach(p=>t.disposeIntermediateTensorInfo(p)),d}const fre={kernelName:w1,backendName:"webgl",kernelFunc:dre};function pre(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o}=r;let i=Tt(o,s.shape);const a=En(i,s.shape.length);let l=s;const c=[];a!=null&&(l=cs({inputs:{x:s},backend:t,attrs:{perm:a}}),c.push(l),i=Wn(i.length,l.shape.length)),Dr("argMin",[i[0]],l.shape.length);const d=_F(t,l,i[0],"min");return c.forEach(p=>t.disposeIntermediateTensorInfo(p)),d}const mre={kernelName:b1,backendName:"webgl",kernelFunc:pre};const gre=Qo+`
if (abs(x) > 1.) {
return NAN;
}
return asin(x);
`,xre=zt({opSnippet:gre}),yre={kernelName:sg,backendName:"webgl",kernelFunc:xre};const vre=Qo+"return log(x + sqrt(x * x + 1.0));",wre=zt({opSnippet:vre}),bre={kernelName:og,backendName:"webgl",kernelFunc:wre};const Cre=Qo+`
return atan(x);
`,Sre=zt({opSnippet:Cre}),kre={kernelName:ig,backendName:"webgl",kernelFunc:Sre};const Ire=HI+`
return atan(a, b);
`,$re=`
vec4 result = atan(a, b);
bvec4 isNaNA = isnan(a);
bvec4 isNaNB = isnan(b);
bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);
`+mh+`
return result;
`,Nre=Or({opSnippet:Ire,packedOpSnippet:$re}),Tre={kernelName:lg,backendName:"webgl",kernelFunc:Nre};const Ere=Qo+`
if ((x < -1.0) || (x > 1.0)) return NAN;
return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,Rre=zt({opSnippet:Ere}),Are={kernelName:ag,backendName:"webgl",kernelFunc:Rre};class qm{constructor(e,t,r,s=!1,o=!1){if(this.variableNames=["x"],t==="avg"&&r)throw new Error("Cannot compute positions for average pool.");const i=e.filterWidth,a=e.strideHeight,l=e.strideWidth,c=e.dilationHeight,d=e.dilationWidth,p=e.effectiveFilterHeight,m=e.effectiveFilterWidth,y=e.padInfo.top,v=e.padInfo.left;this.outputShape=e.outShape;const b=t==="avg",w=`((batch * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`,k=`(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`;let I="0.0";if(b||(I="-1.0 / 1e-20"),r){this.userCode=`
const ivec2 strides = ivec2(${a}, ${l});
const ivec2 pads = ivec2(${y}, ${v});
void main() {
ivec4 coords = getOutputCoords();
int batch = coords[0];
int d = coords[3];
ivec2 xRCCorner = coords.yz * strides - pads;
int xRCorner = xRCCorner.x;
int xCCorner = xRCCorner.y;
// max/min x(?, ?, d) to get y(yR, yC, d).
// ? = to be determined
float minMaxValue = 0.0;
float minMaxValueFound = 0.0;
int minMaxPosition = 0;
float avgValue = 0.0;
for (int wR = 0; wR < ${p};
wR += ${c}) {
int xR = xRCorner + wR;
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
}
for (int wC = 0; wC < ${m};
wC += ${d}) {
int xC = xCCorner + wC;
if (xC < 0 || xC >= ${e.inWidth}) {
continue;
}
float value = getX(batch, xR, xC, d);
// If a min / max value has already been found, use it. If not,
// use the current value.
float currMinMaxValue = mix(
value, minMaxValue, minMaxValueFound);
if (value >= currMinMaxValue) {
minMaxValue = value;
minMaxValueFound = 1.0;
minMaxPosition = ${s?o?w:k:`wR * ${m} + wC`};
}
}
}
setOutput(float(minMaxPosition));
}
`;return}const N="max";let T=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="avg"&&(T="avgValue / max(count, 1.0)");const A=Math.floor(i/4)*4,O=i%4,P=`
if (${b}) {
avgValue += dot(values, ones);
} else {
minMaxValue = ${N}(values, minMaxValue);
}
`;this.userCode=`
const ivec2 strides = ivec2(${a}, ${l});
const ivec2 pads = ivec2(${y}, ${v});
const float initializationValue = ${I};
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
float count = 0.0;
float getValue(int batch, int xR, int xC, int d) {
if (xC < 0 || xC >= ${e.inWidth}) {
return initializationValue;
}
count += 1.0;
return getX(batch, xR, xC, d);
}
void main() {
ivec4 coords = getOutputCoords();
int batch = coords[0];
int d = coords[3];
ivec2 xRCCorner = coords.yz * strides - pads;
int xRCorner = xRCCorner.x;
int xCCorner = xRCCorner.y;
// max/min x(?, ?, d) to get y(yR, yC, d).
// ? = to be determined
vec4 minMaxValue = vec4(${I});
float avgValue = 0.0;
count = 0.0;
for (int wR = 0; wR < ${p};
wR += ${c}) {
int xR = xRCorner + wR;
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
}
for (int wC = 0; wC < ${A}; wC += 4) {
int xC = xCCorner + wC * ${d};
vec4 values = vec4(
getValue(batch, xR, xC, d),
getValue(batch, xR, xC + ${d}, d),
getValue(batch, xR, xC + 2 * ${d}, d),
getValue(batch, xR, xC + 3 * ${d}, d)
);
${P}
}
int xC = xCCorner + ${A};
if (${O===1}) {
vec4 values = vec4(
getValue(batch, xR, xC, d),
initializationValue,
initializationValue,
initializationValue
);
${P}
} else if (${O===2}) {
vec4 values = vec4(
getValue(batch, xR, xC, d),
getValue(batch, xR, xC + ${d}, d),
initializationValue,
initializationValue
);
${P}
} else if (${O===3}) {
vec4 values = vec4(
getValue(batch, xR, xC, d),
getValue(batch, xR, xC + ${d}, d),
getValue(batch, xR, xC + 2 * ${d}, d),
initializationValue
);
${P}
}
}
setOutput(${T});
}
`}}class KI{constructor(e,t,r,s=!1,o=!1){if(this.variableNames=["x"],t==="avg"&&r)throw new Error("Cannot compute positions for average pool.");const i=e.filterWidth,a=e.strideDepth,l=e.strideHeight,c=e.strideWidth,d=e.dilationDepth,p=e.dilationHeight,m=e.dilationWidth,y=e.effectiveFilterDepth,v=e.effectiveFilterHeight,b=e.effectiveFilterWidth,w=e.padInfo.front,k=e.padInfo.top,I=e.padInfo.left;this.outputShape=e.outShape;const N=t==="avg";let T="0.0";if(N||(T="-1.0 / 1e-20"),r){this.userCode=`
const ivec3 strides =
ivec3(${a}, ${l}, ${c});
const ivec3 pads = ivec3(${w}, ${k}, ${I});
void main() {
ivec5 coords = getOutputCoords();
int batch = coords.x;
int ch = coords.u;
ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;
int xDCorner = xCorner.x;
int xRCorner = xCorner.y;
int xCCorner = xCorner.z;
// max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).
// ? = to be determined
float minMaxValue = 0.0;
float minMaxValueFound = 0.0;
int minMaxPosition = 0;
for (int wD = 0; wD < ${y};
wD += ${d}) {
int xD = xDCorner + wD;
if (xD < 0 || xD >= ${e.inDepth}) {
continue;
}
for (int wR = 0; wR < ${v};
wR += ${p}) {
int xR = xRCorner + wR;
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
}
for (int wC = 0; wC < ${b};
wC += ${m}) {
int xC = xCCorner + wC;
if (xC < 0 || xC >= ${e.inWidth}) {
continue;
}
float value = getX(batch, xD, xR, xC, ch);
// If a min / max value has already been found, use it. If not,
// use the current value.
float currMinMaxValue = mix(
value, minMaxValue, minMaxValueFound);
if (value >= currMinMaxValue) {
minMaxValue = value;
minMaxValueFound = 1.0;
minMaxPosition = ${s?o?`(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`wD * ${v} * ${b} +
wR * ${b} + wC`};
}
}
}
}
setOutput(float(minMaxPosition));
}
`;return}const A="max";let O=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="avg"&&(O="avgValue / max(count, 1.0)");const P=Math.floor(i/4)*4,B=i%4,z=`
if (${N}) {
avgValue += dot(values, ones);
} else {
minMaxValue = ${A}(values, minMaxValue);
}
`;this.userCode=`
const ivec3 strides =
ivec3(${a}, ${l}, ${c});
const ivec3 pads = ivec3(${w}, ${k}, ${I});
const float initializationValue = ${T};
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
float count = 0.0;
float getValue(int batch, int xD, int xR, int xC, int ch) {
if (xC < 0 || xC >= ${e.inWidth}) {
return initializationValue;
}
count += 1.0;
return getX(batch, xD, xR, xC, ch);
}
void main() {
ivec5 coords = getOutputCoords();
int batch = coords.x;
int ch = coords.u;
ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;
int xDCorner = xCorner.x;
int xRCorner = xCorner.y;
int xCCorner = xCorner.z;
// max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).
// ? = to be determined
vec4 minMaxValue = vec4(${T});
float avgValue = 0.0;
count = 0.0;
for (int wD = 0; wD < ${y};
wD += ${d}) {
int xD = xDCorner + wD;
if (xD < 0 || xD >= ${e.inDepth}) {
continue;
}
for (int wR = 0; wR < ${v};
wR += ${p}) {
int xR = xRCorner + wR;
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
}
for (int wC = 0; wC < ${P}; wC += 4) {
int xC = xCCorner + wC * ${m};
vec4 values = vec4(
getValue(batch, xD, xR, xC, ch),
getValue(batch, xD, xR, xC + ${m}, ch),
getValue(batch, xD, xR, xC + 2 * ${m}, ch),
getValue(batch, xD, xR, xC + 3 * ${m}, ch)
);
${z}
}
int xC = xCCorner + ${P};
if (${B===1}) {
vec4 values = vec4(
getValue(batch, xD, xR, xC, ch),
initializationValue,
initializationValue,
initializationValue
);
${z}
} else if (${B===2}) {
vec4 values = vec4(
getValue(batch, xD, xR, xC, ch),
getValue(batch, xD, xR, xC + ${m}, ch),
initializationValue,
initializationValue
);
${z}
} else if (${B===3}) {
vec4 values = vec4(
getValue(batch, xD, xR, xC, ch),
getValue(batch, xD, xR, xC + ${m}, ch),
getValue(batch, xD, xR, xC + 2 * ${m}, ch),
initializationValue
);
${z}
}
}
}
setOutput(${O});
}
`}}function _re(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e;xx(s,"avgPool");const{filterSize:o,strides:i,pad:a,dimRoundingMode:l}=r,c=1;U(Hr(i,c),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const d=Xo(s.shape,o,i,c,a,l);if(d.filterWidth===1&&d.filterHeight===1&&Xt(d.inShape,d.outShape))return Js({inputs:{x:s},backend:t});const p=new qm(d,"avg",!1);return t.runWebGLProgram(p,[s],"float32")}const Dre={kernelName:C1,backendName:"webgl",kernelFunc:_re};function Ore(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{filterSize:o,strides:i,pad:a,dimRoundingMode:l,dataFormat:c}=r,d=[1,1,1],p=ll(s.shape,o,i,d,a,l,c),m=new KI(p,"avg",!1);return t.runWebGLProgram(m,[s],"float32")}const Fre={kernelName:S1,backendName:"webgl",kernelFunc:Ore};class Pre{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterHeight,r=e.filterWidth,s=e.strideHeight,o=e.strideWidth,i=e.dilationHeight,a=e.dilationWidth,l=e.effectiveFilterHeight,c=e.effectiveFilterWidth,d=l-1-e.padInfo.top,p=c-1-e.padInfo.left,m=1/(t*r);this.userCode=`
const ivec2 pads = ivec2(${d}, ${p});
const float avgMultiplier = float(${m});
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
ivec2 dyRCCorner = coords.yz - pads;
int dyRCorner = dyRCCorner.x;
int dyCCorner = dyRCCorner.y;
// Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
for (int wR = 0; wR < ${l};
wR += ${i}) {
float dyR = float(dyRCorner + wR) / ${s}.0;
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
for (int wC = 0; wC < ${c};
wC+= ${a}) {
float dyC = float(dyCCorner + wC) / ${o}.0;
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
float dyValue = getDy(b, idyR, idyC, d);
dotProd += dyValue * avgMultiplier;
}
}
setOutput(dotProd);
}
`}}class Lre{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterDepth,r=e.filterHeight,s=e.filterWidth,o=e.strideDepth,i=e.strideHeight,a=e.strideWidth,l=e.dilationDepth,c=e.dilationHeight,d=e.dilationWidth,p=e.effectiveFilterDepth,m=e.effectiveFilterHeight,y=e.effectiveFilterWidth,v=p-1-e.padInfo.front,b=m-1-e.padInfo.top,w=y-1-e.padInfo.left,k=1/(t*r*s);this.userCode=`
const ivec3 pads = ivec3(${v}, ${b}, ${w});
const float avgMultiplier = float(${k});
void main() {
ivec5 coords = getOutputCoords();
int batch = coords.x;
int ch = coords.u;
ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;
int dyDCorner = dyCorner.x;
int dyRCorner = dyCorner.y;
int dyCCorner = dyCorner.z;
// Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get
// dx(xD, xR, xC, ch).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
for (int wD = 0; wD < ${p};
wD += ${l}) {
float dyD = float(dyDCorner + wD) / ${o}.0;
if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {
continue;
}
int idyD = int(dyD);
for (int wR = 0; wR < ${m};
wR += ${c}) {
float dyR = float(dyRCorner + wR) / ${i}.0;
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||
fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
for (int wC = 0; wC < ${y};
wC += ${d}) {
float dyC = float(dyCCorner + wC) / ${a}.0;
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
float dyValue = getDy(batch, idyD, idyR, idyC, ch);
dotProd += dyValue * avgMultiplier;
}
}
}
setOutput(dotProd);
}
`}}function Mre(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,input:o}=e,i=o,{filterSize:a,strides:l,pad:c,dimRoundingMode:d}=r,p=[1,1,1],m=ll(i.shape,a,l,p,c,d),y=new Lre(m);return t.runWebGLProgram(y,[s],i.dtype)}const zre={kernelName:CS,backendName:"webgl",kernelFunc:Mre};function Bre(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,input:o}=e,i=o;xx([s,o],"avgPoolGrad");const{filterSize:a,strides:l,pad:c}=r,d=Xo(i.shape,a,l,1,c),p=new Pre(d);return t.runWebGLProgram(p,[s],i.dtype)}const Ure={kernelName:bS,backendName:"webgl",kernelFunc:Bre};function Wre(n){const{inputs:e,backend:t,attrs:r}=n,{a:s,b:o}=e,{transposeA:i,transposeB:a}=r;return u1({a:s,b:o,transposeA:i,transposeB:a,backend:t})}const Vre={kernelName:k1,backendName:"webgl",kernelFunc:Wre};class Gre{constructor(e,t,r,s,o,i){this.outputShape=[],this.variableNames=["x","mean","variance"],gt(e,t),gt(e,r);let a="0.0";s!=null&&(gt(e,s),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");let l="1.0";o!=null&&(gt(e,o),this.variableNames.push("scale"),l="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`
void main() {
float x = getXAtOutCoords();
float mean = getMeanAtOutCoords();
float variance = getVarianceAtOutCoords();
float offset = ${a};
float scale = ${l};
float inv = scale * inversesqrt(variance + float(${i}));
setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));
}
`}}class jre{constructor(e,t,r,s,o,i){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],gt(e,t),gt(e,r);let a="vec4(0.0)";s!=null&&(gt(e,s),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");let l="vec4(1.0)";o!=null&&(gt(e,o),this.variableNames.push("scale"),l="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`
void main() {
vec4 offset = ${a};
vec4 scale = ${l};
vec4 x = getXAtOutCoords();
vec4 mean = getMeanAtOutCoords();
vec4 variance = getVarianceAtOutCoords();
vec4 inv = scale * inversesqrt(variance + vec4(${i}));
setOutput((x - mean) * inv + offset);
}
`}}const Hre=({inputs:n,backend:e,attrs:t})=>{const{x:r,mean:s,variance:o,offset:i,scale:a}=n;U(s.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),U(i==null||s.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),U(a==null||s.shape.length===a.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let{varianceEpsilon:l}=t;l==null&&(l=.001);const c=[r,s,o];let d=null;i!=null&&(d=i.shape,c.push(i));let p=null;a!=null&&(p=a.shape,c.push(a));const m=ye().getBool("WEBGL_PACK_NORMALIZATION")?new jre(r.shape,s.shape,o.shape,d,p,l):new Gre(r.shape,s.shape,o.shape,d,p,l);return e.runWebGLProgram(m,c,c[0].dtype)},qre={kernelName:P1,backendName:"webgl",kernelFunc:Hre};class Kre{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;const t=on(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const r=Xre(this.rank);let s;const o=e.map((i,a)=>`sourceLoc.${MC[a]} = start[${a}] + coords.${MC[a]};`);s=`
${t} sourceLoc;
${t} coords = getOutputCoords();
${o.join(`
`)}
`,this.userCode=`
void main() {
${s}
setOutput(getSource(${r}));
}
`}}const MC=["x","y","z","w","u","v"];function Xre(n){if(n===1)return"sourceLoc";if(n<=6)return MC.slice(0,n).map(e=>"sourceLoc."+e).join(",");throw Error(`Slicing for rank ${n} is not yet supported`)}class Yre{constructor(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const t=on(this.rank),r=ls("coords",this.rank),s=ls("sourceLoc",this.rank),o=this.rank===1?"sourceLoc":`vec2(${s.slice(-2).join()})`,i=`getChannel(getSource(${s.join()}), ${o})`,a=`
result.x = ${i};
if (++${r[this.rank-1]} < ${e[this.rank-1]}) {
++${s[this.rank-1]};
result.y = ${i};
--${s[this.rank-1]};
}
`,l=this.rank===1?"":`
--${r[this.rank-1]};
if (++${r[this.rank-2]} < ${e[this.rank-2]}) {
++${s[this.rank-2]};
result.z = ${i};
if (++${r[this.rank-1]} < ${e[this.rank-1]}) {
++${s[this.rank-1]};
result.w = ${i};
}
}
`,c=this.rank<=4?`sourceLoc = coords +
${t}(${e.map((d,p)=>`start[${p}]`).join()});`:e.map((d,p)=>`${s[p]} = ${r[p]} + start[${p}];`).join(`
`);this.userCode=`
void main() {
${t} coords = getOutputCoords();
${t} sourceLoc;
${c}
vec4 result = vec4(0.);
${a}
${l}
setOutput(result);
}
`}}function Qre(n,e,t,r){const s=r.texData.get(n.dataId),o=r.makeTensorInfo(t,n.dtype),i=r.texData.get(o.dataId);Object.assign(i,s),i.refCount=1,i.shape=t,i.dtype=n.dtype;let a=Vk(e,tt(n.shape));s.slice&&(a+=s.slice.flatOffset),i.slice={flatOffset:a,origDataId:s.slice&&s.slice.origDataId||n.dataId};const l=r.dataRefCount.get(i.slice.origDataId)||1;return r.dataRefCount.set(i.slice.origDataId,l+1),o}function Lf(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{begin:o,size:i}=r,[a,l]=$v(s,o,i);if(Bk(s,a,l),Se(l)===0)return t.makeTensorInfo(l,s.dtype,[]);if(t.shouldExecuteOnCPU([s])||s.dtype==="string"){const p=t.texData.get(s.dataId),m=Vte(p.values,a,l,s.shape,s.dtype);return t.makeTensorInfo(l,s.dtype,m)}const{isPacked:c}=t.texData.get(s.dataId),d=Wk(s.shape,a,l);if(c||!d){const p=ye().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Yre(l):new Kre(l),m=[a];return t.runWebGLProgram(p,[s],s.dtype,m)}return t.uploadToGPU(s.dataId),Qre(s,a,l,t)}const Jre={kernelName:hv,backendName:"webgl",kernelFunc:Lf};const Zre=n=>{const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{blockShape:o,crops:i}=r;U(s.shape.length<=4,()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");const a=o.reduce((I,N)=>I*N),l=sx(s.shape,o,a),c=ox(l.length,o.length),d=ix(s.shape,o,a),p=Kk(i,o.length),m=Xk(d,i,o.length),y=[],v=Ue({inputs:{x:s},backend:t,attrs:{shape:l}}),b=cs({inputs:{x:v},backend:t,attrs:{perm:c}}),w=Ue({inputs:{x:b},backend:t,attrs:{shape:d}}),k=Lf({inputs:{x:w},backend:t,attrs:{begin:p,size:m}});return y.push(v),y.push(b),y.push(w),y.forEach(I=>t.disposeIntermediateTensorInfo(I)),k},ese={kernelName:I1,backendName:"webgl",kernelFunc:Zre};function tse(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,weights:o}=e,{size:i}=r,a=t.readSync(s.dataId),l=t.readSync(o.dataId),c=vF(a,l,o.dtype,o.shape,i);return t.makeTensorInfo([i],o.dtype,c)}const nse={kernelName:SS,backendName:"webgl",kernelFunc:tse};const rse=`
int r = int(a.r) & int(b.r);
int g = int(a.g) & int(b.g);
int rb = int(a.b) & int(b.b);
int ra = int(a.a) & int(b.a);
return vec4(r, g, rb, ra);
`,sse=`
return float(int(a.r) & int(b.r));
`;function ose(n){const{inputs:e,backend:t}=n,{a:r,b:s}=e,o=ye().getBool("WEBGL_PACK_BINARY_OPERATIONS"),i=ye().getNumber("WEBGL_VERSION");if(t.shouldExecuteOnCPU([r,s])||i===1){const l=t.texData.get(r.dataId).values,c=t.texData.get(s.dataId).values,[d,p]=fte(r.shape,s.shape,l,c,r.dtype),m=t.makeTensorInfo(p,r.dtype),y=t.texData.get(m.dataId);return y.values=d,m}let a;return o?a=new Ff(rse,r.shape,s.shape,!1):a=new sh(sse,r.shape,s.shape),t.runWebGLProgram(a,[r,s],r.dtype)}const ise={kernelName:kS,backendName:"webgl",kernelFunc:ose};function ase(n){const{inputs:e,backend:t}=n,{s0:r,s1:s}=e,o=t.readSync(r.dataId),i=t.readSync(s.dataId),a=gt(Array.from(o),Array.from(i));return t.makeTensorInfo([a.length],"int32",Int32Array.from(a))}const lse={kernelName:IE,backendName:"webgl",kernelFunc:ase};const use="return float(a != b);",DF=Or({opSnippet:use,cpuKernelImpl:Ote,dtype:"bool"}),cse={kernelName:Z1,backendName:"webgl",kernelFunc:DF};function vx(n){const{inputs:e,backend:t}=n,{input:r}=e,s=t.texData.get(r.dataId);return Js({inputs:{x:s.complexTensorInfos.real},backend:t})}const hse={kernelName:XS,backendName:"webgl",kernelFunc:vx};const dse="return float(int(x));";function fse(n,e){const t=new la(n.shape,dse),r=e.runWebGLProgram(t,[n],"int32");return{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}function zC(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{dtype:o}=r;if(o==="complex64"){if(s.dtype==="complex64")return Js({inputs:{x:s},backend:t});const i=gr(s.shape),a=zC({inputs:{x:s},backend:t,attrs:{dtype:"float32"}}),l=ku({inputs:{real:a,imag:i},backend:t});return i.dispose(),t.disposeIntermediateTensorInfo(a),l}if(s.dtype==="complex64"){const i=vx({inputs:{input:s},backend:t}),a=zC({inputs:{x:i},backend:t,attrs:{dtype:o}});return t.disposeIntermediateTensorInfo(i),a}if(!wE(s.dtype,o)){const i=Js({inputs:{x:s},backend:t});return{dataId:i.dataId,shape:i.shape,dtype:o}}if(t.shouldExecuteOnCPU([s])){const i=t.texData.get(s.dataId).values,[a,l,c]=pte(i,s.shape,s.dtype,o);return t.makeTensorInfo(a,l,c)}if(o==="int32")return fse(s,t);if(o==="bool"){const i=t.makeTensorInfo([],"bool",Vr("bool",1)),l=DF({inputs:{a:s,b:i},backend:t});return t.disposeIntermediateTensorInfo(i),l}throw new Error(`Error in Cast: failed to cast ${s.dtype} to ${o}`)}const pse={kernelName:ug,backendName:"webgl",kernelFunc:zC};const eT="return ceil(x);",mse=zt({opSnippet:eT,packedOpSnippet:eT,cpuKernelImpl:mte}),gse={kernelName:cg,backendName:"webgl",kernelFunc:mse};class xse{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode=`
void main() {
float value = getAAtOutCoords();
if (isnan(value)) {
setOutput(value);
return;
}
setOutput(clamp(value, minVal, maxVal));
}
`}}class yse{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode=`
void main() {
vec4 value = getAAtOutCoords();
if (any(isnan(value))) {
setOutput(value);
return;
}
setOutput(clamp(value, vec4(minVal), vec4(maxVal)));
}
`}}function vse(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{clipValueMin:o,clipValueMax:i}=r;let a;ye().getBool("WEBGL_PACK_CLIP")?a=new yse(s.shape):a=new xse(s.shape);const l=[[o],[i]];return t.runWebGLProgram(a,[s],s.dtype,l)}const wse={kernelName:hg,backendName:"webgl",kernelFunc:vse};class bse{constructor(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode=`
void main() {
float re = abs(getRealAtOutCoords());
float im = abs(getImagAtOutCoords());
float mx = max(re, im);
// sadly the length function in glsl is not underflow-safe
// (at least not on Intel GPUs). So the safe solution is
// to ensure underflow-safety in all cases.
setOutput(
mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))
);
}
`}}function tT(n,e){return{dataId:e.dataId,dtype:e.dtype,shape:n.shape}}function Cse(n){const{inputs:e,backend:t}=n,{x:r}=e,s=t.texData.get(r.dataId),o=new bse(r.shape),i=[tT(r,s.complexTensorInfos.real),tT(r,s.complexTensorInfos.imag)];return t.runWebGLProgram(o,i,i[0].dtype)}const Sse={kernelName:$1,backendName:"webgl",kernelFunc:Cse};class kse{constructor(e){this.outputShape=[],this.outputShape=da(e,1),this.variableNames=e.map((i,a)=>`T${a}`);const t=new Array(e.length-1);t[0]=e[0][1];for(let i=1;i<t.length;i++)t[i]=t[i-1]+e[i][1];const r=[`if (yC < ${t[0]}) setOutput(getT0(yR, yC));`];for(let i=1;i<t.length;i++){const a=t[i-1];r.push(`else if (yC < ${t[i]}) setOutput(getT${i}(yR, yC-${a}));`)}const s=t.length,o=t[t.length-1];r.push(`else setOutput(getT${s}(yR, yC-${o}));`),this.userCode=`
void main() {
ivec2 coords = getOutputCoords();
int yR = coords.x;
int yC = coords.y;
${r.join(`
`)}
}
`}}class Ise{constructor(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=da(e,t);const r=this.outputShape,s=r.length,o=on(s),i=ls("coords",s),a=["x","y","z","w","u","v"].slice(0,s);this.variableNames=e.map((b,w)=>`T${w}`);const l=new Array(e.length-1);l[0]=e[0][t];for(let b=1;b<l.length;b++)l[b]=l[b-1]+e[b][t];const c=a[t],d=a.slice(-2),p=a.join();let m=`if (${c} < ${l[0]}) {
return getChannel(
getT0(${p}), vec2(${d.join()}));
}`;for(let b=1;b<l.length;b++){const w=l[b-1];m+=`
if (${c} < ${l[b]} && ${c} >= ${l[b-1]}) {
return getChannel(
getT${b}(${my(a,c,w)}),
vec2(${my(d,c,w)}));
}`}const y=l.length,v=l[l.length-1];m+=`
return getChannel(
getT${y}(${my(a,c,v)}),
vec2(${my(d,c,v)}));`,this.userCode=`
float getValue(${a.map(b=>"int "+b)}) {
${m}
}
void main() {
${o} coords = getOutputCoords();
vec4 result = vec4(getValue(${i}), 0., 0., 0.);
${i[s-1]} = ${i[s-1]} + 1;
if (${i[s-1]} < ${r[s-1]}) {
result.g = getValue(${i});
}
${i[s-2]} = ${i[s-2]} + 1;
if (${i[s-2]} < ${r[s-2]}) {
result.a = getValue(${i});
}
${i[s-1]} = ${i[s-1]} - 1;
if (${i[s-2]} < ${r[s-2]} &&
${i[s-1]} < ${r[s-1]}) {
result.b = getValue(${i});
}
setOutput(result);
}
`}}function my(n,e,t){const r=n.indexOf(e);return n.map((o,i)=>i===r?`${o} - ${t}`:o).join()}function Hv(n){const{inputs:e,backend:t}=n,{input:r}=e,s=t.texData.get(r.dataId);return Js({inputs:{x:s.complexTensorInfos.imag},backend:t})}const $se={kernelName:US,backendName:"webgl",kernelFunc:Hv};function km(n,e,t){const r=n[0].dtype;if(r==="complex64"){const y=n.map(I=>vx({inputs:{input:I},backend:t})),v=n.map(I=>Hv({inputs:{input:I},backend:t})),b=km(y,e,t),w=km(v,e,t),k=ku({inputs:{real:b,imag:w},backend:t});return y.forEach(I=>t.disposeIntermediateTensorInfo(I)),v.forEach(I=>t.disposeIntermediateTensorInfo(I)),t.disposeIntermediateTensorInfo(b),t.disposeIntermediateTensorInfo(w),k}let s=t.shouldExecuteOnCPU(n);if(r==="string"&&(s=!0),s){const y=n.map(T=>{const O=[-1,Se(T.shape.slice(e))];return Ue({inputs:{x:T},backend:t,attrs:{shape:O}})}),v=y.map(T=>({vals:t.readSync(T.dataId),shape:T.shape})),b=da(y.map(T=>T.shape),1),w=y[0].shape[0]===1,k=gte(v,b,r,w),I=da(n.map(T=>T.shape),e),N=t.makeTensorInfo(I,r,k);return y.forEach(T=>t.disposeIntermediateTensorInfo(T)),N}const o=n.filter(y=>Se(y.shape)>0),i=ye().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&o[0].shape.length>1;if(o.length===1){const y=i?new la(n[0].shape,Yl):new tu(n[0].shape,Yl);return t.runWebGLProgram(y,n,r)}const a=ye().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(o.length>a){const y=[];for(let b=0;b<o.length;b+=a){const w=o.slice(b,b+a);y.push(km(w,e,t))}const v=km(y,e,t);for(const b of y)t.disposeIntermediateTensorInfo(b);return v}if(i){const y=new Ise(o.map(v=>v.shape),e);return t.runWebGLProgram(y,o,r)}const{tensors2D:l,outShape:c}=Nse(o,e,t),d=new kse(l.map(y=>y.shape)),p=t.runWebGLProgram(d,l,r);l.forEach(y=>t.disposeIntermediateTensorInfo(y));const m=Ue({inputs:{x:p},attrs:{shape:c},backend:t});return t.disposeIntermediateTensorInfo(p),m}function Nse(n,e,t){const r=da(n.map(o=>o.shape),e);return{tensors2D:n.map(o=>Ue({inputs:{x:o},attrs:{shape:[-1,Se(o.shape.slice(e))]},backend:t})),outShape:r}}function OF(n){const{inputs:e,backend:t,attrs:r}=n,{axis:s}=r,o=Tt(s,e[0].shape)[0],i=e.map(c=>c.shape);jk(i,o);const a=da(e.map(c=>c.shape),o);if(Se(a)===0)return t.makeTensorInfo(a,e[0].dtype,[]);const l=e.filter(c=>Se(c.shape)>0);return l.length===1?Js({inputs:{x:l[0]},backend:t}):km(l,o,t)}const Tse={kernelName:N1,backendName:"webgl",kernelFunc:OF};class FF{constructor(e,t=!1,r=null,s=!1,o=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;const i=e.padInfo.top,a=e.padInfo.left,l=e.strideHeight,c=e.strideWidth,d=e.dilationHeight,p=e.dilationWidth,m=e.filterHeight,y=e.filterWidth,v=Math.floor(e.inChannels/4)*4,b=e.inChannels%4,w=e.dataFormat==="channelsLast",k=w?1:2,I=w?2:3,N=w?3:1;let T="",A="";r&&(s?T=`float activation(float a) {
float b = getPreluActivationWeightsAtOutCoords();
${r}
}`:o?T=`float activation(float a) {
float b = getLeakyreluAlphaAtOutCoords();
${r}
}`:T=`
float activation(float x) {
${r}
}
`,A="result = activation(result);");const O=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),s&&this.variableNames.push("preluActivationWeights"),o&&this.variableNames.push("leakyreluAlpha"),this.userCode=`
${T}
const ivec2 strides = ivec2(${l}, ${c});
const ivec2 pads = ivec2(${i}, ${a});
void main() {
ivec4 coords = getOutputCoords();
int batch = coords[0];
int d2 = coords[${N}];
ivec2 xRCCorner =
ivec2(coords[${k}], coords[${I}]) * strides - pads;
int xRCorner = xRCCorner.x;
int xCCorner = xRCCorner.y;
// Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
for (int wR = 0; wR < ${m}; wR++) {
int xR = xRCorner + wR * ${d};
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
}
for (int wC = 0; wC < ${y}; wC++) {
int xC = xCCorner + wC * ${p};
if (xC < 0 || xC >= ${e.inWidth}) {
continue;
}
for (int d1 = 0; d1 < ${v}; d1 += 4) {
vec4 wValues = vec4(
getW(wR, wC, d1, d2),
getW(wR, wC, d1 + 1, d2),
getW(wR, wC, d1 + 2, d2),
getW(wR, wC, d1 + 3, d2)
);
if (${w}) {
vec4 xValues = vec4(
getX(batch, xR, xC, d1),
getX(batch, xR, xC, d1 + 1),
getX(batch, xR, xC, d1 + 2),
getX(batch, xR, xC, d1 + 3)
);
dotProd += dot(xValues, wValues);
} else {
vec4 xValues = vec4(
getX(batch, d1, xR, xC),
getX(batch, d1 + 1, xR, xC),
getX(batch, d1 + 2, xR, xC),
getX(batch, d1 + 3, xR, xC)
);
dotProd += dot(xValues, wValues);
}
}
if (${b===1}) {
if (${w}) {
dotProd +=
getX(batch, xR, xC, ${v}) *
getW(wR, wC, ${v}, d2);
} else {
dotProd +=
getX(batch, ${v}, xR, xC) *
getW(wR, wC, ${v}, d2);
}
} else if (${b===2}) {
vec2 wValues = vec2(
getW(wR, wC, ${v}, d2),
getW(wR, wC, ${v} + 1, d2)
);
if (${w}) {
vec2 xValues = vec2(
getX(batch, xR, xC, ${v}),
getX(batch, xR, xC, ${v} + 1)
);
dotProd += dot(xValues, wValues);
} else {
vec2 xValues = vec2(
getX(batch, ${v}, xR, xC),
getX(batch, ${v} + 1, xR, xC)
);
dotProd += dot(xValues, wValues);
}
} else if (${b===3}) {
vec3 wValues = vec3(
getW(wR, wC, ${v}, d2),
getW(wR, wC, ${v} + 1, d2),
getW(wR, wC, ${v} + 2, d2)
);
if (${w}) {
vec3 xValues = vec3(
getX(batch, xR, xC, ${v}),
getX(batch, xR, xC, ${v} + 1),
getX(batch, xR, xC, ${v} + 2)
);
dotProd += dot(xValues, wValues);
} else {
vec3 xValues = vec3(
getX(batch, ${v}, xR, xC),
getX(batch, ${v} + 1, xR, xC),
getX(batch, ${v} + 2, xR, xC)
);
dotProd += dot(xValues, wValues);
}
}
}
}
float result = dotProd;
${O}
${A}
setOutput(result);
}
`}}class Ese{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const t=e.padInfo.front,r=e.padInfo.top,s=e.padInfo.left,o=e.strideDepth,i=e.strideHeight,a=e.strideWidth,l=e.dilationDepth,c=e.dilationHeight,d=e.dilationWidth,p=e.filterDepth,m=e.filterHeight,y=e.filterWidth,v=Math.floor(e.inChannels/4)*4,b=e.inChannels%4;this.userCode=`
const ivec3 strides = ivec3(${o}, ${i}, ${a});
const ivec3 pads = ivec3(${t}, ${r}, ${s});
void main() {
ivec5 coords = getOutputCoords();
int batch = coords.x;
int d2 = coords.u;
ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;
int xFCorner = xFRCCorner.x;
int xRCorner = xFRCCorner.y;
int xCCorner = xFRCCorner.z;
// Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get
// y(yF, yR, yC, d2). ? = to be determined. : = across all
// values in that axis.
float dotProd = 0.0;
for (int wF = 0; wF < ${p}; wF++) {
int xF = xFCorner + wF * ${l};
if (xF < 0 || xF >= ${e.inDepth}) {
continue;
}
for (int wR = 0; wR < ${m}; wR++) {
int xR = xRCorner + wR * ${c};
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
}
for (int wC = 0; wC < ${y}; wC++) {
int xC = xCCorner + wC * ${d};
if (xC < 0 || xC >= ${e.inWidth}) {
continue;
}
for (int d1 = 0; d1 < ${v}; d1 += 4) {
vec4 xValues = vec4(
getX(batch, xF, xR, xC, d1),
getX(batch, xF, xR, xC, d1 + 1),
getX(batch, xF, xR, xC, d1 + 2),
getX(batch, xF, xR, xC, d1 + 3)
);
vec4 wValues = vec4(
getW(wF, wR, wC, d1, d2),
getW(wF, wR, wC, d1 + 1, d2),
getW(wF, wR, wC, d1 + 2, d2),
getW(wF, wR, wC, d1 + 3, d2)
);
dotProd += dot(xValues, wValues);
}
if (${b===1}) {
dotProd +=
getX(batch, xF, xR, xC, ${v}) *
getW(wF, wR, wC, ${v}, d2);
} else if (${b===2}) {
vec2 xValues = vec2(
getX(batch, xF, xR, xC, ${v}),
getX(batch, xF, xR, xC, ${v} + 1)
);
vec2 wValues = vec2(
getW(wF, wR, wC, ${v}, d2),
getW(wF, wR, wC, ${v} + 1, d2)
);
dotProd += dot(xValues, wValues);
} else if (${b===3}) {
vec3 xValues = vec3(
getX(batch, xF, xR, xC, ${v}),
getX(batch, xF, xR, xC, ${v} + 1),
getX(batch, xF, xR, xC, ${v} + 2)
);
vec3 wValues = vec3(
getW(wF, wR, wC, ${v}, d2),
getW(wF, wR, wC, ${v} + 1, d2),
getW(wF, wR, wC, ${v} + 2, d2)
);
dotProd += dot(xValues, wValues);
}
}
}
}
setOutput(dotProd);
}
`}}class PF{constructor(e,t=!1,r=null,s=!1,o=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=Kr(this.outputShape.length);const i=e.padInfo.left,a=e.strideWidth,l=e.dilationWidth,c=e.filterHeight,d=e.filterWidth,p=d;let m=`
int xR; int xC; int xCOffset;
vec4 wTexel; vec4 previous; vec4 final;`;for(let w=0;w<d;w++)m+=`
vec4 xTexelC${w*2};
int xTexelC${w*2}Ready;
vec4 xTexelC${w*2+1};
int xTexelC${w*2+1}Ready;
vec4 xC${w};`;m+=`
for (int r = 0; r < ${c}; r++) {
for (int d1 = 0; d1 < ${e.inChannels}; d1 += 2) {
`;for(let w=0;w<d;w++)m+=`
xTexelC${w*2} = vec4(0.0);
xTexelC${w*2}Ready = 0;
xTexelC${w*2+1} = vec4(0.0);
xTexelC${w*2+1}Ready = 0;
xC${w} = vec4(0.0);`;m+=`
xR = xRCorner + r * dilations[0];
if (xR >=0 && xR < inDims[0]) {
`;for(let w=0;w<(p+1)/2;w++){const k=w*2;if(m+=`
xC = xCCorner + ${k*l};
`,a===1){if(k<d&&(i%2===1?(m+=`
xCOffset = xC + 1;
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${k}Ready == 0) {
xTexelC${k} = getX(batch, xR, xCOffset, d1);
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if (xCOffset + 1 >= inDims[1]) {
xTexelC${k}.zw = vec2(0.0);
}
xTexelC${k}Ready = 1;
}
`,l===1&&k>0?m+=`
xC${k} = vec4(xTexelC${k-2}.zw, xTexelC${k}.xy);
`:m+=`
xCOffset = xC + 1 - 2;
if (xCOffset >= 0 && xCOffset < inDims[1]) {
previous = getX(batch, xR, xCOffset, d1);
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if (xCOffset + 1 >= inDims[1]) {
previous.zw = vec2(0.0);
}
xC${k} = vec4(previous.zw, xTexelC${k}.xy);
} else {
xC${k} = vec4(0.0, 0.0, xTexelC${k}.xy);
}
`):m+=`
if (xC >= 0 && xC < inDims[1] && xTexelC${k}Ready == 0) {
xTexelC${k} = getX(batch, xR, xC, d1);
if (xC + 1 >= inDims[1]) {
xTexelC${k}.zw = vec2(0.0);
}
xTexelC${k}Ready = 1;
}
xC${k} = xTexelC${k};
`,k+1<d)){const I=i%2===0?dS(l):l;l%2===0&&i%2===1||l%2!==0&&i%2!==1?(m+=`
xCOffset = xC + imod(pads[1], 2) + ${I};
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${k+1}Ready == 0) {
xTexelC${k+1} = getX(batch, xR, xCOffset, d1);
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if (xCOffset + 1 >= inDims[1]) {
xTexelC${k+1}.zw = vec2(0.0);
}
xTexelC${k+1}Ready = 1;
}
`,l>1?m+=`
xCOffset -= 2;
if (xCOffset >= 0 && xCOffset < inDims[1]) {
previous = getX(batch, xR, xCOffset, d1);
xC${k+1} = vec4(previous.zw, xTexelC${k+1}.xy);
} else {
xC${k+1} = vec4(0.0, 0.0, xTexelC${k+1}.xy);
}
`:m+=`
xC${k+1} = vec4(xTexelC${k}.zw, xTexelC${k+1}.xy);
`):I===1?m+=`
xC${k+1} = xTexelC${k};
`:m+=`
xCOffset = xC + ${I};
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${k+1}Ready == 0) {
xTexelC${k+1} = getX(batch, xR, xCOffset, d1);
if (xCOffset + 1 >= inDims[1]) {
xTexelC${k+1}.zw = vec2(0.0);
}
xTexelC${k+1}Ready = 1;
}
xC${k+1} = xTexelC${k+1};
`}}else k<d&&(i%2===1?(m+=`
xCOffset = xC + 1 - strides[1];
if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${k}Ready == 0) {
xTexelC${k} = getX(batch, xR, xCOffset, d1);
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if (xCOffset + 1 >= inDims[1]) {
xTexelC${k}.zw = vec2(0.0);
}
xTexelC${k}Ready = 1;
}
if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${k+1}Ready == 0) {
xTexelC${k+1} = getX(batch, xR, xC + 1, d1);
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if (xC + 2 >= inDims[1]) {
xTexelC${k+1}.zw = vec2(0.0);
}
xTexelC${k+1}Ready = 1;
}
xC${k} = vec4(xTexelC${k}.zw, xTexelC${k+1}.zw);
`,k+1<d&&(m+=`
final = vec4(0.0);
xCOffset = xC + 1 + strides[1];
if(xCOffset >= 0 && xCOffset < inDims[1]) {
final = getX(batch, xR, xCOffset, d1);
}
xC${k+1} = vec4(xTexelC${k+1}.xy, final.xy);
`)):(m+=`
if(xC >= 0 && xC < inDims[1] && xTexelC${k}Ready == 0) {
xTexelC${k} = getX(batch, xR, xC, d1);
if (xC + 1 >= inDims[1]) {
xTexelC${k}.zw = vec2(0.0);
}
xTexelC${k}Ready = 1;
}
xCOffset = xC + strides[1];
if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${k+1}Ready == 0) {
xTexelC${k+1} = getX(batch, xR, xCOffset, d1);
if (xCOffset + 1 >= inDims[1]) {
xTexelC${k+1}.zw = vec2(0.);
}
xTexelC${k+1}Ready = 1;
}
xC${k} = vec4(
xTexelC${k}.xy, xTexelC${k+1}.xy);
`,k+1<d&&(m+=`
xC${k+1} = vec4(xTexelC${k}.zw, xTexelC${k+1}.zw);
`)));k<d&&(m+=`
wTexel = getW(r, ${k}, d1, d2);
dotProd += xC${k}.xxzz * vec4(wTexel.xy, wTexel.xy);
if(d1 + 1 < ${e.inChannels}) {
dotProd += xC${k}.yyww * vec4(wTexel.zw, wTexel.zw);
}
`,k+1<d&&(m+=`
wTexel = getW(r, ${k+1}, d1, d2);
dotProd += xC${k+1}.xxzz * vec4(wTexel.xy, wTexel.xy);
if(d1 + 1 < ${e.inChannels}) {
dotProd += xC${k+1}.yyww * vec4(wTexel.zw, wTexel.zw);
}
`))}m+=`
}
`,m+=`
}
`,m+=`
}
`;let y="",v="";r&&(s?y=`vec4 activation(vec4 a) {
vec4 b = getPreluActivationWeightsAtOutCoords();
${r}
}`:o?y=`vec4 activation(vec4 a) {
vec4 b = getLeakyreluAlphaAtOutCoords();
${r}
}`:y=`vec4 activation(vec4 x) {
${r}
}`,v="result = activation(result);");const b=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),s&&this.variableNames.push("preluActivationWeights"),o&&this.variableNames.push("leakyreluAlpha"),this.userCode=`
${y}
void main() {
ivec4 coords = getOutputCoords();
int batch = coords.x;
ivec2 xRCCorner = coords.yz * strides - pads;
int d2 = coords.w;
int xRCorner = xRCCorner.x;
int xCCorner = xRCCorner.y;
//intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.
vec4 dotProd = vec4(0.000000000000001);
${m}
vec4 result = dotProd - vec4(0.000000000000001);
${b}
${v}
setOutput(result);
}
`}}class Rse{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec4"},{name:"pad",type:"ivec2"},{name:"stride",type:"ivec2"},{name:"dilation",type:"ivec2"},{name:"inChannels",type:"int"},{name:"itemsPerBlockRow",type:"int"},{name:"outWidth",type:"int"}],this.outputShape=e,this.enableShapeUniforms=Kr(this.outputShape.length);const{dataFormat:r}=t,s=hs(),o=r==="channelsLast",i=o?1:2,a=o?2:3,l=this.enableShapeUniforms?"if(blockIndex < outShape[2] && pos < outShape[1]) {":`if(blockIndex < ${e[2]} && pos < ${e[1]}) {`;let c="";for(let d=0;d<=1;d++)for(let p=0;p<=1;p++)c+=`
blockIndex = rc.z + ${p};
pos = rc.y + ${d};
${l}
offsetY = int(blockIndex / outWidth) * stride[0] - pad[0];
d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow);
if(d0 < inputShape[${i}] && d0 >= 0) {
// Use custom imod instead mod. On Intel GPU, mod may generate
// unexpected value.
// https://github.com/tensorflow/tfjs/issues/5447
offsetX = imod(blockIndex, outWidth) * stride[1] - pad[1];
d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) /
inChannels);
if(d1 < inputShape[${a}] && d1 >= 0) {
ch = imod(pos, inChannels);
if (${o}) {
innerDims = vec2(d1, ch);
result[${d*2+p}] = getChannel(
getA(rc.x, d0, int(innerDims.x),
int(innerDims.y)), innerDims);
} else {
innerDims = vec2(d0, d1);
result[${d*2+p}] = getChannel(
getA(rc.x, ch, int(innerDims.x),
int(innerDims.y)), innerDims);
}
}
}
}
`;this.userCode=`
void main() {
ivec3 rc = getOutputCoords();
vec4 result = vec4(0);
int blockIndex, pos, offsetY, d0, offsetX, d1, ch;
vec2 innerDims;
${c}
${s.output} = result;
}
`}}function c1(n,e){const t=n.length;return t>=3?e?[...n.slice(0,-3),n[t-3]*n[t-2],n[t-1]]:[...n.slice(0,-3),n[t-3],n[t-2]*n[t-1]]:!e&&t===1&&n[0]>1?[n[0],1]:null}function LF({x:n,filter:e,convInfo:t,backend:r,bias:s=null,preluActivationWeights:o=null,leakyreluAlpha:i=0,activation:a=null}){const l=n.shape,c=r.texData.get(n.dataId),d=t.inChannels,p=l[0]*l[1]*l[2],m=t.outChannels,y=t.dataFormat==="channelsLast",v=!1,b=!1;let w;const k=[];if(o!=null){const T=c1(o.shape,y);T!=null&&(o=Ue({inputs:{x:o},backend:r,attrs:{shape:T}}),k.push(o))}if(s!=null){const T=c1(s.shape,y);T!=null&&(s=Ue({inputs:{x:s},backend:r,attrs:{shape:T}}),k.push(s))}if(!((p===1||m===1)&&d>EF)&&c.isPacked&&y&&c.texture!=null&&l[2]%2!==0&&Xt(c.shape.slice(-3),l.slice(-3))){const T=l[0]*l[1]*(l[2]+1),A={dataId:n.dataId,shape:[1,T,t.inChannels],dtype:n.dtype},O=c.shape;c.shape=c.shape.slice(),c.shape[c.shape.length-2]++,U(l1(c.shape,A.shape),()=>`packed reshape ${c.shape} to ${A.shape} isn't free`);const P=Ue({inputs:{x:e},backend:r,attrs:{shape:[1,t.inChannels,t.outChannels]}});k.push(P);const B=u1({a:A,b:P,backend:r,transposeA:v,transposeB:b,bias:s,activation:a,preluActivationWeights:o,leakyreluAlpha:i}),z=r.texData.get(B.dataId);U(z.isPacked,()=>"batchMatMul result is expected to be packed"),c.shape=O,z.shape=t.outShape,w=Js({inputs:{x:B},backend:r}),w.shape=t.outShape,k.push(B)}else{const T=t.outHeight*t.outWidth,A=Ue({inputs:{x:n},backend:r,attrs:{shape:y?[t.batchSize,T,t.inChannels]:[t.batchSize,t.inChannels,T]}}),O=Ue({inputs:{x:e},backend:r,attrs:{shape:[1,t.inChannels,t.outChannels]}}),P=u1({a:y?A:O,b:y?O:A,transposeA:!y,transposeB:b,backend:r,bias:s,activation:a,preluActivationWeights:o,leakyreluAlpha:i});w=Ue({inputs:{x:P},backend:r,attrs:{shape:t.outShape}}),k.push(A),k.push(O),k.push(P)}for(const T of k)r.disposeIntermediateTensorInfo(T);return w}function MF({x:n,filter:e,convInfo:t,backend:r,bias:s=null,preluActivationWeights:o=null,leakyreluAlpha:i=0,activation:a=null}){const{filterWidth:l,filterHeight:c,inChannels:d,outWidth:p,outHeight:m,dataFormat:y}=t,v=y==="channelsLast",b=l*c*d,w=m*p,k=[t.batchSize,b,w],I=!0,N=!1,T=[];if(o!=null){const j=c1(o.shape,v);j!=null&&(o=Ue({inputs:{x:o},backend:r,attrs:{shape:j}}),T.push(o))}if(s!=null){const j=c1(s.shape,v);j!=null&&(s=Ue({inputs:{x:s},backend:r,attrs:{shape:j}}),T.push(s))}const A=Ue({inputs:{x:e},backend:r,attrs:{shape:[1,b,Se(e.shape)/b]}});T.push(A);const O=new Rse(k,t),P=[n.shape,[t.padInfo.top,t.padInfo.left],[t.strideHeight,t.strideWidth],[t.dilationHeight,t.dilationWidth],[t.inChannels],[t.filterWidth*t.inChannels],[t.outWidth]],B=r.runWebGLProgram(O,[n],"float32",P),z=Ue({inputs:{x:B},backend:r,attrs:{shape:k}});T.push(B),T.push(z);const L=s!=null,_=o!=null,H=a==="leakyrelu",Y=a?Hm(a,!0):null,re=new TF(v?z.shape:A.shape,v?A.shape:z.shape,v?[t.batchSize,w,t.outChannels]:[t.batchSize,t.outChannels,w],I,N,L,Y,_,H),te=v?[z,A]:[A,z];if(s&&te.push(s),_&&te.push(o),H){const j=r.makeTensorInfo([],"float32",mu(i,"float32"));te.push(j),T.push(j)}const le=r.runWebGLProgram(re,te,"float32"),de=Ue({inputs:{x:le},backend:r,attrs:{shape:t.outShape}});T.push(le);for(const j of T)r.disposeIntermediateTensorInfo(j);return de}function Ase(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:o}=e,{strides:i,pad:a,dataFormat:l,dilations:c,dimRoundingMode:d}=r,p=ul(l),m=_r(s.shape,o.shape,i,c,a,d,!1,p);let y;if(m.filterHeight===1&&m.filterWidth===1&&m.dilationHeight===1&&m.dilationWidth===1&&m.strideHeight===1&&m.strideWidth===1&&(m.padInfo.type==="SAME"||m.padInfo.type==="VALID"))y=LF({x:s,filter:o,convInfo:m,backend:t});else if(m.strideWidth<=2&&p==="channelsLast"&&ye().getBool("WEBGL_EXP_CONV")){const b=new PF(m),w=[[m.padInfo.top,m.padInfo.left],[m.strideHeight,m.strideWidth],[m.dilationHeight,m.dilationWidth],[m.inHeight,m.inWidth]];y=t.runWebGLProgram(b,[s,o],"float32",w)}else if(ye().getBool("WEBGL_CONV_IM2COL"))y=MF({x:s,filter:o,convInfo:m,backend:t});else{const b=new FF(m);y=t.runWebGLProgram(b,[s,o],"float32")}const v=Ue({inputs:{x:y},backend:t,attrs:{shape:m.outShape}});return t.disposeIntermediateTensorInfo(y),v}const _se={kernelName:T1,backendName:"webgl",kernelFunc:Ase};class Dse{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,r=e.strideWidth,s=e.padInfo.top,o=e.padInfo.left,i=e.dataFormat==="channelsLast";this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int wR = coords.x;
int wC = coords.y;
int d1 = coords.z;
int d2 = coords.w;
// Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
for (int b = 0; b < ${e.batchSize}; b++) {
for (int yR = 0; yR < ${e.outHeight}; yR++) {
int xR = wR + yR * ${t} - ${s};
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
}
for (int yC = 0; yC < ${e.outWidth}; yC++) {
int xC = wC + yC * ${r} - ${o};
if (xC < 0 || xC >= ${e.inWidth}) {
continue;
}
${i?`float dyValue = getDy(b, yR, yC, d2);
float xValue = getX(b, xR, xC, d1);
dotProd += (xValue * dyValue);`:`float dyValue = getDy(b, d2, yR, yC);
float xValue = getX(b, d1, xR, xC);
dotProd += (xValue * dyValue);`}
}
}
}
setOutput(dotProd);
}
`}}class Ose{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,r=e.filterWidth,s=e.strideHeight,o=e.strideWidth,i=e.dataFormat==="channelsLast",a=t-1-e.padInfo.top,l=r-1-e.padInfo.left,c=i?1:2,d=i?2:3,p=i?3:1;this.userCode=`
const ivec2 pads = ivec2(${a}, ${l});
void main() {
ivec4 coords = getOutputCoords();
int batch = coords[0];
int d1 = coords[${p}];
ivec2 dyCorner = ivec2(coords[${c}], coords[${d}]) - pads;
int dyRCorner = dyCorner.x;
int dyCCorner = dyCorner.y;
// Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
for (int wR = 0; wR < ${t}; wR++) {
float dyR = float(dyRCorner + wR) / ${s}.0;
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
int wRPerm = ${t} - 1 - wR;
for (int wC = 0; wC < ${r}; wC++) {
float dyC = float(dyCCorner + wC) / ${o}.0;
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
int wCPerm = ${r} - 1 - wC;
for (int d2 = 0; d2 < ${e.outChannels}; d2++) {
if (${i}) {
float xValue = getDy(batch, idyR, idyC, d2);
float wValue = getW(wRPerm, wCPerm, d1, d2);
dotProd += xValue * wValue;
} else {
float xValue = getDy(batch, d2, idyR, idyC);
float wValue = getW(wRPerm, wCPerm, d1, d2);
dotProd += xValue * wValue;
}
}
}
}
setOutput(dotProd);
}
`}}class Fse{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideDepth,r=e.strideHeight,s=e.strideWidth,o=e.padInfo.front,i=e.padInfo.top,a=e.padInfo.left;this.userCode=`
void main() {
ivec5 coords = getOutputCoords();
int wF = coords.x;
int wR = coords.y;
int wC = coords.z;
int d1 = coords.w;
int d2 = coords.u;
float dotProd = 0.0;
for (int b = 0; b < ${e.batchSize}; b++) {
for (int yF = 0; yF < ${e.outDepth}; yF++) {
int xF = wF + yF * ${t} - ${o};
if (xF < 0 || xF >= ${e.inDepth}) {
continue;
}
for (int yR = 0; yR < ${e.outHeight}; yR++) {
int xR = wR + yR * ${r} - ${i};
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
}
for (int yC = 0; yC < ${e.outWidth}; yC++) {
int xC = wC + yC * ${s} - ${a};
if (xC < 0 || xC >= ${e.inWidth}) {
continue;
}
float dyValue = getDy(b, yF, yR, yC, d2);
float xValue = getX(b, xF, xR, xC, d1);
dotProd += (xValue * dyValue);
}
}
}
}
setOutput(dotProd);
}
`}}class Pse{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterDepth,r=e.filterHeight,s=e.filterWidth,o=e.strideDepth,i=e.strideHeight,a=e.strideWidth,l=t-1-e.padInfo.front,c=r-1-e.padInfo.top,d=s-1-e.padInfo.left;this.userCode=`
const ivec3 pads = ivec3(${l}, ${c}, ${d});
void main() {
ivec5 coords = getOutputCoords();
int batch = coords.x;
int d1 = coords.u;
ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;
int dyFCorner = dyCorner.x;
int dyRCorner = dyCorner.y;
int dyCCorner = dyCorner.z;
float dotProd = 0.0;
for (int wF = 0; wF < ${t}; wF++) {
float dyF = float(dyFCorner + wF) / ${o}.0;
if (dyF < 0.0 || dyF >= ${e.outDepth}.0 || fract(dyF) > 0.0) {
continue;
}
int idyF = int(dyF);
int wFPerm = ${t} - 1 - wF;
for (int wR = 0; wR < ${r}; wR++) {
float dyR = float(dyRCorner + wR) / ${i}.0;
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||
fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
int wRPerm = ${r} - 1 - wR;
for (int wC = 0; wC < ${s}; wC++) {
float dyC = float(dyCCorner + wC) / ${a}.0;
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
int wCPerm = ${s} - 1 - wC;
for (int d2 = 0; d2 < ${e.outChannels}; d2++) {
float xValue = getDy(batch, idyF, idyR, idyC, d2);
float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);
dotProd += xValue * wValue;
}
}
}
}
setOutput(dotProd);
}
`}}function Lse(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,dy:o}=e,{strides:i,pad:a,dataFormat:l,dimRoundingMode:c,filterShape:d}=r,p=ul(l),m=_r(s.shape,d,i,1,a,c,!1,p),y=new Dse(m);return t.runWebGLProgram(y,[s,o],"float32")}const Mse={kernelName:$S,backendName:"webgl",kernelFunc:Lse};class zse{constructor(e){this.variableNames=["dy","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"strides",type:"vec2"}],this.outputShape=e.inShape,this.enableShapeUniforms=Kr(this.outputShape.length);const t=e.filterHeight,r=e.filterWidth,s=t-1-e.padInfo.top,o=r-1-e.padInfo.left;this.userCode=`
const ivec2 pads = ivec2(${s}, ${o});
void main() {
ivec4 coords = getOutputCoords();
int batch = coords[0];
int d1 = coords[3];
ivec2 dyCorner = ivec2(coords[1], coords[2]) - pads;
int dyRCorner = dyCorner.x;
int dyCCorner = dyCorner.y;
vec4 result = vec4(0.);
for (int wR = 0; wR < ${t}; wR++) {
float dyR = float(dyRCorner + wR) / strides[0];
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
int wRPerm = ${t} - 1 - wR;
for (int wC = 0; wC < ${r}; wC++) {
int wCPerm = ${r} - 1 - wC;
float dyC = float(dyCCorner + wC) / strides[1];
bool idyCVal = (dyC >= 0.0) && (dyC < ${e.outWidth}.0)
&& (fract(dyC) == 0.0);
int idyC = int(dyC);
float dyC2 = float(dyCCorner + wC + 1) / strides[1];
bool idyCVal2 = (dyC2 >= 0.0) && (dyC2 < ${e.outWidth}.0)
&& (fract(dyC2) == 0.0);
int idyC2 = int(dyC2);
if (idyCVal && idyCVal2) {
for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) {
vec4 wValue = getW(wRPerm, wCPerm, d1, d2);
vec4 dySample = getDy(batch, idyR, idyC, d2);
vec4 dySample2 = (idyC / 2 == idyC2 / 2) ?
dySample : getDy(batch, idyR, idyC2, d2);
vec2 dyValue = mod(float(idyC), 2.) == 0. ?
dySample.xy : dySample.zw;
result.xy += vec2(dot(dyValue, wValue.xy),
dot(dyValue, wValue.zw));
dyValue = mod(float(idyC2), 2.) == 0. ?
dySample2.xy : dySample2.zw;
result.zw += vec2(dot(dyValue, wValue.xy),
dot(dyValue, wValue.zw));
}
} else if (idyCVal) {
for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) {
vec4 wValue = getW(wRPerm, wCPerm, d1, d2);
vec4 dySample = getDy(batch, idyR, idyC, d2);
vec2 dyValue = mod(float(idyC), 2.) == 0. ?
dySample.xy : dySample.zw;
result.xy += vec2(dot(dyValue, wValue.xy),
dot(dyValue, wValue.zw));
}
} else if (idyCVal2) {
for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) {
vec4 wValue = getW(wRPerm, wCPerm, d1, d2);
vec4 dySample = getDy(batch, idyR, idyC2, d2);
vec2 dyValue = mod(float(idyC2), 2.) == 0. ?
dySample.xy : dySample.zw;
result.zw += vec2(dot(dyValue, wValue.xy),
dot(dyValue, wValue.zw));
}
}
}
}
setOutput(result);
}
`}}function Bse(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,filter:o}=e,{inputShape:i,strides:a,pad:l,dataFormat:c,dimRoundingMode:d}=r,p=ul(c),m=_r(i,o.shape,a,1,l,d,!1,p);if(ye().getBool("WEBGL_PACK_CONV2DTRANSPOSE")&&p==="channelsLast"){const y=[[m.strideHeight,m.strideWidth]],v=new zse(m);return t.runWebGLProgram(v,[s,o],"float32",y)}else{const y=new Ose(m);return t.runWebGLProgram(y,[s,o],"float32")}}const Use={kernelName:E1,backendName:"webgl",kernelFunc:Bse};function Wse(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:o}=e,{strides:i,pad:a,dilations:l}=r,c=xu(s.shape,o.shape,i,l,a),d=new Ese(c);return t.runWebGLProgram(d,[s,o],"float32")}const Vse={kernelName:R1,backendName:"webgl",kernelFunc:Wse};function Gse(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,dy:o}=e,{strides:i,pad:a,filterShape:l}=r,c=xu(s.shape,l,i,1,a),d=new Fse(c);return t.runWebGLProgram(d,[s,o],"float32")}const jse={kernelName:NS,backendName:"webgl",kernelFunc:Gse};function Hse(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,filter:o}=e,{pad:i,strides:a,inputShape:l}=r,c=xu(l,o.shape,a,1,i),d=new Pse(c);return t.runWebGLProgram(d,[s,o],"float32")}const qse={kernelName:TS,backendName:"webgl",kernelFunc:Hse};const Kse=Pf+`
return cos(x);
`,Xse=`
vec4 result = cos(x);
bvec4 isNaN = isnan(x);
${mh}
return result;
`,Yse=zt({opSnippet:Kse,packedOpSnippet:Xse}),Qse={kernelName:dg,backendName:"webgl",kernelFunc:Yse};const Jse=`
float e2x = exp(-x);
return (e2x + 1.0 / e2x) / 2.0;
`,Zse=zt({opSnippet:Jse}),eoe={kernelName:fg,backendName:"webgl",kernelFunc:Zse};class toe{constructor(e,t,r,s,o){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[i,a,l,c]=e,[d]=t,[p,m]=r;this.outputShape=[d,p,m,c];const y=s==="bilinear"?1:0,[v,b]=[`${a-1}.0`,`${l-1}.0`],[w,k,I]=p>1?[`${(a-1)/(p-1)}`,"(y2-y1) * height_ratio",`y1*${v} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${v}`],[N,T,A]=m>1?[`${(l-1)/(m-1)}`,"(x2-x1) * width_ratio",`x1*${b} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${b}`];this.userCode=`
const float height_ratio = float(${w});
const float width_ratio = float(${N});
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int y = coords[1];
int x = coords[2];
int d = coords[3];
// get box vals
float y1 = getBoxes(b,0);
float x1 = getBoxes(b,1);
float y2 = getBoxes(b,2);
float x2 = getBoxes(b,3);
// get image in batch index
int bInd = round(getBoxInd(b));
if(bInd < 0 || bInd >= ${i}) {
return;
}
float height_scale = ${k};
float width_scale = ${T};
float in_y = ${I};
if( in_y < 0.0 || in_y > ${v} ) {
setOutput(float(${o}));
return;
}
float in_x = ${A};
if( in_x < 0.0 || in_x > ${b} ) {
setOutput(float(${o}));
return;
}
vec2 sourceFracIndexCR = vec2(in_x,in_y);
if(${y} == 1) {
// Compute the four integer indices.
ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);
ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));
float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);
float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);
float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);
float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);
vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);
float top = topLeft + (topRight - topLeft) * fracCR.x;
float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;
float newValue = top + (bottom - top) * fracCR.y;
setOutput(newValue);
} else {
// Compute the coordinators of nearest neighbor point.
ivec2 sourceNearestCR = ivec2(floor(
sourceFracIndexCR + vec2(0.5,0.5)));
float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);
setOutput(newValue);
}
}
`}}const noe=n=>{const{inputs:e,backend:t,attrs:r}=n,{image:s,boxes:o,boxInd:i}=e,{cropSize:a,method:l,extrapolationValue:c}=r,d=new toe(s.shape,o.shape,a,l,c);return t.runWebGLProgram(d,[s,o,i],"float32")},roe={kernelName:RS,backendName:"webgl",kernelFunc:noe};var Km;(function(n){n.Prod="*",n.Sum="+"})(Km||(Km={}));class nT{constructor(e,t,r,s){this.op=e,this.outputShape=t,this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}];const o=this.outputShape.length,i=this.op===Km.Prod?"1.0":"0.0",a=r?i:`getX(${rT(o,"coords",this.op)})`,l=this.outputShape[this.outputShape.length-1];let c="",d="";r?(c=s?`end != ${l-1}`:"end != 0",d=s?"end + 1":"end - 1"):(c=s?`end + pow2 < ${l}`:"end >= pow2",d=s?"end + pow2":"end - pow2"),this.userCode=`
void main() {
${on(o)} coords = getOutputCoords();
int end = ${sT(o,"coords",this.op)};
float val = ${a};
int pow2 = int(pow(2.0, index));
if (${c}) {
int idx = ${d};
${sT(o,"coords",this.op)} = idx;
val ${this.op}= getX(${rT(o,"coords",this.op)});
}
setOutput(val);
}
`}}function rT(n,e,t){if(n===1)return`${e}`;if(n===2)return`${e}.x, ${e}.y`;if(n===3)return`${e}.x, ${e}.y, ${e}.z`;if(n===4)return`${e}.x, ${e}.y, ${e}.z, ${e}.w`;throw new Error(`Cumulative ${t} for rank ${n} is not yet supported`)}function sT(n,e,t){if(n===1)return`${e}`;if(n===2)return`${e}.y`;if(n===3)return`${e}.z`;if(n===4)return`${e}.w`;throw new Error(`Cumulative ${t} for rank ${n} is not yet supported`)}function zF(n,e,t,r,s,o){const i=e.shape.length,a=En([r],i);let l=e;a!=null&&(l=cs({inputs:{x:e},backend:t,attrs:{perm:a}}));const c=Wn(1,i)[0];if(c!==i-1)throw new Error(`WebGL cumprod shader expects an inner-most axis=${e.shape.length-1} but got axis=${r}`);const d=l.shape[c];let p=Js({inputs:{x:l},backend:t});for(let m=0;m<=Math.ceil(Math.log2(d))-1;m++){const y=new nT(n,l.shape,!1,o),v=[[m]],b=p;p=t.runWebGLProgram(y,[p],p.dtype,v),t.disposeIntermediateTensorInfo(b)}if(s){const m=new nT(n,l.shape,s,o),y=p;p=t.runWebGLProgram(m,[p],p.dtype),t.disposeIntermediateTensorInfo(y)}if(a!=null){const m=yu(a),y=cs({inputs:{x:p},backend:t,attrs:{perm:m}});return t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(l),y}return p}function soe(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o,exclusive:i,reverse:a}=r;return zF(Km.Prod,s,t,o,i,a)}const ooe={kernelName:ES,backendName:"webgl",kernelFunc:soe};function ioe(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o,exclusive:i,reverse:a}=r;return zF(Km.Sum,s,t,o,i,a)}const aoe={kernelName:A1,backendName:"webgl",kernelFunc:ioe};function loe(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,weights:o}=e,{size:i,binaryOutput:a}=r;if(s.shape.length===1){const l=t.readSync(s.dataId),c=t.readSync(o.dataId),d=vF(l,c,o.dtype,o.shape,i);return t.makeTensorInfo([i],o.dtype,d)}else if(s.shape.length===2){const l=t.bufferSync(s),c=t.bufferSync(o),d=dte(l,c,i,a);return t.makeTensorInfo(d.shape,o.dtype,d.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${s.shape.length}.`)}const uoe={kernelName:AS,backendName:"webgl",kernelFunc:loe};class coe{constructor(e,t,r){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,this.dataFormat=r,this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int h = ${this.getHeightCoordString()};
int w = ${this.getWidthCoordString()};
int d = ${this.getDepthCoordString()};
int in_h = h / ${t};
int offset_h = imod(h, ${t});
int in_w = w / ${t};
int offset_w = imod(w, ${t});
int offset_d = (offset_h * ${t} + offset_w) *
${this.getOutputDepthSize()};
int in_d = d + offset_d;
float result = ${this.getInputSamplingString()};
setOutput(result);
}
`}getHeightCoordString(){return this.dataFormat==="NHWC"?"coords[1]":"coords[2]"}getWidthCoordString(){return this.dataFormat==="NHWC"?"coords[2]":"coords[3]"}getDepthCoordString(){return this.dataFormat==="NHWC"?"coords[3]":"coords[1]"}getOutputDepthSize(){return this.dataFormat==="NHWC"?this.outputShape[3]:this.outputShape[1]}getInputSamplingString(){return this.dataFormat==="NHWC"?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"}}function hoe(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{blockSize:o,dataFormat:i}=r,a=s.shape[0],l=i==="NHWC"?s.shape[1]:s.shape[2],c=i==="NHWC"?s.shape[2]:s.shape[3],d=i==="NHWC"?s.shape[3]:s.shape[1],p=l*o,m=c*o,y=d/(o*o),v=i==="NHWC"?[a,p,m,y]:[a,y,p,m],b=new coe(v,o,i);return t.runWebGLProgram(b,[s],s.dtype)}const doe={kernelName:_S,backendName:"webgl",kernelFunc:hoe};class BF{constructor(e,t=!1,r=null,s=!1,o=!1){this.variableNames=["x","W"],this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=Kr(this.outputShape.length);const i=e.filterHeight,a=e.filterWidth,l=e.outChannels/e.inChannels;let c="",d="";r&&(s?c=`float activation(float a) {
float b = getPreluActivationWeightsAtOutCoords();
${r}
}`:o?c=`float activation(float a) {
float b = getLeakyreluAlphaAtOutCoords();
${r}
}`:c=`
float activation(float x) {
${r}
}
`,d="result = activation(result);");const p=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),s&&this.variableNames.push("preluActivationWeights"),o&&this.variableNames.push("leakyreluAlpha"),this.userCode=`
${c}
void main() {
ivec4 coords = getOutputCoords();
int batch = coords.x;
ivec2 xRCCorner = coords.yz * strides - pads;
int d2 = coords.w;
int d1 = d2 / ${l};
int q = d2 - d1 * ${l};
int xRCorner = xRCCorner.x;
int xCCorner = xRCCorner.y;
// Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
// TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.
for (int wR = 0; wR < ${i}; wR++) {
int xR = xRCorner + wR * dilations[0];
if (xR < 0 || xR >= inDims[0]) {
continue;
}
for (int wC = 0; wC < ${a}; wC++) {
int xC = xCCorner + wC * dilations[1];
if (xC < 0 || xC >= inDims[1]) {
continue;
}
float xVal = getX(batch, xR, xC, d1);
float wVal = getW(wR, wC, d1, q);
dotProd += xVal * wVal;
}
}
float result = dotProd;
${p}
${d}
setOutput(result);
}
`}}class UF{constructor(e,t=!1,r=null,s=!1,o=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=Kr(this.outputShape.length);const i=e.outChannels/e.inChannels,a=e.padInfo.left,l=e.strideWidth,c=e.dilationWidth,d=e.filterHeight,p=e.filterWidth,m=p;let y=`
int xR; int xC; int xCOffset;
vec4 wTexel; vec4 previous; vec4 final;`;for(let k=0;k<p;k++)y+=`
vec4 xTexelC${k*2};
int xTexelC${k*2}Ready;
vec4 xTexelC${k*2+1};
int xTexelC${k*2+1}Ready;
vec4 xC${k};`;y+=`
for (int r = 0; r < ${d}; r++) {
`;for(let k=0;k<p;k++)y+=`
xTexelC${k*2} = vec4(0.0);
xTexelC${k*2}Ready = 0;
xTexelC${k*2+1} = vec4(0.0);
xTexelC${k*2+1}Ready = 0;
xC${k} = vec4(0.0);`;y+=`
xR = xRCorner + r * dilations[0];
if (xR >=0 && xR < inDims[0]) {
`;for(let k=0;k<(m+1)/2;k++){const I=k*2;if(y+=`
xC = xCCorner + ${I*c};
`,l===1){if(I<p&&(a%2===1?(y+=`
xCOffset = xC + 1;
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${I}Ready == 0) {
xTexelC${I} = getX(batch, xR, xCOffset, d1);
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if (xCOffset + 1 >= inDims[1]) {
xTexelC${I}.zw = vec2(0.0);
}
xTexelC${I}Ready = 1;
}
`,c===1&&I>0?y+=`
xC${I} = vec4(xTexelC${I-2}.zw, xTexelC${I}.xy);
`:y+=`
xCOffset = xC + 1 - 2;
if (xCOffset >= 0 && xCOffset < inDims[1]) {
previous = getX(batch, xR, xCOffset, d1);
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if (xCOffset + 1 >= inDims[1]) {
previous.zw = vec2(0.0);
}
xC${I} = vec4(previous.zw, xTexelC${I}.xy);
} else {
xC${I} = vec4(0.0, 0.0, xTexelC${I}.xy);
}
`):y+=`
if (xC >= 0 && xC < inDims[1] && xTexelC${I}Ready == 0) {
xTexelC${I} = getX(batch, xR, xC, d1);
if (xC + 1 >= inDims[1]) {
xTexelC${I}.zw = vec2(0.0);
}
xTexelC${I}Ready = 1;
}
xC${I} = xTexelC${I};
`,I+1<p)){const N=a%2===0?dS(c):c;c%2===0&&a%2===1||c%2!==0&&a%2!==1?(y+=`
xCOffset = xC + imod(pads[1], 2) + ${N};
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${I+1}Ready == 0) {
xTexelC${I+1} = getX(batch, xR, xCOffset, d1);
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if (xCOffset + 1 >= inDims[1]) {
xTexelC${I+1}.zw = vec2(0.0);
}
xTexelC${I+1}Ready = 1;
}
`,c>1?y+=`
xCOffset -= 2;
if (xCOffset >= 0 && xCOffset < inDims[1]) {
previous = getX(batch, xR, xCOffset, d1);
xC${I+1} = vec4(previous.zw, xTexelC${I+1}.xy);
} else {
xC${I+1} = vec4(0.0, 0.0, xTexelC${I+1}.xy);
}
`:y+=`
xC${I+1} = vec4(xTexelC${I}.zw, xTexelC${I+1}.xy);
`):N===1?y+=`
xC${I+1} = xTexelC${I};
`:y+=`
xCOffset = xC + ${N};
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${I+1}Ready == 0) {
xTexelC${I+1} = getX(batch, xR, xCOffset, d1);
if (xCOffset + 1 >= inDims[1]) {
xTexelC${I+1}.zw = vec2(0.0);
}
xTexelC${I+1}Ready = 1;
}
xC${I+1} = xTexelC${I+1};
`}}else I<p&&(a%2===1?(y+=`
xCOffset = xC + 1 - strides[1];
if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${I}Ready == 0) {
xTexelC${I} = getX(batch, xR, xCOffset, d1);
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if (xCOffset + 1 >= inDims[1]) {
xTexelC${I}.zw = vec2(0.0);
}
xTexelC${I}Ready = 1;
}
if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${I+1}Ready == 0) {
xTexelC${I+1} = getX(batch, xR, xC + 1, d1);
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if (xC + 2 >= inDims[1]) {
xTexelC${I+1}.zw = vec2(0.0);
}
xTexelC${I+1}Ready = 1;
}
xC${I} = vec4(xTexelC${I}.zw, xTexelC${I+1}.zw);
`,I+1<p&&(y+=`
final = vec4(0.0);
xCOffset = xC + 1 + strides[1];
if(xCOffset >= 0 && xCOffset < inDims[1]) {
final = getX(batch, xR, xCOffset, d1);
}
xC${I+1} = vec4(xTexelC${I+1}.xy, final.xy);
`)):(y+=`
if(xC >= 0 && xC < inDims[1] && xTexelC${I}Ready == 0) {
xTexelC${I} = getX(batch, xR, xC, d1);
if (xC + 1 >= inDims[1]) {
xTexelC${I}.zw = vec2(0.0);
}
xTexelC${I}Ready = 1;
}
xCOffset = xC + strides[1];
if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${I+1}Ready == 0) {
xTexelC${I+1} = getX(batch, xR, xCOffset, d1);
if (xCOffset + 1 >= inDims[1]) {
xTexelC${I+1}.zw = vec2(0.);
}
xTexelC${I+1}Ready = 1;
}
xC${I} = vec4(
xTexelC${I}.xy, xTexelC${I+1}.xy);
`,I+1<p&&(y+=`
xC${I+1} = vec4(xTexelC${I}.zw, xTexelC${I+1}.zw);
`)));I<p&&(y+=`
wTexel = getW(r, ${I}, d1, q);
dotProd += xC${I} * vec4(wTexel.xz, wTexel.xz);
`,I+1<p&&(y+=`
wTexel = getW(r, ${I+1}, d1, q);
dotProd += xC${I+1} * vec4(wTexel.xz, wTexel.xz);
`))}y+=`
}
`,y+=`
}
`;let v="",b="";r&&(s?v=`vec4 activation(vec4 a) {
vec4 b = getPreluActivationWeightsAtOutCoords();
${r}
}`:o?v=`vec4 activation(vec4 a) {
vec4 b = getLeakyreluAlphaAtOutCoords();
${r}
}`:v=`vec4 activation(vec4 x) {
${r}
}`,b="result = activation(result);");const w=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),s&&this.variableNames.push("preluActivationWeights"),o&&this.variableNames.push("leakyreluAlpha"),this.userCode=`
${v}
void main() {
ivec4 coords = getOutputCoords();
int batch = coords.x;
ivec2 xRCCorner = coords.yz * strides - pads;
int d2 = coords.w;
int d1 = d2 / ${i};
int q = d2 - d1 * ${i};
int xRCorner = xRCCorner.x;
int xCCorner = xRCCorner.y;
//intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.
vec4 dotProd = vec4(0.000000000000001);
${y}
vec4 result = dotProd - vec4(0.000000000000001);
${w}
${b}
setOutput(result);
}
`}}function foe(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:o}=e,{strides:i,pad:a,dilations:l,dimRoundingMode:c}=r;let d=l;d==null&&(d=[1,1]),U(Hr(i,d),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${d}'`);const p=_r(s.shape,o.shape,i,d,a,c,!0);let m;ye().getBool("WEBGL_PACK_DEPTHWISECONV")&&p.strideWidth<=2&&p.outChannels/p.inChannels===1?m=new UF(p):m=new BF(p);const y=[[p.padInfo.top,p.padInfo.left],[p.strideHeight,p.strideWidth],[p.dilationHeight,p.dilationWidth],[p.inHeight,p.inWidth]];return t.runWebGLProgram(m,[s,o],"float32",y)}const poe={kernelName:_1,backendName:"webgl",kernelFunc:foe};class moe{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,r=e.strideWidth,s=e.padInfo.top,o=e.padInfo.left,i=e.outChannels/e.inChannels;this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int wR = coords.x;
int wC = coords.y;
int d1 = coords.z;
int dm = coords.w;
int d2 = d1 * ${i} + dm;
float dotProd = 0.0;
// TO DO: Vec4 over the batch size
for (int b = 0; b < ${e.batchSize}; b++) {
for (int yR = 0; yR < ${e.outHeight}; yR++) {
int xR = wR + yR * ${t} - ${s};
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
}
for (int yC = 0; yC < ${e.outWidth}; yC++) {
int xC = wC + yC * ${r} - ${o};
if (xC < 0 || xC >= ${e.inWidth}) {
continue;
}
float dyValue = getDy(b, yR, yC, d2);
float xValue = getX(b, xR, xC, d1);
dotProd += (xValue * dyValue);
}
}
}
setOutput(dotProd);
}
`}}class goe{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,r=e.filterWidth,s=e.strideHeight,o=e.strideWidth,i=t-1-e.padInfo.top,a=r-1-e.padInfo.left,l=e.outChannels/e.inChannels;this.userCode=`
const ivec2 pads = ivec2(${i}, ${a});
void main() {
ivec4 coords = getOutputCoords();
int batch = coords[0];
int d1 = coords[3];
ivec2 dyCorner = coords.yz - pads;
int dyRCorner = dyCorner.x;
int dyCCorner = dyCorner.y;
float dotProd = 0.0;
for (int wR = 0; wR < ${t}; wR++) {
float dyR = float(dyRCorner + wR) / ${s}.0;
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
int wRPerm = ${t} - 1 - wR;
for (int wC = 0; wC < ${r}; wC++) {
float dyC = float(dyCCorner + wC) / ${o}.0;
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
int wCPerm = ${r} - 1 - wC;
// TO DO: Vec4 over the channelMul
for (int dm = 0; dm < ${l}; dm++) {
int d2 = d1 * ${l} + dm;
float xValue = getDy(batch, idyR, idyC, d2);
float wValue = getW(wRPerm, wCPerm, d1, dm);
dotProd += xValue * wValue;
}
}
}
setOutput(dotProd);
}
`}}function xoe(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,dy:o}=e,{strides:i,dilations:a,pad:l,dimRoundingMode:c,filterShape:d}=r,p=_r(s.shape,d,i,a,l,c,!0),m=new moe(p);return t.runWebGLProgram(m,[s,o],"float32")}const yoe={kernelName:DS,backendName:"webgl",kernelFunc:xoe};function voe(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,filter:o}=e,{strides:i,dilations:a,pad:l,dimRoundingMode:c,inputShape:d}=r,p=_r(d,o.shape,i,a,l,c,!0),m=new goe(p);return t.runWebGLProgram(m,[s,o],"float32")}const woe={kernelName:OS,backendName:"webgl",kernelFunc:voe};class boe{constructor(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode=`
void main() {
ivec2 coords = getOutputCoords();
float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;
setOutput(val);
}
`}}function Coe(n){const{inputs:e,backend:t}=n,{x:r}=e,s=[...r.shape,...r.shape],o=Se(r.shape),i=Ue({inputs:{x:r},backend:t,attrs:{shape:[o]}}),a=new boe(o),l=t.runWebGLProgram(a,[i],i.dtype),c=Ue({inputs:{x:l},backend:t,attrs:{shape:s}});return t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(l),c}const Soe={kernelName:$E,backendName:"webgl",kernelFunc:Coe};class koe{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const{inHeight:t,inWidth:r,padInfo:s,strideHeight:o,strideWidth:i,filterHeight:a,filterWidth:l,dilationHeight:c,dilationWidth:d}=e,{top:p,left:m}=s;this.userCode=`
const ivec2 strides = ivec2(${o}, ${i});
const ivec2 pads = ivec2(${p}, ${m});
const float neg_infinity = -3.4e38;
void main() {
ivec4 coords = getOutputCoords();
int batch = coords.x;
int d1 = coords.w;
ivec2 outTopLeftCorner =
coords.yz * strides - pads;
int hBeg = outTopLeftCorner.x;
int wBeg = outTopLeftCorner.y;
float curVal = neg_infinity;
for (int h = 0; h < ${a}; h++) {
int hIn = hBeg + h * ${c};
if (hIn >= 0 && hIn < ${t}) {
for (int w = 0; w < ${l}; w++) {
int wIn = wBeg + w * ${d};
if (wIn >= 0 && wIn < ${r}) {
float xVal = getX(batch, hIn, wIn, d1);
float wVal = getW(h, w, d1);
float val = xVal + wVal;
if (val > curVal) {
curVal = val;
}
}
}
}
}
float result = curVal;
setOutput(result);
}
`}}function Ioe(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:o}=e,{strides:i,pad:a,dilations:l}=r,c=Zg(s.shape,o.shape,i,a,"NHWC",l);let d;const p=new koe(c);d=t.runWebGLProgram(p,[s,o],"float32");const m=Ue({inputs:{x:d},backend:t,attrs:{shape:c.outShape}});return t.disposeIntermediateTensorInfo(d),m}const $oe={kernelName:D1,backendName:"webgl",kernelFunc:Ioe};function Noe(n){const{inputs:e,backend:t,attrs:r}=n,{equation:s}=r,o=e,{allDims:i,summedDims:a,idDims:l}=rI(s,o.length);oI(i.length,l,o);const{path:c,steps:d}=iI(a,l),p=d.length;let m=null,y=i.length;const v=[];for(let b=0;b<p;++b){for(const w of d[b]){const{permutationIndices:k,expandDims:I}=sI(y,l[w]);let N;aI(k)?N=o[w]:(N=cs({inputs:{x:o[w]},backend:t,attrs:{perm:k}}),v.push(N));const T=N.shape.slice();for(let A=0;A<I.length;++A)T.splice(I[A],0,1);Xt(N.shape,T)||(N=Ue({inputs:{x:N},backend:t,attrs:{shape:T}}),v.push(N)),m===null?m=N:(m=qI({inputs:{a:N,b:m},backend:t}),v.push(m))}b<p-1&&(c[b]>=0&&(m=jv({inputs:{x:m},backend:t,attrs:{axis:c[b]-(i.length-y),keepDims:!1}}),v.push(m)),y--)}for(const b of v)b!==m&&t.disposeIntermediateTensorInfo(b);return m}const Toe={kernelName:FS,backendName:"webgl",kernelFunc:Noe};const Eoe="return (x >= 0.0) ? x : (exp(x) - 1.0);",Roe=`
vec4 result;
result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);
result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);
result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);
result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);
return result;
`,Aoe=zt({opSnippet:Eoe,packedOpSnippet:Roe}),_oe={kernelName:mg,backendName:"webgl",kernelFunc:Aoe};const Doe="return (b >= 0.0) ? a : a * (b + 1.0);",Ooe=`
vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));
return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));
`,Foe=n=>{const{inputs:e,backend:t}=n,{dy:r,y:s}=e,o=ye().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Ff(Ooe,r.shape,s.shape):new sh(Doe,r.shape,s.shape);return t.runWebGLProgram(o,[r,s],r.dtype)},Poe={kernelName:PS,backendName:"webgl",kernelFunc:Foe};const Loe=`
return vec4(equal(a, b));
`,Moe="return float(a == b);",zoe=Or({opSnippet:Moe,packedOpSnippet:Loe,dtype:"bool",cpuKernelImpl:xte}),Boe={kernelName:O1,backendName:"webgl",kernelFunc:zoe};const Uoe=`
// Error function is calculated approximately with elementary function.
// See "Handbook of Mathematical Functions with Formulas,
// Graphs, and Mathematical Tables", Abramowitz and Stegun.
float p = ${Yk};
float a1 = ${Qk};
float a2 = ${Jk};
float a3 = ${Zk};
float a4 = ${eI};
float a5 = ${tI};
float sign = sign(x);
x = abs(x);
float t = 1.0 / (1.0 + p * x);
return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));
`,Woe=zt({opSnippet:Uoe}),Voe={kernelName:gg,backendName:"webgl",kernelFunc:Woe};const Goe=Pf+`
return exp(x);
`,joe=`
vec4 result = exp(x);
bvec4 isNaN = isnan(x);
result.r = isNaN.r ? x.r : result.r;
result.g = isNaN.g ? x.g : result.g;
result.b = isNaN.b ? x.b : result.b;
result.a = isNaN.a ? x.a : result.a;
return result;
`,WF=zt({opSnippet:Goe,packedOpSnippet:joe,cpuKernelImpl:yte,dtype:"float32"}),Hoe={kernelName:xg,backendName:"webgl",kernelFunc:WF};function BC(n){const{inputs:e,attrs:t,backend:r}=n,{dim:s}=t,{input:o}=e,i=o.shape.length,a=o.shape.slice();let l=s;return s<0&&(U(-(i+1)<=s,()=>`Axis must be in the interval [${-(i+1)}, ${i}]`),l=i+s+1),a.splice(l,0,1),Ue({inputs:{x:o},backend:r,attrs:{shape:a}})}const qoe={kernelName:F1,backendName:"webgl",kernelFunc:BC};const oT="return exp(x) - 1.0;",Koe=zt({opSnippet:oT,packedOpSnippet:oT,cpuKernelImpl:vte}),Xoe={kernelName:yg,backendName:"webgl",kernelFunc:Koe};class iT{constructor(e,t,r){this.variableNames=["real","imag"];const s=t[1];this.outputShape=t;const o=r?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,i=r?`${s}.0`:"1.0";let a;if(e==="real")a="return real * expR - imag * expI;";else if(e==="imag")a="return real * expI + imag * expR;";else throw new Error(`FFT component must be either "real" or "imag", got ${e}.`);this.userCode=`
const float exponentMultiplier = ${o};
float unaryOpComplex(float real, float expR, float imag, float expI) {
${a}
}
float mulMatDFT(int batch, int index) {
float indexRatio = float(index) / float(${s});
float exponentMultiplierTimesIndexRatio =
exponentMultiplier * indexRatio;
float result = 0.0;
for (int i = 0; i < ${s}; i++) {
// x = (-2|2 * PI / N) * index * i;
float x = exponentMultiplierTimesIndexRatio * float(i);
float expR = cos(x);
float expI = sin(x);
float real = getReal(batch, i);
float imag = getImag(batch, i);
result +=
unaryOpComplex(real, expR, imag, expI) / ${i};
}
return result;
}
void main() {
ivec2 coords = getOutputCoords();
setOutput(mulMatDFT(coords[0], coords[1]));
}
`}}function VF(n,e,t){const r=t.texData.get(n.dataId),s=Se(n.shape),o=n.shape[n.shape.length-1],i=s/o,a=Ue({inputs:{x:n},backend:t,attrs:{shape:[i,o]}}),l=a.shape,c=new iT("real",l,e),d=new iT("imag",l,e),p=[{dataId:r.complexTensorInfos.real.dataId,dtype:r.complexTensorInfos.real.dtype,shape:l},{dataId:r.complexTensorInfos.imag.dataId,dtype:r.complexTensorInfos.imag.dtype,shape:l}],m=t.runWebGLProgram(c,p,"float32"),y=t.runWebGLProgram(d,p,"float32"),v=ku({inputs:{real:m,imag:y},backend:t});t.disposeIntermediateTensorInfo(m),t.disposeIntermediateTensorInfo(y);const b=Ue({inputs:{x:v},backend:t,attrs:{shape:n.shape}});return t.disposeIntermediateTensorInfo(a),t.disposeIntermediateTensorInfo(v),b}function Yoe(n){const{inputs:e,backend:t}=n,{input:r}=e;return VF(r,!1,t)}const Qoe={kernelName:LS,backendName:"webgl",kernelFunc:Yoe};class Joe{constructor(e,t){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode=`
void main() {
// Input can be obtained from uniform value.
setOutput(value);
}
`}}function wx(n){const{backend:e,attrs:t}=n,{shape:r,value:s}=t;let{dtype:o}=t;if(o=o||Cf(s),o==="string"){const i=Mn(o,Se(r));return i.fill(s),e.makeTensorInfo(r,o,i)}else{const i=new Joe(r,s),a=[[s]];return e.runWebGLProgram(i,[],o,a)}}const Zoe={kernelName:MS,backendName:"webgl",kernelFunc:wx};class eie{constructor(e){this.variableNames=["Image"],this.outputShape=[];const t=e[2];this.outputShape=e,this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int x = coords[2];
int coordX = ${t} - x - 1;
float outputValue;
if(coordX >= 0 && coordX < ${t}) {
outputValue = getImage(coords[0], coords[1], coordX, coords[3]);
} else {
outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);
}
setOutput(outputValue);
}
`}}const tie={kernelName:zS,backendName:"webgl",kernelFunc:({inputs:n,backend:e})=>{const{image:t}=n,r=e,s=new eie(t.shape);return r.runWebGLProgram(s,[t],t.dtype)}};const aT="return floor(x);",nie=zt({opSnippet:aT,packedOpSnippet:aT,cpuKernelImpl:wte}),rie={kernelName:vg,backendName:"webgl",kernelFunc:nie};const sie=`
float s = sign(a) * sign(b);
int ia = round(a);
int ib = round(b);
if (ib != 0) {
// Windows (D3D) wants guaranteed non-zero int division at compile-time.
return float(idiv(ia, ib, s));
} else {
return NAN;
}
`,oie=`
ivec4 ia = round(a);
ivec4 ib = round(b);
bvec4 cond = notEqual(ib, ivec4(0));
ivec4 result = ivec4(0);
vec4 s = sign(a) * sign(b);
// Windows (D3D) wants guaranteed non-zero int division at compile-time.
if (cond[0]) {
result[0] = idiv(ia[0], ib[0], s[0]);
}
if (cond[1]) {
result[1] = idiv(ia[1], ib[1], s[1]);
}
if (cond[2]) {
result[2] = idiv(ia[2], ib[2], s[2]);
}
if (cond[3]) {
result[3] = idiv(ia[3], ib[3], s[3]);
}
return vec4(result);
`,iie=Or({opSnippet:sie,packedOpSnippet:oie,dtype:"int32"}),aie={kernelName:wg,backendName:"webgl",kernelFunc:iie};class lie{constructor(e){this.variableNames=["A"];const t=hs(),[r,s]=e;this.outputShape=e,this.userCode=`
void main() {
ivec3 coords = getOutputCoords();
int texR = coords[0];
int texC = coords[1];
int depth = coords[2];
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${s}.0, ${r}.0);
vec4 values = ${t.texture2D}(A, uv);
float value;
if (depth == 0) {
value = values.r;
} else if (depth == 1) {
value = values.g;
} else if (depth == 2) {
value = values.b;
} else if (depth == 3) {
value = values.a;
}
setOutput(floor(value * 255.0 + 0.5));
}
`}}class uie{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const t=hs(),[r,s]=e;this.outputShape=e,this.userCode=`
void main() {
ivec3 coords = getOutputCoords();
int texR = coords[0];
int texC = coords[1];
int depth = coords[2];
vec4 result = vec4(0.);
for(int row=0; row<=1; row++) {
for(int col=0; col<=1; col++) {
texC = coords[1] + row;
depth = coords[2] + col;
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${s}.0, ${r}.0);
vec4 values = ${t.texture2D}(A, uv);
float value;
if (depth == 0) {
value = values.r;
} else if (depth == 1) {
value = values.g;
} else if (depth == 2) {
value = values.b;
} else if (depth == 3) {
value = values.a;
}
result[row * 2 + col] = floor(value * 255.0 + 0.5);
}
}
${t.output} = result;
}
`}}const cie={kernelName:uC,backendName:"webgl",kernelFunc:hie};let Gd,Bb=ye().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");function hie(n){const{inputs:e,backend:t,attrs:r}=n;let{pixels:s}=e;const{numChannels:o}=r,i=typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement,a=typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement,[l,c]=i?[s.videoWidth,s.videoHeight]:[s.width,s.height],d=[c,l],p=[c,l,o];if(a||i){const b=ye().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");(Gd==null||b!==Bb)&&(Bb=b,Gd=document.createElement("canvas").getContext("2d",{willReadFrequently:Bb})),Gd.canvas.width=l,Gd.canvas.height=c,Gd.drawImage(s,0,0,l,c),s=Gd.canvas}const m=t.makeTensorInfo(d,"int32");t.texData.get(m.dataId).usage=xo.PIXELS,t.gpgpu.uploadPixelDataToTexture(t.getTexture(m.dataId),s);const y=ye().getBool("WEBGL_PACK")?new uie(p):new lie(p),v=t.runWebGLProgram(y,[m],"int32");return t.disposeData(m.dataId),v}function die(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:o,bias:i,preluActivationWeights:a}=e,{strides:l,pad:c,dataFormat:d,dilations:p,dimRoundingMode:m,activation:y,leakyreluAlpha:v}=r,b=ul(d),w=_r(s.shape,o.shape,l,p,c,m,!1,b);let k;const I=[],N=i!=null,T=a!=null,A=y==="leakyrelu",O=()=>{const B=[s,o],z=(L,_)=>{if(_==="NCHW"&&L.shape.length===1&&L.shape[0]!==1){const H=Ue({inputs:{x:L},backend:t,attrs:{shape:[L.shape[0],1,1]}});return I.push(H),H}return L};if(N&&B.push(z(i,d)),T&&B.push(z(a,d)),A){const L=t.makeTensorInfo([],"float32",mu(v,"float32"));B.push(L),I.push(L)}return B};if(w.filterHeight===1&&w.filterWidth===1&&w.dilationHeight===1&&w.dilationWidth===1&&w.strideHeight===1&&w.strideWidth===1&&(w.padInfo.type==="SAME"||w.padInfo.type==="VALID"))k=LF({x:s,filter:o,convInfo:w,backend:t,bias:i,activation:y,preluActivationWeights:a,leakyreluAlpha:v});else if(w.strideWidth<=2&&b==="channelsLast"&&ye().getBool("WEBGL_EXP_CONV")){const B=y?Hm(y,!0):null,z=new PF(w,N,B,T,A),L=[[w.padInfo.top,w.padInfo.left],[w.strideHeight,w.strideWidth],[w.dilationHeight,w.dilationWidth],[w.inHeight,w.inWidth]],_=O();k=t.runWebGLProgram(z,_,"float32",L)}else if(ye().getBool("WEBGL_CONV_IM2COL"))k=MF({x:s,filter:o,convInfo:w,backend:t,bias:i,activation:y,preluActivationWeights:a,leakyreluAlpha:v});else{const B=y?Hm(y,!1):null,z=new FF(w,N,B,T,A),L=O();k=t.runWebGLProgram(z,L,"float32")}const P=Ue({inputs:{x:k},backend:t,attrs:{shape:w.outShape}});return I.push(k),I.forEach(B=>t.disposeIntermediateTensorInfo(B)),P}const fie={kernelName:My,backendName:"webgl",kernelFunc:die};function pie(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,filter:o,bias:i,preluActivationWeights:a}=e,{strides:l,pad:c,dilations:d,dimRoundingMode:p,activation:m,leakyreluAlpha:y}=r,v=[];let b=d;b==null&&(b=[1,1]),U(Hr(l,b),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${l} and dilations '${b}'`);const w=_r(s.shape,o.shape,l,b,c,p,!0),k=ye().getBool("WEBGL_PACK_DEPTHWISECONV")&&w.strideWidth<=2&&w.outChannels/w.inChannels===1,I=m?Hm(m,k):null,N=[s,o],T=i!=null,A=a!=null,O=m==="leakyrelu";if(T&&N.push(i),A&&N.push(a),O){const L=t.makeTensorInfo([],"float32",mu(y,"float32"));N.push(L),v.push(L)}let P;k?P=new UF(w,T,I,A,O):P=new BF(w,T,I,A,O);const B=[[w.padInfo.top,w.padInfo.left],[w.strideHeight,w.strideWidth],[w.dilationHeight,w.dilationWidth],[w.inHeight,w.inWidth]],z=t.runWebGLProgram(P,N,"float32",B);return v.forEach(L=>t.disposeIntermediateTensorInfo(L)),z}const mie={kernelName:jE,backendName:"webgl",kernelFunc:pie};class gie{constructor(e,t,r,s){this.sliceDim=e,this.strides=t,this.paramsShape=s,this.variableNames=["x","indices"],this.outputShape=r;const o=on(r.length);let i=`
int index;`;for(let a=0;a<this.sliceDim;a++)i+=`
index = round(getIndices(coords[0], ${a}));
out_of_bounds = out_of_bounds || index < 0;
out_of_bounds = out_of_bounds || index >= ${this.paramsShape[a]};
flattenIndex += index * ${this.strides[a]};`;this.userCode=`
void main() {
${o} coords = getOutputCoords();
int flattenIndex = 0;
bool out_of_bounds = false;
${i}
setOutput(out_of_bounds ? 0.0 : getX(flattenIndex, coords[1]));
}
`}}function xie(n){const{inputs:e,backend:t}=n,{params:r,indices:s}=e,o=s.shape,i=o[o.length-1],a=Se(r.shape),[l,c,d,p]=zk(r,s),m=Ue({inputs:{x:s},backend:t,attrs:{shape:[c,i]}}),y=Ue({inputs:{x:r},backend:t,attrs:{shape:[Se(r.shape)/d,d]}});if(t.shouldExecuteOnCPU([r,s])||r.dtype==="string"){const k=t.readSync(s.dataId),I=t.bufferSync(r),N=bte(k,I,r.dtype,c,i,d,p,r.shape,a);return t.makeTensorInfo(l,r.dtype,N.values)}const v=new gie(i,p,[c,d],r.shape),b=t.runWebGLProgram(v,[y,m],y.dtype),w=Ue({inputs:{x:b},backend:t,attrs:{shape:l}});return t.disposeIntermediateTensorInfo(m),t.disposeIntermediateTensorInfo(y),t.disposeIntermediateTensorInfo(b),w}const yie={kernelName:NE,backendName:"webgl",kernelFunc:xie};class vie{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;const r=on(this.rank),s=wie(e);this.userCode=`
void main() {
${r} resRC = getOutputCoords();
int index = int(getIndices(resRC.x, resRC.z));
float inBounds = (index >= 0) && (index < ${e[2]}) ? 1.0 : 0.0;
setOutput(inBounds * getA(${s}));
}
`}}function wie(n,e){const t=["resRC.x","resRC.y","resRC.z","resRC.w"],r=[];for(let s=0;s<n.length;s++)s===2?r.push("index"):r.push(`${t[s]}`);return r.join()}function GF(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,indices:o}=e,{axis:i,batchDims:a}=r,l=Tt(i,s.shape)[0];if(ye().get("DEBUG")){const I=t.readSync(o.dataId),N=s.shape[l];for(let T=0;T<I.length;++T){const A=I[T];U(A<=N-1&&A>=0,()=>`GatherV2: the index value ${A} is not in [0, ${N-1}]`)}}const c=uI(s,o,l,a),d=Se(o.shape),p=[],m=Ue({inputs:{x:s},backend:t,attrs:{shape:[c.batchSize,c.outerSize,c.dimSize,c.sliceSize]}}),y=Ue({inputs:{x:o},backend:t,attrs:{shape:[c.batchSize,d/c.batchSize]}});p.push(m),p.push(y);const v=[c.batchSize,c.outerSize,d/c.batchSize,c.sliceSize];if(t.shouldExecuteOnCPU([s,o])||s.dtype==="string"){const I=t.bufferSync(y),N=t.bufferSync(m),T=Cte(N,I,v);return p.forEach(A=>t.disposeIntermediateTensorInfo(A)),t.makeTensorInfo(c.outputShape,T.dtype,T.values)}const b=new vie(m.shape,v),w=t.runWebGLProgram(b,[m,y],m.dtype);p.push(w);const k=Ue({inputs:{x:w},backend:t,attrs:{shape:c.outputShape}});return p.forEach(I=>t.disposeIntermediateTensorInfo(I)),k}const bie={kernelName:L1,backendName:"webgl",kernelFunc:GF};const Cie="return float(a > b);",Sie=`
return vec4(greaterThan(a, b));
`,kie=Or({opSnippet:Cie,packedOpSnippet:Sie,cpuKernelImpl:Ste,dtype:"bool"}),Iie={kernelName:M1,backendName:"webgl",kernelFunc:kie};const $ie="return float(a >= b);",Nie=`
return vec4(greaterThanEqual(a, b));
`,Tie=Or({opSnippet:$ie,packedOpSnippet:Nie,dtype:"bool",cpuKernelImpl:kte}),Eie={kernelName:bg,backendName:"webgl",kernelFunc:Tie};function Rie(n){const{inputs:e,backend:t}=n,{input:r}=e;return VF(r,!0,t)}const Aie={kernelName:BS,backendName:"webgl",kernelFunc:Rie};const _ie="return float(!isnan(x) && !isinf(x));",Die=zt({opSnippet:_ie,dtype:"bool"}),Oie={kernelName:Sg,backendName:"webgl",kernelFunc:Die};const Fie="return float(isinf(x));",Pie=zt({opSnippet:Fie,dtype:"bool"}),Lie={kernelName:kg,backendName:"webgl",kernelFunc:Pie};const Mie="return float(isnan(x));",zie=zt({opSnippet:Mie,dtype:"bool"}),Bie={kernelName:Ig,backendName:"webgl",kernelFunc:zie};const Uie="return float(a < b);",Wie=`
return vec4(lessThan(a, b));
`,Vie=Or({opSnippet:Uie,packedOpSnippet:Wie,cpuKernelImpl:Ite,dtype:"bool"}),Gie={kernelName:B1,backendName:"webgl",kernelFunc:Vie};const jie="return float(a <= b);",Hie=`
return vec4(lessThanEqual(a, b));
`,qie=Or({opSnippet:jie,packedOpSnippet:Hie,cpuKernelImpl:$te,dtype:"bool"}),Kie={kernelName:U1,backendName:"webgl",kernelFunc:qie};function Xie(n){const{backend:e,attrs:t}=n,{start:r,stop:s,num:o}=t,i=Nte(r,s,o);return e.makeTensorInfo([i.length],"float32",i)}const Yie={kernelName:TE,backendName:"webgl",kernelFunc:Xie};const Qie=Pf+`
return x < 0.0 ? 0./0. : log(x);
`,Jie=`
vec4 result = log(x);
bvec4 isNaN = isnan(x);
result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r);
result.g = isNaN.g ? x.g : (x.g < 0.0 ? 0./0. : result.g);
result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b);
result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a);
return result;
`,Zie=zt({opSnippet:Qie,packedOpSnippet:Jie,cpuKernelImpl:Tte}),eae={kernelName:$g,backendName:"webgl",kernelFunc:Zie};const tae=Pf+`
return log(1.0 + x);
`,nae=zt({opSnippet:tae}),rae={kernelName:Ng,backendName:"webgl",kernelFunc:nae};const sae="return float(a >= 1.0 && b >= 1.0);",oae=`
return vec4(
vec4(greaterThanEqual(a, vec4(1.0))) *
vec4(greaterThanEqual(b, vec4(1.0))));
`,iae=Or({opSnippet:sae,packedOpSnippet:oae,dtype:"bool"}),aae={kernelName:W1,backendName:"webgl",kernelFunc:iae};const lae="return float(!(x >= 1.0));",uae=zt({opSnippet:lae}),cae={kernelName:V1,backendName:"webgl",kernelFunc:uae};const hae="return float(a >= 1.0 || b >= 1.0);",dae=`
return min(
vec4(greaterThanEqual(a, vec4(1.0))) +
vec4(greaterThanEqual(b, vec4(1.0))),
vec4(1.0));
`,fae=Or({opSnippet:hae,packedOpSnippet:dae,dtype:"bool"}),pae={kernelName:G1,backendName:"webgl",kernelFunc:fae};class mae{constructor(e,t,r,s,o){this.variableNames=["x"],this.outputShape=[];const i=t,a=e[3]-1;this.outputShape=e;let l;const c=`float(${r}) + float(${s}) * sum`;o===.5?l=`inversesqrt(${c})`:o===1?l=`1.0/(${c})`:l=`exp(log(${c}) * float(-${o}));`,this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int r = coords[1];
int c = coords[2];
int d = coords[3];
float x = getX(b, r, c, d);
float sum = 0.0;
for (int j = -${i}; j <= ${i}; j++) {
int idx = d + j;
if (idx >= 0 && idx <= ${a}) {
float z = getX(b, r, c, idx);
sum += z * z;
}
}
float val = x * ${l};
setOutput(val);
}
`}}class gae{constructor(e,t,r,s,o){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;const i=t,a=e[3]-1;this.outputShape=e;let l;const c=`float(${r}) + float(${s}) * sum`;o===.5?l=`inversesqrt(${c})`:o===1?l=`1.0/(${c})`:l=`exp(log(${c}) * float(-${o}));`,this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int b = coords.x;
int r = coords.y;
int c = coords.z;
int d = coords.w;
bool hasNextCol = d < ${this.outputShape[3]};
bool hasNextRow = c < ${this.outputShape[2]};
vec4 sum = vec4(0.);
vec4 xFragAtOutputCoords = getX(b, r, c, d);
vec4 xAtOutputCoords = vec4(
getChannel(xFragAtOutputCoords, vec2(c, d)),
hasNextCol ?
getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,
hasNextRow ?
getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,
(hasNextRow && hasNextCol) ?
getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0
);
int firstChannel = d - ${i};
vec2 cache = vec2(0.);
if(firstChannel >= 0){
vec4 firstChannelFrag = getX(b, r, c, firstChannel);
cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));
if(hasNextRow){
cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));
}
}
ivec2 depth = ivec2(d, d + 1);
for (int j = - ${i}; j <= ${i}; j++) {
ivec2 idx = depth + j;
bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));
bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${a}));
bool depthInRange = aboveLowerBound.x && belowUpperBound.x;
bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;
if(depthInRange || depthPlusOneInRange){
vec4 z = vec4(0.);
vec4 xFragAtCurrentDepth;
z.xz = cache.xy;
if(depthPlusOneInRange && hasNextCol){
xFragAtCurrentDepth = idx.y != d ?
getX(b, r, c, idx.y) : xFragAtOutputCoords;
z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));
if(hasNextRow){
z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));
}
}
cache.xy = z.yw;
sum += z * z;
}
}
vec4 result = xAtOutputCoords * ${l};
setOutput(result);
}
`}}const xae=n=>{const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{depthRadius:o,bias:i,alpha:a,beta:l}=r,c=ye().getBool("WEBGL_PACK_NORMALIZATION")?new gae(s.shape,o,i,a,l):new mae(s.shape,o,i,a,l);return t.runWebGLProgram(c,[s],s.dtype)},yae={kernelName:j1,backendName:"webgl",kernelFunc:xae};class vae{constructor(e,t,r,s,o){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=r,this.alpha=s,this.beta=o,this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int r = coords[1];
int c = coords[2];
float result = 0.0;
for (int d = 0; d < ${this.depth}; ++d) {
int depthBegin = int(max(0.0, float(d - ${t})));
int depthEnd = int(min(float(${this.depth}),
float(d + ${t} + 1)));
const int MIN_DEPTH_BEGIN = 0;
const int MAX_DEPTH_END = ${this.depth};
float norm = 0.0;
for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) {
if (k < depthBegin){
continue;
}
else if (k >= depthBegin && k < depthEnd) {
norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);
}
else {
break;
}
}
norm = float(${s}) * norm + float(${r});
for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){
if (k < depthBegin){
continue;
}
else if (k >= depthBegin && k < depthEnd){
float dyi = -2.0 * float(${s})
* float(${o})
* getInputImage(b, r, c, k) * getOutputImage(b, r, c, d)
/ norm;
if (k == d) {
dyi += pow(norm, -1.0 * ${o});
}
if (k == coords[3]) {
dyi *= getDy(b, r, c, d);
result += dyi;
}
}
else {
break;
}
}
}
setOutput(result);
}
`}}const wae=n=>{const{inputs:e,backend:t,attrs:r}=n,{x:s,y:o,dy:i}=e,{depthRadius:a,bias:l,alpha:c,beta:d}=r,p=new vae(s.shape,a,l,c,d);return t.runWebGLProgram(p,[s,o,i],s.dtype)},bae={kernelName:WS,backendName:"webgl",kernelFunc:wae};function Cae(n,e,t,r){const s=Se(e),i=Se(n.shape)/s,a=Ue({inputs:{x:n},attrs:{shape:[i,s]},backend:r}),l=gh(a,n.dtype,"max",r),c=Ue({inputs:{x:l},attrs:{shape:t},backend:r});return r.disposeIntermediateTensorInfo(a),r.disposeIntermediateTensorInfo(l),c}function jF(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{reductionIndices:o,keepDims:i}=r,a=s.shape.length,l=Tt(o,s.shape);let c=l;const d=En(c,a),p=d!=null,m=t.shouldExecuteOnCPU([s]);let y=s;if(p){if(m){const N=t.texData.get(y.dataId).values,T=new Array(a);for(let P=0;P<T.length;P++)T[P]=s.shape[d[P]];const A=jI(N,s.shape,s.dtype,d,T);y=t.makeTensorInfo(T,s.dtype);const O=t.texData.get(y.dataId);O.values=A}else y=Gv(s,d,t);c=Wn(c.length,a)}Dr("max",c,a);const[v,b]=yr(y.shape,c);let w=v;i&&(w=Yn(v,l));let k;if(m){const N=t.texData.get(y.dataId).values,T=Ete(N,Se(b),w,s.dtype);k=t.makeTensorInfo(w,s.dtype);const A=t.texData.get(k.dataId);A.values=T}else k=Cae(y,b,w,t);return p&&t.disposeIntermediateTensorInfo(y),k}const Sae={kernelName:H1,backendName:"webgl",kernelFunc:jF};const kae=HI+`
return max(a, b);
`,Iae=`
vec4 result = vec4(max(a, b));
bvec4 isNaNA = isnan(a);
bvec4 isNaNB = isnan(b);
bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);
`+mh+`
return result;
`,$ae=Or({opSnippet:kae,packedOpSnippet:Iae,cpuKernelImpl:Rte}),Nae={kernelName:Tg,backendName:"webgl",kernelFunc:$ae};function Tae(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e;xx(s,"maxPool");const{filterSize:o,strides:i,pad:a,dimRoundingMode:l}=r,c=1;U(Hr(i,c),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const d=Xo(s.shape,o,i,c,a,l);if(d.filterWidth===1&&d.filterHeight===1&&Xt(d.inShape,d.outShape))return Js({inputs:{x:s},backend:t});const p=new qm(d,"max",!1);return t.runWebGLProgram(p,[s],s.dtype)}const Eae={kernelName:q1,backendName:"webgl",kernelFunc:Tae};function Rae(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{filterSize:o,strides:i,pad:a,dataFormat:l,dimRoundingMode:c}=r,d=[1,1,1],p=ll(s.shape,o,i,d,a,c,l),m=new KI(p,"max",!1);return t.runWebGLProgram(m,[s],s.dtype)}const Aae={kernelName:K1,backendName:"webgl",kernelFunc:Rae};class _ae{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideHeight,r=e.strideWidth,s=e.dilationHeight,o=e.effectiveFilterHeight,i=e.effectiveFilterWidth,a=o-1-e.padInfo.top,l=i-1-e.padInfo.left,c=o*i-1;this.userCode=`
const ivec2 pads = ivec2(${a}, ${l});
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
ivec2 dyRCCorner = coords.yz - pads;
int dyRCorner = dyRCCorner.x;
int dyCCorner = dyRCCorner.y;
// Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
for (int wR = 0; wR < ${o};
wR += ${s}) {
float dyR = float(dyRCorner + wR) / ${t}.0;
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
for (int wC = 0; wC < ${i}; wC++) {
float dyC = float(dyCCorner + wC) / ${r}.0;
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
float dyValue = getDy(b, idyR, idyC, d);
int maxPosValue = ${c} - int(getMaxPos(b, idyR, idyC, d));
// Get the current value, check it against the value from the
// position matrix.
int curPosValue = wR * ${i} + wC;
float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);
dotProd += dyValue * mask;
}
}
setOutput(dotProd);
}
`}}class Dae{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideDepth,r=e.strideHeight,s=e.strideWidth,o=e.dilationDepth,i=e.dilationHeight,a=e.dilationWidth,l=e.effectiveFilterDepth,c=e.effectiveFilterHeight,d=e.effectiveFilterWidth,p=l-1-e.padInfo.front,m=c-1-e.padInfo.top,y=d-1-e.padInfo.left,v=l*c*d-1;this.userCode=`
const ivec3 pads = ivec3(${p}, ${m}, ${y});
void main() {
ivec5 coords = getOutputCoords();
int batch = coords.x;
int ch = coords.u;
ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;
int dyDCorner = dyCorner.x;
int dyRCorner = dyCorner.y;
int dyCCorner = dyCorner.z;
// Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get
// dx(xD, xR, xC, ch).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
for (int wD = 0; wD < ${l};
wD += ${o}) {
float dyD = float(dyDCorner + wD) / ${t}.0;
if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {
continue;
}
int idyD = int(dyD);
for (int wR = 0; wR < ${c};
wR += ${i}) {
float dyR = float(dyRCorner + wR) / ${r}.0;
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||
fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
for (int wC = 0; wC < ${d};
wC += ${a}) {
float dyC = float(dyCCorner + wC) / ${s}.0;
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
float dyValue = getDy(batch, idyD, idyR, idyC, ch);
int maxPosValue = ${v} -
int(getMaxPos(batch, idyD, idyR, idyC, ch));
// Get the current value, check it against the value from the
// position matrix.
int curPosValue =
wD * ${c} * ${d} +
wR * ${d} + wC;
float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);
dotProd += dyValue * mask;
}
}
}
setOutput(dotProd);
}
`}}function Oae(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,input:o}=e,i=o,{filterSize:a,strides:l,pad:c,dimRoundingMode:d}=r,p=[1,1,1],m=ll(i.shape,a,l,p,c,d),y=new KI(m,"max",!0),v=t.runWebGLProgram(y,[i],i.dtype),b=new Dae(m),w=t.runWebGLProgram(b,[s,v],i.dtype);return t.disposeIntermediateTensorInfo(v),w}const Fae={kernelName:GS,backendName:"webgl",kernelFunc:Oae};function Pae(n){const{inputs:e,backend:t,attrs:r}=n,{dy:s,input:o,output:i}=e,a=o;xx([o,i],"maxPoolGrad");const{filterSize:l,strides:c,pad:d,dimRoundingMode:p}=r,m=Xo(a.shape,l,c,1,d,p),y=!0,v=new qm(m,"max",y),b=t.runWebGLProgram(v,[a],a.dtype),w=new _ae(m),k=t.runWebGLProgram(w,[s,b],a.dtype);return t.disposeIntermediateTensorInfo(b),k}const Lae={kernelName:VS,backendName:"webgl",kernelFunc:Pae};function Mae(n,e,t,r){let s=new qm(t,"max",!1);const o=r.runWebGLProgram(s,[n],"float32");s=new qm(t,"max",!0,!0,e);const i=r.runWebGLProgram(s,[n],"float32");return[o,i]}const zae={kernelName:EE,backendName:"webgl",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{x:r}=n,{filterSize:s,strides:o,pad:i,includeBatchInIndex:a}=e,l=t;U(r.shape.length===4,()=>`Error in maxPool: input must be rank 4 but got rank ${r.shape.length}.`);const c=[1,1];U(Hr(o,c),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${c}'`);const d=Xo(r.shape,s,o,c,i),[p,m]=Mae(r,a,d,l);return[p,m]}};function Bae(n,e,t,r){const s=Se(e),i=Se(n.shape)/s,a=Ue({inputs:{x:n},attrs:{shape:[i,s]},backend:r}),l=gh(a,"float32","mean",r),c=Ue({inputs:{x:l},attrs:{shape:t},backend:r});return r.disposeIntermediateTensorInfo(a),r.disposeIntermediateTensorInfo(l),c}const Uae={kernelName:X1,backendName:"webgl",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{x:r}=n,{keepDims:s,axis:o}=e,i=t,a=r.shape.length,l=Tt(o,r.shape);let c=l;const d=En(c,a),p=d!=null,m=i.shouldExecuteOnCPU([r]),y=[];let v=r;if(p){if(m){const T=i.texData.get(v.dataId).values,A=new Array(a);for(let B=0;B<A.length;B++)A[B]=r.shape[d[B]];const O=jI(T,r.shape,r.dtype,d,A);v=i.makeTensorInfo(A,r.dtype);const P=i.texData.get(v.dataId);P.values=O}else v=Gv(r,d,i);y.push(v),c=Wn(c.length,a)}Dr("sum",c,a);const[b,w]=yr(v.shape,c);let k=b;s&&(k=Yn(b,l));const I=Bae(v,w,k,i);for(const N of y)i.disposeIntermediateTensorInfo(N);return I}};function Wae(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o,keepDims:i}=r,a=s.shape.length,l=Tt(o,s.shape);let c=l;const d=En(c,a);let p=s;d!=null&&(p=cs({inputs:{x:s},backend:t,attrs:{perm:d}}),c=Wn(c.length,s.shape.length)),Dr("min",c,a);const[m,y]=yr(p.shape,c),v=Se(y),b=Ue({inputs:{x:p},backend:t,attrs:{shape:[-1,v]}}),w=gh(b,b.dtype,"min",t);let k;if(i){const I=Yn(m,l);k=Ue({inputs:{x:w},backend:t,attrs:{shape:I}})}else k=Ue({inputs:{x:w},backend:t,attrs:{shape:m}});return t.disposeIntermediateTensorInfo(b),t.disposeIntermediateTensorInfo(w),d!=null&&t.disposeIntermediateTensorInfo(p),k}const Vae={kernelName:Y1,backendName:"webgl",kernelFunc:Wae};const Gae=HI+`
return min(a, b);
`,jae=`
vec4 result = vec4(min(a, b));
bvec4 isNaNA = isnan(a);
bvec4 isNaNB = isnan(b);
bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);
`+mh+`
return result;
`,Hae=Or({opSnippet:Gae,packedOpSnippet:jae,cpuKernelImpl:Ate}),qae={kernelName:Eg,backendName:"webgl",kernelFunc:Hae};class Kae{constructor(e,t,r){this.variableNames=["x"],this.outputShape=t.map((d,p)=>d[0]+e[p]+d[1]);const s=e.length,o=on(s),i=t.map(d=>d[0]).join(","),a=t.map((d,p)=>d[0]+e[p]).join(","),l=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,s),c=r==="reflect"?0:1;if(s===1){this.userCode=`
int start = ${i};
int end = ${a};
void main() {
int outC = getOutputCoords();
if (outC < start) {
outC = start * 2 - outC - ${c};
} else if(outC >= end) {
outC = (end - 1) * 2 - outC + ${c};
}
setOutput(getX(outC - start));
}
`;return}this.userCode=`
${o} start = ${o}(${i});
${o} end = ${o}(${a});
void main() {
${o} outC = getOutputCoords();
for (int i = 0; i < ${s}; i++) {
if (outC[i] < start[i]) {
outC[i] = start[i] * 2 - outC[i] - ${c};
} else if(outC[i] >= end[i]) {
outC[i] = (end[i] - 1) * 2 - outC[i] + ${c};
}
}
${o} coords = outC - start;
setOutput(getX(${l}));
}
`}}class Xae{constructor(e,t,r){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((v,b)=>v[0]+e[b]+v[1]);const s=e.length,o=on(s),i=t.map(v=>v[0]).join(","),a=t.map((v,b)=>v[0]+e[b]).join(","),l=ls("rc",s),c=ls("source",s),d=`${l[s-1]} < ${this.outputShape[s-1]}`,p=s===1?"source":`vec2(${c.slice(-2).join()})`,m=r==="reflect"?0:1;let y="";if(s===1){const v=`
${o} source = rc;
if (source < start) {
source = start * 2 - source - ${m};
} else if (source >= end) {
source = (end - 1) * 2 - source + ${m};
}
source -= start;
`;y=`
${o} rc = outputLoc;
${v}
result[0] = getChannel(getX(${c.join()}), ${p});
${l[s-1]} += 1;
if(${d}) {
${v}
result[1] = getChannel(getX(${c.join()}), ${p});
}
`}else{const v=`
${o} source = rc;
${o} lt = ${o}(lessThan(source, start));
${o} gte = ${o}(greaterThanEqual(source, end));
${o} orig = 1 - (lt + gte);
source = orig * source +
lt * (start * 2 - source - ${m}) +
gte * ((end - 1) * 2 - source + ${m});
source -= start;
`;y=`
${o} rc = outputLoc;
${v}
result[0] = getChannel(getX(${c.join()}), ${p});
${l[s-1]} += 1;
if(${d}) {
${v}
result[1] = getChannel(getX(${c.join()}), ${p});
}
rc = outputLoc;
${l[s-2]} += 1;
if(${l[s-2]} < ${this.outputShape[s-2]}) {
${v}
result[2] = getChannel(getX(${c.join()}), ${p});
${l[s-1]} += 1;
if(${d}) {
${v}
result[3] = getChannel(getX(${c.join()}), ${p});
}
}
`}this.userCode=`
const ${o} start = ${o}(${i});
const ${o} end = ${o}(${a});
void main() {
${o} outputLoc = getOutputCoords();
vec4 result = vec4(0.);
${y}
setOutput(result);
}
`}}const Yae=({inputs:n,backend:e,attrs:t})=>{const{x:r}=n,{paddings:s,mode:o}=t,i=ye().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Xae(r.shape,s,o):new Kae(r.shape,s,o);return e.runWebGLProgram(i,[r],r.dtype)},Qae={kernelName:Q1,backendName:"webgl",kernelFunc:Yae};const Jae=`if (b == 0.0) return NAN;
return mod(a, b);`,Zae=`
vec4 result = mod(a, b);
bvec4 isNaN = equal(b, vec4(0.0));
`+mh+`
return result;
`,ele=Or({opSnippet:Jae,packedOpSnippet:Zae}),tle={kernelName:Rg,backendName:"webgl",kernelFunc:ele};class nle{constructor(e,t,r){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[e,r],this.userCode=`
void main() {
ivec2 coords = getOutputCoords();
int batch = coords[0];
float r = random(seed);
float cdf = 0.0;
for (int i = 0; i < ${t-1}; i++) {
cdf += getProbs(batch, i);
if (r < cdf) {
setOutput(float(i));
return;
}
}
// If no other event happened, last event happened.
setOutput(float(${t-1}));
}
`}}const rle=`
if (a == b) {
return 1.0;
};
return a / b;`,sle=`
// vec4 one = vec4(equal(a, b));
// return one + (vec4(1.0) - one) * a / b;
vec4 result = a / b;
if(a.x == b.x) {
result.x = 1.;
}
if(a.y == b.y) {
result.y = 1.;
}
if(a.z == b.z) {
result.z = 1.;
}
if(a.w == b.w) {
result.w = 1.;
}
return result;
`,HF=Or({opSnippet:rle,packedOpSnippet:sle,checkOutOfBounds:!0}),ole={kernelName:pg,backendName:"webgl",kernelFunc:HF};const lT="return a - b;",qF=Or({opSnippet:lT,packedOpSnippet:lT,supportsComplex:!0,cpuKernelImpl:Jte}),ile={kernelName:Hg,backendName:"webgl",kernelFunc:qF};function KF(n){const{inputs:e,backend:t,attrs:r}=n,{logits:s}=e,{dim:o}=r,i=Tt([o],s.shape),a=jF({inputs:{x:s},backend:t,attrs:{reductionIndices:i,keepDims:!1}}),l=Yn(a.shape,i),c=Ue({inputs:{x:a},backend:t,attrs:{shape:l}}),d=qF({inputs:{a:s,b:c},backend:t}),p=WF({inputs:{x:d},backend:t}),m=jv({inputs:{x:p},backend:t,attrs:{axis:i,keepDims:!1}}),y=Ue({inputs:{x:m},backend:t,attrs:{shape:l}}),v=HF({inputs:{a:p,b:y},backend:t});return t.disposeIntermediateTensorInfo(a),t.disposeIntermediateTensorInfo(c),t.disposeIntermediateTensorInfo(d),t.disposeIntermediateTensorInfo(p),t.disposeIntermediateTensorInfo(m),t.disposeIntermediateTensorInfo(y),v}const ale={kernelName:mv,backendName:"webgl",kernelFunc:KF};function lle(n){const{inputs:e,backend:t,attrs:r}=n,{logits:s}=e,{numSamples:o,seed:i,normalized:a}=r,l=a?s:KF({inputs:{logits:s},backend:t,attrs:{dim:s.shape.length-1}}),c=l.shape[0],d=l.shape[1],p=new nle(c,d,o),m=[[i]],y=t.runWebGLProgram(p,[l],"int32",m);return a||t.disposeIntermediateTensorInfo(l),y}const ule={kernelName:RE,backendName:"webgl",kernelFunc:lle};const cle=Qo+`
return -x;
`,hle=`
vec4 result = -x;
bvec4 isNaN = isnan(x);
result.r = isNaN.r ? x.r : result.r;
result.g = isNaN.g ? x.g : result.g;
result.b = isNaN.b ? x.b : result.b;
result.a = isNaN.a ? x.a : result.a;
return result;
`;function dle(n){const{inputs:e,backend:t}=n,{x:r}=e;if(t.shouldExecuteOnCPU([r])){const o=t.texData.get(r.dataId),[i,a]=Dte(o.values,r.shape,r.dtype);return t.makeTensorInfo(a,r.dtype,i)}let s;return ye().getBool("WEBGL_PACK_UNARY_OPERATIONS")?s=new tu(r.shape,hle):s=new la(r.shape,cle),t.runWebGLProgram(s,[r],r.dtype)}const fle={kernelName:J1,backendName:"webgl",kernelFunc:dle};const ple=Dk;function mle(n){go("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:t,attrs:r}=n,{boxes:s,scores:o}=e,{maxOutputSize:i,iouThreshold:a,scoreThreshold:l}=r,c=t.readSync(s.dataId),d=t.readSync(o.dataId),{selectedIndices:p}=ple(c,d,i,a,l);return t.makeTensorInfo([p.length],"int32",new Int32Array(p))}const gle={kernelName:jS,backendName:"webgl",kernelFunc:mle};const xle=Ok;function yle(n){go("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:t,attrs:r}=n,{boxes:s,scores:o}=e,{maxOutputSize:i,iouThreshold:a,scoreThreshold:l,padToMaxOutputSize:c}=r,d=t.readSync(s.dataId),p=t.readSync(o.dataId),{selectedIndices:m,validOutputs:y}=xle(d,p,i,a,l,c);return[t.makeTensorInfo([m.length],"int32",new Int32Array(m)),t.makeTensorInfo([],"int32",new Int32Array([y]))]}const vle={kernelName:HS,backendName:"webgl",kernelFunc:yle};const wle=Fk;function ble(n){go("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:t,attrs:r}=n,{boxes:s,scores:o}=e,{maxOutputSize:i,iouThreshold:a,scoreThreshold:l,softNmsSigma:c}=r,d=t.readSync(s.dataId),p=t.readSync(o.dataId),m=i,y=a,v=l,b=c,{selectedIndices:w,selectedScores:k}=wle(d,p,m,y,v,b);return[t.makeTensorInfo([w.length],"int32",new Int32Array(w)),t.makeTensorInfo([k.length],"float32",new Float32Array(k))]}const Cle={kernelName:qS,backendName:"webgl",kernelFunc:ble};class Sle{constructor(e,t,r,s){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode=`
void main() {
ivec2 coords = getOutputCoords();
int index = round(getIndices(coords.x));
setOutput(mix(float(${s}), float(${r}),
float(index == coords.y)));
}
`}}const kle=n=>{const{inputs:e,backend:t,attrs:r}=n,{indices:s}=e,{dtype:o,depth:i,onValue:a,offValue:l}=r,c=Se(s.shape),d=new Sle(c,i,a,l),p=Ue({inputs:{x:s},backend:t,attrs:{shape:[c]}}),m=t.runWebGLProgram(d,[p],o);t.disposeIntermediateTensorInfo(p);const y=[...s.shape,i],v=Ue({inputs:{x:m},backend:t,attrs:{shape:y}});return t.disposeIntermediateTensorInfo(m),v},Ile={kernelName:tv,backendName:"webgl",kernelFunc:kle};function h1(n){const{inputs:e,backend:t}=n,{x:r}=e;if(r.dtype==="complex64"){const s=vx({inputs:{input:r},backend:t}),o=h1({inputs:{x:s},backend:t}),i=Hv({inputs:{input:r},backend:t}),a=h1({inputs:{x:i},backend:t}),l=ku({inputs:{real:o,imag:a},backend:t});return t.disposeIntermediateTensorInfo(s),t.disposeIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(a),l}else return wx({attrs:{shape:r.shape,dtype:r.dtype,value:r.dtype==="string"?"":0},backend:t})}const $le={kernelName:yv,backendName:"webgl",kernelFunc:h1};function XF(n){const{inputs:e,backend:t}=n,{x:r}=e;if(r.dtype==="string")throw new Error("onesLike is not supported under string dtype");if(r.dtype==="complex64"){const s=vx({inputs:{input:r},backend:t}),o=XF({inputs:{x:s},backend:t}),i=Hv({inputs:{input:r},backend:t}),a=h1({inputs:{x:i},backend:t}),l=ku({inputs:{real:o,imag:a},backend:t});return t.disposeIntermediateTensorInfo(s),t.disposeIntermediateTensorInfo(o),t.disposeIntermediateTensorInfo(i),t.disposeIntermediateTensorInfo(a),l}else return wx({attrs:{shape:r.shape,dtype:r.dtype,value:1},backend:t})}const Nle={kernelName:ev,backendName:"webgl",kernelFunc:XF};function Tle(n){const{inputs:e,backend:t,attrs:r}=n,{axis:s}=r;if(e.length===1)return BC({inputs:{input:e[0]},backend:t,attrs:{dim:s}});const o=e[0].shape,i=e[0].dtype;e.forEach(d=>{fS(o,d.shape,"All tensors passed to stack must have matching shapes"),U(i===d.dtype,()=>"All tensors passed to stack must have matching dtypes")});const a=[],l=e.map(d=>{const p=BC({inputs:{input:d},backend:t,attrs:{dim:s}});return a.push(p),p}),c=OF({inputs:l,backend:t,attrs:{axis:s}});return a.forEach(d=>t.disposeIntermediateTensorInfo(d)),c}const Ele={kernelName:nv,backendName:"webgl",kernelFunc:Tle};class Rle{constructor(e,t,r){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((c,d)=>c[0]+e[d]+c[1]);const s=e.length,o=on(s),i=t.map(c=>c[0]).join(","),a=t.map((c,d)=>c[0]+e[d]).join(","),l=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,s);if(s===1){this.userCode=`
int start = ${i};
int end = ${a};
void main() {
int outC = getOutputCoords();
if (outC < start || outC >= end) {
setOutput(value);
} else {
setOutput(getX(outC - start));
}
}
`;return}this.userCode=`
${o} start = ${o}(${i});
${o} end = ${o}(${a});
void main() {
${o} outC = getOutputCoords();
if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {
setOutput(value);
} else {
${o} coords = outC - start;
setOutput(getX(${l}));
}
}
`}}class Ale{constructor(e,t,r){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((b,w)=>b[0]+e[w]+b[1]);const s=e.length,o=on(s),i=t.map(b=>b[0]).join(","),a=t.map((b,w)=>b[0]+e[w]).join(","),l=ls("rc",s),c=ls("source",s),d=`${l[s-1]} < ${this.outputShape[s-1]}`,p=s===1?"source":`vec2(${c.slice(-2).join()})`,m=[`${o} rc = outputLoc;`,`${l[s-1]} += 1;
if(${d}) {
`,s===1?"":`}
rc = outputLoc;
${l[s-2]} += 1;
if(${l[s-2]} < ${this.outputShape[s-2]}) {`,s===1?"":` ${l[s-1]} += 1;
if(${d}) {`],y=s===1?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))";let v="";for(let b=0,w=s===1?2:4;b<w;b++)v+=`
${m[b]}
if (${y}) {
result[${b}] = float(value);
} else {
${o} source = rc - start;
result[${b}] = getChannel(getX(${c.join()}), ${p});
}
`;v+=s===1?"} ":"}}",this.userCode=`
const ${o} start = ${o}(${i});
const ${o} end = ${o}(${a});
void main() {
${o} outputLoc = getOutputCoords();
vec4 result = vec4(0.);
${v}
setOutput(result);
}
`}}const YF=n=>{const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{paddings:o,constantValue:i}=r;if(Se(s.shape)===0){const c=o.map((d,p)=>d[0]+s.shape[p]+d[1]);return wx({backend:t,attrs:{shape:c,value:i,dtype:s.dtype}})}const a=ye().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Ale(s.shape,o,i):new Rle(s.shape,o,i),l=[[i]];return t.runWebGLProgram(a,[s],s.dtype,l)},_le={kernelName:rv,backendName:"webgl",kernelFunc:YF};const Dle=`
if(a < 0.0 && floor(b) < b){
return NAN;
}
if (b == 0.0) {
return 1.0;
}
return (round(mod(b, 2.0)) != 1) ?
pow(abs(a), b) : sign(a) * pow(abs(a), b);
`,Ole=`
// isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.
vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));
vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);
vec4 result = multiplier * pow(abs(a), b);
// Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS
bvec4 isExpZero = equal(b, vec4(0.0));
result.r = isExpZero.r ? 1.0 : result.r;
result.g = isExpZero.g ? 1.0 : result.g;
result.b = isExpZero.b ? 1.0 : result.b;
result.a = isExpZero.a ? 1.0 : result.a;
bvec4 isNaN1 = lessThan(a, vec4(0.0));
bvec4 isNaN2 = lessThan(floor(b), b);
bvec4 isNaN = bvec4(isNaN1.x && isNaN2.x, isNaN1.y && isNaN2.y, isNaN1.z && isNaN2.z, isNaN1.w && isNaN2.w);
`+mh+`
return result;
`,Fle=Or({opSnippet:Dle,packedOpSnippet:Ole}),Ple={kernelName:_g,backendName:"webgl",kernelFunc:Fle};function Lle(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{axis:o,keepDims:i}=r,a=s.shape.length,l=[],c=Tt(o,s.shape);let d=c;const p=En(d,a);let m=s;p!=null&&(m=cs({inputs:{x:s},backend:t,attrs:{perm:p}}),d=Wn(d.length,a),l.push(m)),Dr("prod",d,a);let y;if(t.shouldExecuteOnCPU([m])){const v=t.texData.get(m.dataId).values,{outVals:b,outShape:w,outDtype:k}=Fte(m.shape,m.dtype,v,d);y=t.makeTensorInfo(w,k,b)}else{const[v,b]=yr(m.shape,d),w=Se(b),k=Ue({inputs:{x:m},backend:t,attrs:{shape:[-1,w]}}),I=ok(s.dtype),N=gh(k,I,"prod",t);y=Ue({inputs:{x:N},backend:t,attrs:{shape:v}}),l.push(k),l.push(N)}if(i){l.push(y);const v=Yn(y.shape,c);y=Ue({inputs:{x:y},backend:t,attrs:{shape:v}})}return l.forEach(v=>t.disposeIntermediateTensorInfo(v)),y}const Mle={kernelName:ov,backendName:"webgl",kernelFunc:Lle};function zle(n){const{inputs:e,backend:t,attrs:r}=n,{paramsNestedSplits:s,paramsDenseValues:o,indices:i}=e,{outputRaggedRank:a}=r,l=s.map(k=>t.readSync(k.dataId)),c=s.map(k=>k.shape),d=t.readSync(o.dataId),p=t.readSync(i.dataId),[m,y,v]=Pte(l,c,d,o.shape,o.dtype,p,i.shape,a),b=m.map(k=>t.makeTensorInfo([k.length],"int32",k)),w=t.makeTensorInfo(v,o.dtype,y);return b.concat([w])}const Ble={kernelName:AE,backendName:"webgl",kernelFunc:zle};function Ule(n){const{inputs:e,backend:t}=n,{starts:r,limits:s,deltas:o}=e,i=t.readSync(r.dataId),a=t.readSync(s.dataId),l=t.readSync(o.dataId),[c,d]=Lte(i,r.shape,r.dtype,a,s.shape,l,o.shape),p=t.makeTensorInfo([c.length],"int32",c),m=t.makeTensorInfo([d.length],r.dtype,d);return[p,m]}const Wle={kernelName:_E,backendName:"webgl",kernelFunc:Ule};function Vle(n){const{inputs:e,backend:t,attrs:r}=n,{shape:s,values:o,defaultValue:i,rowPartitionTensors:a}=e,{rowPartitionTypes:l}=r,c=t.readSync(s.dataId),d=t.readSync(o.dataId),p=t.readSync(i.dataId),m=a.map(w=>t.readSync(w.dataId)),y=a.map(w=>w.shape),[v,b]=Mte(c,s.shape,d,o.shape,o.dtype,p,i.shape,m,y,l);return t.makeTensorInfo(v,o.dtype,b)}const Gle={kernelName:DE,backendName:"webgl",kernelFunc:Vle};const QF=n=>{const{backend:e,attrs:t}=n,{start:r,stop:s,step:o,dtype:i}=t,a=zte(r,s,o,i);return e.makeTensorInfo([a.length],i,a)},jle={kernelName:KS,backendName:"webgl",kernelFunc:QF};const Hle="return 1.0 / x;",qle=zt({opSnippet:Hle}),Kle={kernelName:Dg,backendName:"webgl",kernelFunc:qle};const Xle=Qo+`
return (x < 0.0) ? 0.0 : x;
`,Yle=`
vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));
bvec4 isNaN = isnan(x);
result.r = isNaN.r ? x.r : result.r;
result.g = isNaN.g ? x.g : result.g;
result.b = isNaN.b ? x.b : result.b;
result.a = isNaN.a ? x.a : result.a;
return result;
`,Qle=zt({opSnippet:Xle,packedOpSnippet:Yle}),Jle={kernelName:Og,backendName:"webgl",kernelFunc:Qle};const Zle=Qo+`
return (x < 0.0) ? 0.0 : min(6.0, x);
`,eue=`
vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));
bvec4 isNaN = isnan(x);
result.r = isNaN.r ? x.r : result.r;
result.g = isNaN.g ? x.g : result.g;
result.b = isNaN.b ? x.b : result.b;
result.a = isNaN.a ? x.a : result.a;
return result;
`,tue=zt({opSnippet:Zle,packedOpSnippet:eue}),nue={kernelName:Fg,backendName:"webgl",kernelFunc:tue};class rue{constructor(e,t,r,s,o){this.variableNames=["A"],this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,t,r,c];const d=[s&&t>1?a-1:a,s&&r>1?l-1:l],p=[s&&t>1?t-1:t,s&&r>1?r-1:r];let m;o?m="(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":m="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
const vec2 effectiveInputOverOutputRatioRC = vec2(
${d[0]/p[0]},
${d[1]/p[1]});
const vec2 inputShapeRC = vec2(${a}.0, ${l}.0);
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
ivec2 yRC = coords.yz;
// Fractional source index.
vec2 sourceFracIndexRC = ${m};
// Compute the four integer indices.
ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0)));
ivec2 sourceCeilRC = ivec2(
min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));
float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);
float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);
float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);
float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);
vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);
float top = topLeft + (topRight - topLeft) * fracRC.y;
float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;
float newValue = top + (bottom - top) * fracRC.x;
setOutput(newValue);
}
`}}class sue{constructor(e,t,r,s,o){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,t,r,c];const d=[s&&t>1?a-1:a,s&&r>1?l-1:l],p=[s&&t>1?t-1:t,s&&r>1?r-1:r];let m;o?m="(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":m="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
const vec3 effectiveInputOverOutputRatioRC = vec3(
${d[0]/p[0]},
${d[1]/p[1]},
${d[1]/p[1]});
const vec3 inputShapeRC = vec3(${a}.0, ${l}.0,
${l}.0);
float getAValue(int b, int r, int c, int d) {
return getChannel(getA(b, r, c, d), vec2(c, d));
}
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
// Calculate values for next column in yRC.z.
ivec3 yRC = coords.yzz + ivec3(0, 0, 1);
// Fractional source index.
vec3 sourceFracIndexRC = ${m};
// Compute the four integer indices.
ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0)));
ivec3 sourceCeilRC = ivec3(
min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));
// Should we calculate next column and row elements in 2x2 packed cell.
bool hasNextCol = d < ${c-1};
bool hasNextRow = coords.z < ${r-1};
// In parallel, construct four corners for all four components in
// packed 2x2 cell.
vec4 topLeft = vec4(
getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),
hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)
: 0.0,
hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)
: 0.0,
(hasNextRow && hasNextCol) ?
getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);
vec4 bottomLeft = vec4(
getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),
hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)
: 0.0,
hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)
: 0.0,
(hasNextRow && hasNextCol) ?
getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);
vec4 topRight = vec4(
getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),
hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)
: 0.0,
hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)
: 0.0,
(hasNextRow && hasNextCol) ?
getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);
vec4 bottomRight = vec4(
getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),
hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)
: 0.0,
hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)
: 0.0,
(hasNextRow && hasNextCol) ?
getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);
vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);
vec4 top = mix(topLeft, topRight, fracRC.yyzz);
vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);
vec4 newValue = mix(top, bottom, fracRC.x);
setOutput(newValue);
}
`}}function oue(n){const{inputs:e,backend:t,attrs:r}=n,{images:s}=e,{alignCorners:o,halfPixelCenters:i,size:a}=r,[l,c]=a,d=ye().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new sue(s.shape,l,c,o,i):new rue(s.shape,l,c,o,i);return t.runWebGLProgram(d,[s],"float32")}const iue={kernelName:lv,backendName:"webgl",kernelFunc:oue};class aue{constructor(e,t,r){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,s,o]=t,[,i,a]=e,l=[r&&i>1?s-1:s,r&&a>1?o-1:o],c=[r&&i>1?i-1:i,r&&a>1?a-1:a],d=l[0]/c[0],p=l[1]/c[1],m=1/d,y=1/p,v=Math.ceil(m)*2+2,b=Math.ceil(y)*2+2;this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
int r = coords[1];
int c = coords[2];
float accumulator = 0.0;
const float heightScale = float(${d});
const float widthScale = float(${p});
const float invHeightScale = float(${m});
const float invWidthScale = float(${y});
const int winHeight = int(${v});
const int winWidth = int(${b});
// Compute bounds for where in dy we will look
float startRLerp = floor(float(r) * invHeightScale);
int startDyR = int(startRLerp - float(winHeight / 2));
float startCLerp = floor(float(c) * invWidthScale);
int startDyC = int(startCLerp - float(winWidth / 2));
// Loop over dy
for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {
int dyR = dyROffset + startDyR;
// Guard against the window exceeding the bounds of dy
if (dyR < 0 || dyR >= ${i}) {
continue;
}
for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {
int dyC = dyCOffset + startDyC;
// Guard against the window exceeding the bounds of dy
if (dyC < 0 || dyC >= ${a}) {
continue;
}
float dxR = float(dyR) * heightScale;
int topDxRIndex = int(floor(dxR));
int bottomDxRIndex = int(min(ceil(dxR), ${s-1}.0));
float dxRLerp = dxR - float(topDxRIndex);
float inverseDxRLerp = 1.0 - dxRLerp;
float dxC = float(dyC) * widthScale;
int leftDxCIndex = int(floor(dxC));
int rightDxCIndex = int(min(ceil(dxC), ${o-1}.0));
float dxCLerp = dxC - float(leftDxCIndex);
float inverseDxCLerp = 1.0 - dxCLerp;
if (r == topDxRIndex && c == leftDxCIndex) {
// topLeft
accumulator +=
getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;
}
if (r == topDxRIndex && c == rightDxCIndex) {
// topRight
accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;
}
if (r == bottomDxRIndex && c == leftDxCIndex) {
// bottomLeft
accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;
}
if (r == bottomDxRIndex && c == rightDxCIndex) {
// bottomRight
accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;
}
}
}
// End loop over dy
setOutput(accumulator);
}
`}}function lue(n){const{inputs:e,backend:t,attrs:r}=n,{images:s,dy:o}=e,{alignCorners:i}=r,a=new aue(o.shape,s.shape,i);return t.runWebGLProgram(a,[o],o.dtype)}const uue={kernelName:QS,backendName:"webgl",kernelFunc:lue};class cue{constructor(e,t,r,s,o){this.variableNames=["A"],this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,t,r,c];const d=[s&&t>1?a-1:a,s&&r>1?l-1:l],p=[s&&t>1?t-1:t,s&&r>1?r-1:r],m=s?"0.5":"0.0";let y;o?y="max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":y="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
const vec2 effectiveInputOverOutputRatioRC = vec2(
${d[0]/p[0]},
${d[1]/p[1]});
const vec2 inputShapeRC = vec2(${a}.0, ${l}.0);
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
ivec2 yRC = coords.yz;
// Fractional source index.
vec2 sourceFracIndexRC = ${y};
// Compute the coordinators of nearest neighbor point.
ivec2 sourceNearestRC = ivec2(
min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${m})));
float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);
setOutput(newValue);
}
`}}class hue{constructor(e,t,r,s,o){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,t,r,c];const d=[s&&t>1?a-1:a,s&&r>1?l-1:l],p=[s&&t>1?t-1:t,s&&r>1?r-1:r],m=s?"0.5":"0.0";let y;o?y="max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":y="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
const vec3 effectiveInputOverOutputRatioRC = vec3(
${d[0]/p[0]},
${d[1]/p[1]},
${d[1]/p[1]});
const vec3 inputShapeRC = vec3(${a}.0, ${l}.0,
${l}.0);
float getAValue(int b, int r, int c, int d) {
return getChannel(getA(b, r, c, d), vec2(c, d));
}
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
// Calculate values for next column in yRC.z.
ivec3 yRC = coords.yzz + ivec3(0, 0, 1);
// Fractional source index.
vec3 sourceFracIndexRC = ${y};
// Compute the coordinators of nearest neighbor point.
ivec3 sourceNearestRC = ivec3(
min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${m})));
// Should we calculate next column and row elements in 2x2 packed cell.
bool hasNextCol = d < ${c-1};
bool hasNextRow = coords.z < ${r-1};
vec4 newValue = vec4(
getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d),
hasNextCol ? getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d + 1)
: 0.0,
hasNextRow ? getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d)
: 0.0,
(hasNextRow && hasNextCol) ?
getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d + 1) : 0.0);
setOutput(newValue);
}
`}}function due(n){const{inputs:e,backend:t,attrs:r}=n,{images:s}=e,{alignCorners:o,halfPixelCenters:i,size:a}=r,[l,c]=a,d=ye().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new hue(s.shape,l,c,o,i):new cue(s.shape,l,c,o,i);return t.runWebGLProgram(d,[s],s.dtype)}const fue={kernelName:av,backendName:"webgl",kernelFunc:due};class pue{constructor(e,t,r){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,s,o]=t,[,i,a]=e,l=[r&&i>1?s-1:s,r&&a>1?o-1:o],c=[r&&i>1?i-1:i,r&&a>1?a-1:a],d=l[0]/c[0],p=l[1]/c[1],m=1/d,y=1/p,v=Math.ceil(m)*2+2,b=Math.ceil(y)*2+2;this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
int r = coords[1];
int c = coords[2];
float accumulator = 0.0;
const float heightScale = float(${d});
const float widthScale = float(${p});
const float invHeightScale = float(${m});
const float invWidthScale = float(${y});
const int winHeight = int(${v});
const int winWidth = int(${b});
// Compute bounds for where in dy we will look
float startRLerp = floor(float(r) * invHeightScale);
int startDyR = int(floor(startRLerp - float(winHeight / 2)));
float startCLerp = floor(float(c) * invWidthScale);
int startDyC = int(floor(startCLerp - float(winWidth / 2)));
// Loop over dy
for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {
int dyR = dyROffset + startDyR;
// Guard against the window exceeding the bounds of dy
if (dyR < 0 || dyR >= ${i}) {
continue;
}
for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {
int dyC = dyCOffset + startDyC;
// Guard against the window exceeding the bounds of dy
if (dyC < 0 || dyC >= ${a}) {
continue;
}
float sourceFracRow =
float(${l[0]}) *
(float(dyR) / float(${c[0]}));
float sourceFracCol =
float(${l[1]}) *
(float(dyC) / float(${c[1]}));
int sourceNearestRow = int(min(
float(int(${s}) - 1),
${r} ? float(round(sourceFracRow)) :
float(floor(sourceFracRow))));
int sourceNearestCol = int(min(
float(int(${o}) - 1),
${r} ? float(round(sourceFracCol)) :
float(floor(sourceFracCol))));
if (r == sourceNearestRow && c == sourceNearestCol) {
accumulator += getDy(b, dyR, dyC, d);
}
}
}
// End loop over dy
setOutput(accumulator);
}
`}}function mue(n){const{inputs:e,backend:t,attrs:r}=n,{images:s,dy:o}=e,{alignCorners:i}=r,a=new pue(o.shape,s.shape,i);return t.runWebGLProgram(a,[o],o.dtype)}const gue={kernelName:YS,backendName:"webgl",kernelFunc:mue};class xue{constructor(e,t){this.variableNames=["x"];const r=e.length;if(r>4)throw new Error(`WebGL backend: Reverse of rank-${r} tensor is not yet supported`);if(this.outputShape=e,r===1){this.userCode=`
void main() {
int coord = getOutputCoords();
setOutput(getX(${e[0]} - coord - 1));
}
`;return}const s=a=>t.indexOf(a)!==-1&&e[a]!==1?`${e[a]} - coords[${a}] - 1`:`coords[${a}]`,o=e.map((a,l)=>s(l)).join(","),i=on(r);this.userCode=`
void main() {
${i} coords = getOutputCoords();
setOutput(getX(${o}));
}
`}}class yue{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const r=e.length;if(r>4)throw new Error(`WebGL backend: Reverse of rank-${r} tensor is not yet supported`);this.outputShape=e;const s=ls("rc",r),o=`${s[r-1]} + 1 < ${this.outputShape[r-1]}`,i=`${s[r-2]} + 1 < ${this.outputShape[r-2]}`,a=on(r);r===1?this.userCode=`
void main(){
int rc = getOutputCoords();
vec4 result = vec4(0.);
result.r = getChannel(getX(${e[0]} - rc - 1),
${e[0]} - rc - 1);
if(${o}){
result.g = getChannel(getX(${e[0]} - (rc + 1) - 1),
${e[0]} - (rc + 1) - 1);
}
setOutput(result);
}
`:this.userCode=`
void main() {
${a} rc = getOutputCoords();
vec4 result = vec4(0.);
result.r = ${l(s.slice())};
if(${o}){
result.g = ${c(s.slice())};
}
if(${i}) {
result.b = ${d(s.slice())};
if(${o}) {
result.a = ${p(s.slice())};
}
}
setOutput(result);
}
`;function l(v){return m(v)}function c(v){return v[r-1]="("+v[r-1]+" + 1)",m(v)}function d(v){return v[r-2]="("+v[r-2]+" + 1)",m(v)}function p(v){return v[r-1]="("+v[r-1]+" + 1)",v[r-2]="("+v[r-2]+" + 1)",m(v)}function m(v){const b=e.map((I,N)=>y(N,v)),w=b.join(","),k=b.slice(-2).join(",");return`getChannel(getX(${w}), vec2(${k}))`}function y(v,b){return t.indexOf(v)!==-1&&e[v]!==1?`${e[v]} - ${b[v]} - 1`:`${b[v]}`}}}function vue(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{dims:o}=r,i=s.shape.length,a=Tt(o,s.shape);if(i===0)return Js({inputs:{x:s},backend:t});const l=ye().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new yue(s.shape,a):new xue(s.shape,a);return t.runWebGLProgram(l,[s],s.dtype)}const wue={kernelName:uv,backendName:"webgl",kernelFunc:vue};class bue{constructor(e,t){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];const r=e[1],s=e[2];this.outputShape=e;let o="";typeof t=="number"?o=`float outputValue = ${t.toFixed(2)};`:o=`
vec3 fill = vec3(${t.join(",")});
float outputValue = fill[coords[3]];`,this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int x = coords[2];
int y = coords[1];
float coordXFloat = (float(x) - params[0]) * params[3] -
(float(y) - params[1]) * params[2];
float coordYFloat = (float(x) - params[0]) * params[2] +
(float(y) - params[1]) * params[3];
int coordX = int(round(coordXFloat + params[0]));
int coordY = int(round(coordYFloat + params[1]));
${o}
if(coordX >= 0 && coordX < ${s} && coordY >= 0 && coordY < ${r}) {
outputValue = getImage(coords[0], coordY, coordX, coords[3]);
}
setOutput(outputValue);
}
`}}const Cue={kernelName:sk,backendName:"webgl",kernelFunc:({inputs:n,attrs:e,backend:t})=>{const{image:r}=n,{radians:s,fillValue:o,center:i}=e,a=t,l=new bue(r.shape,o),[c,d]=qk(i,r.shape[1],r.shape[2]),p=[[c,d,Math.sin(s),Math.cos(s)]];return a.runWebGLProgram(l,[r],r.dtype,p)}};const Sue=`
// OpenGL ES does not support round function.
// The algorithm is based on banker's rounding.
float base = floor(x);
if ((x - base) < 0.5) {
return floor(x);
} else if ((x - base) > 0.5) {
return ceil(x);
} else {
if (mod(base, 2.0) == 0.0) {
return base;
} else {
return base + 1.0;
}
}
`,kue=zt({opSnippet:Sue}),Iue={kernelName:Pg,backendName:"webgl",kernelFunc:kue};const $ue="return inversesqrt(x);",Nue=zt({opSnippet:$ue,cpuKernelImpl:Bte}),Tue={kernelName:Lg,backendName:"webgl",kernelFunc:Nue};class XI{constructor(e,t,r,s,o,i,a=!0,l=!1){this.variableNames=["updates","indices","defaultValue"],this.outputShape=i;const c=on(o.length),d=on(i.length);let p="";r===1?p="i":r===2&&(p="i, j");const m=`getIndices(${p})`;let y="";s===1?y="i":s===2&&(y="i, coords[1]");const v=`getUpdates(${y})`;let b="";l&&(b="coords[0], coords[1]");const w=`getDefaultValue(${b})`,k=t>1?"strides[j]":"strides";this.userCode=`
${c} strides = ${c}(${o});
void main() {
${d} coords = getOutputCoords();
float sum = 0.0;
bool found = false;
for (int i = 0; i < ${e}; i++) {
int flattenedIndex = 0;
for (int j = 0; j < ${t}; j++) {
int index = round(${m});
flattenedIndex += index * ${k};
}
if (flattenedIndex == coords[0]) {
sum += ${v};
found = true;
}
}
setOutput(mix(${w}, sum, float(found)));
}
`}}class Eue{constructor(e,t,r,s,o,i,a=!0,l=!1){this.variableNames=["updates","indices","defaultValue"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=i;const c=on(o.length),d=on(i.length);let p="";r===1?p="i":r===2&&(p="i, j");const m=`getIndices(${p})`;let y="";s===1?y="i":s===2&&(y="i, coords[1]");const v=`getUpdates(${y})`;let b="";l&&(b="coords[0], coords[1]");const w=`getDefaultValue(${b})`,k=t>1?"strides[j]":"strides",I=t>1?"strides[j + 1]":"strides";this.userCode=`
${c} strides = ${c}(${o});
void main() {
${d} coords = getOutputCoords();
vec4 sum = vec4(0.);
vec4 found = vec4(0.);
for (int i = 0; i < ${e}; i+=2) {
ivec2 flattenedIndex = ivec2(0);
for (int j = 0; j < ${t}; j+=2) {
ivec4 index = round(${m});
flattenedIndex += index.xz * ${k};
if (j + 1 < ${t}) {
flattenedIndex += index.yw * ${I};
}
}
if (flattenedIndex[0] == coords[0] || flattenedIndex[1] == coords[0] ||
flattenedIndex[0] == coords[0] + 1 || flattenedIndex[1] == coords[0] + 1) {
vec4 updVals = ${v};
if (flattenedIndex[0] == coords[0]) {
sum.xy += updVals.xy;
found.xy = vec2(1.);
} else if (flattenedIndex[0] == coords[0] + 1) {
sum.zw += updVals.xy;
found.zw = vec2(1.);
}
if (flattenedIndex[1] == coords[0]) {
sum.xy += updVals.zw;
found.xy = vec2(1.);
} else if (flattenedIndex[1] == coords[0] + 1) {
sum.zw += updVals.zw;
found.zw = vec2(1.);
}
}
}
setOutput(mix(${w}, sum, found));
}
`}}function Rue(n){const{inputs:e,backend:t,attrs:r}=n,{indices:s,updates:o}=e,{shape:i}=r,{sliceRank:a,numUpdates:l,sliceSize:c,strides:d,outputSize:p}=ch(o,s,i),m=[p/c,c];if(p===0)return t.makeTensorInfo(i,s.dtype);const y=Ue({inputs:{x:s},backend:t,attrs:{shape:[l,a]}}),v=Ue({inputs:{x:o},backend:t,attrs:{shape:[l,c]}}),b=t.makeTensorInfo([],"float32",new Float32Array([0]));let w;ye().getBool("WEBGL_PACK")?w=new Eue(l,a,y.shape.length,v.shape.length,d,m):w=new XI(l,a,y.shape.length,v.shape.length,d,m);const k=t.runWebGLProgram(w,[v,y,b],v.dtype),I=Ue({inputs:{x:k},backend:t,attrs:{shape:i}});return t.disposeIntermediateTensorInfo(y),t.disposeIntermediateTensorInfo(v),t.disposeIntermediateTensorInfo(k),t.disposeIntermediateTensorInfo(b),I}const Aue={kernelName:OE,backendName:"webgl",kernelFunc:Rue};class _ue{constructor(e,t,r,s){this.variableNames=["sortedSequence","values"],this.customUniforms=[{name:"numInputs",type:"int"}],this.outputShape=[e,r];const o="while (left < right) {",i=`for (int i = 0; i < ${Math.ceil(Math.log2(t+1))}; ++i) { if (left >= right) break;`,a=ye().getNumber("WEBGL_VERSION")===2?o:i,l=s==="left"?"<":"<=";this.userCode=`
int findBound(int batch, float value) {
int left = 0;
int right = numInputs;
int mid;
${a}
mid = (left + right) / 2;
if (getSortedSequence(batch, mid) ${l} value) {
left = mid + 1;
} else {
right = mid;
}
}
return right;
}
void main() {
ivec2 coords = getOutputCoords();
int batch = coords[0];
int valueIndex = coords[1];
float value = getValues(batch, valueIndex);
setOutput(float(findBound(batch, value)));
}
`}}function Due(n){const{inputs:e,backend:t,attrs:r}=n,{sortedSequence:s,values:o}=e,{side:i}=r,a=new _ue(s.shape[0],s.shape[1],o.shape[1],i),l=[[s.shape[1]]];return t.runWebGLProgram(a,[s,o],"int32",l)}const Oue={kernelName:PE,backendName:"webgl",kernelFunc:Due};class Fue{constructor(e,t,r){this.variableNames=["c","a","b"],this.outputShape=t;let s,o;if(r>4)throw Error(`Where for rank ${r} is not yet supported`);if(r===1)o="resRC",s="resRC";else{const a=["resRC.x","resRC.y","resRC.z","resRC.w"],l=[],c=[];for(let d=0;d<t.length;d++)c.push(`${a[d]}`),d<e&&l.push(`${a[d]}`);s=l.join(),o=c.join()}const i=on(r);this.userCode=`
void main() {
${i} resRC = getOutputCoords();
float cVal = getC(${s});
if (cVal >= 1.0) {
setOutput(getA(${o}));
} else {
setOutput(getB(${o}));
}
}
`}}function Pue(n){const{inputs:e,backend:t}=n,{condition:r,t:s,e:o}=e,i=new Fue(r.shape.length,s.shape,s.shape.length);return t.runWebGLProgram(i,[r,s,o],Ys(s.dtype,o.dtype))}const Lue={kernelName:cv,backendName:"webgl",kernelFunc:Pue};const Mue=`
// Stable and Attracting Fixed Point (0, 1) for Normalized Weights.
// see: https://arxiv.org/abs/1706.02515
float scaleAlpha = ${Tv};
float scale = ${Ev};
return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);
`,zue=zt({opSnippet:Mue}),Bue={kernelName:Mg,backendName:"webgl",kernelFunc:zue};const Uue=Pf+`
return 1.0 / (1.0 + exp(-1.0 * x));
`,Wue=`
vec4 result = 1.0 / (1.0 + exp(-1.0 * x));
bvec4 isNaN = isnan(x);
result.r = isNaN.r ? x.r : result.r;
result.g = isNaN.g ? x.g : result.g;
result.b = isNaN.b ? x.b : result.b;
result.a = isNaN.a ? x.a : result.a;
return result;
`,Vue=zt({opSnippet:Uue,packedOpSnippet:Wue,cpuKernelImpl:Wte}),Gue={kernelName:Wg,backendName:"webgl",kernelFunc:Vue};const jue=`
if (isnan(x)) { return 0.0; }
return sign(x);
`,Hue=zt({opSnippet:jue}),que={kernelName:Ug,backendName:"webgl",kernelFunc:Hue};const Kue=Pf+`
return sin(x);
`,Xue=`
vec4 result = sin(x);
bvec4 isNaN = isnan(x);
${mh}
return result;
`,Yue=zt({opSnippet:Kue,packedOpSnippet:Xue}),Que={kernelName:zg,backendName:"webgl",kernelFunc:Yue};const Jue=`
float e2x = exp(x);
return (e2x - 1.0 / e2x) / 2.0;
`,Zue=zt({opSnippet:Jue}),ece={kernelName:Bg,backendName:"webgl",kernelFunc:Zue};const tce=`
float epsilon = 1.1920928955078125e-7;
float threshold = log(epsilon) + 2.0;
bool too_large = x > -threshold;
bool too_small = x < threshold;
float result;
float exp_x = exp(x);
if (too_large){
result = x;
}
else if (too_small){
result = exp_x;
}
else{
result = log(exp_x + 1.0);
}
return result;
`,nce=zt({opSnippet:tce}),rce={kernelName:Vg,backendName:"webgl",kernelFunc:nce};const sce=n=>{const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{blockShape:o,paddings:i}=r;U(s.shape.length<=4,()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");const a=o.reduce((k,I)=>k*I),l=[[0,0]];l.push(...i);for(let k=1+o.length;k<s.shape.length;++k)l.push([0,0]);const c=[],d=YF({inputs:{x:s},backend:t,attrs:{paddings:l,constantValue:0}}),p=sx(d.shape,o,a,!1),m=ox(p.length,o.length,!1),y=ix(d.shape,o,a,!1),v=Ue({inputs:{x:d},backend:t,attrs:{shape:p}}),b=cs({inputs:{x:v},backend:t,attrs:{perm:m}}),w=Ue({inputs:{x:b},backend:t,attrs:{shape:y}});return c.push(d),c.push(v),c.push(b),c.forEach(k=>t.disposeIntermediateTensorInfo(k)),w},oce={kernelName:fv,backendName:"webgl",kernelFunc:sce};function ice(n){const{inputs:e,backend:t}=n,{indices:r,values:s,denseShape:o,defaultValue:i}=e;if(o.shape.length!==1)throw new Error(`Dense shape must be a vector, saw:
${o.shape}`);if(r.shape.length!==2)throw new Error(`Indices must be a matrix, saw:
${r.shape}`);if(s.shape.length!==1)throw new Error(`Values must be a vector, saw:
${s.shape}`);if(i.shape.length!==0)throw new Error(`Default value must be a scalar, saw:
${i.shape}`);const a=t.readSync(r.dataId),l=t.readSync(s.dataId),c=t.readSync(o.dataId),d=t.readSync(i.dataId)[0],[p,m,y,v,b]=Gte(a,r.shape,r.dtype,l,s.dtype,c,d);return[t.makeTensorInfo(m,r.dtype,p),t.makeTensorInfo([m[0]],s.dtype,y),t.makeTensorInfo([v.length],"bool",new Uint8Array(v.map(w=>Number(w)))),t.makeTensorInfo([b.length],r.dtype,new Int32Array(b))]}const ace={kernelName:LE,backendName:"webgl",kernelFunc:ice};function lce(n){const{inputs:e,backend:t}=n,{inputIndices:r,inputShape:s,newShape:o}=e;if(r.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape ${r.shape}`);if(s.shape.length!==1)throw new Error(`Input shape should be a vector but received shape ${s.shape}`);if(o.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${o.shape}`);const i=Array.from(t.readSync(s.dataId)),a=t.readSync(r.dataId),l=Array.from(t.readSync(o.dataId)),[c,d,p]=jte(a,r.shape,r.dtype,i,l);return[t.makeTensorInfo(d,r.dtype,c),t.makeTensorInfo([p.length],o.dtype,new Int32Array(p))]}const uce={kernelName:ME,backendName:"webgl",kernelFunc:lce};function cce(n){const{inputs:e,backend:t}=n,{data:r,indices:s,segmentIds:o}=e;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(s.shape.length!==1)throw new Error(`Indices should be a vector but received shape
${s.shape}`);if(o.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
${o.shape}`);const i=t.readSync(r.dataId),a=t.readSync(s.dataId),l=t.readSync(o.dataId),[c,d]=bF(i,r.shape,r.dtype,a,l,!0);return t.makeTensorInfo(d,r.dtype,c)}const hce={kernelName:zE,backendName:"webgl",kernelFunc:cce};function dce(n){const{inputs:e,backend:t}=n,{data:r,indices:s,segmentIds:o}=e;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(s.shape.length!==1)throw new Error(`Indices should be a vector but received shape
${s.shape}`);if(o.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
${o.shape}`);const i=t.readSync(r.dataId),a=t.readSync(s.dataId),l=t.readSync(o.dataId),[c,d]=bF(i,r.shape,r.dtype,a,l);return t.makeTensorInfo(d,r.dtype,c)}const fce={kernelName:BE,backendName:"webgl",kernelFunc:dce};function pce(n){const{inputs:e,backend:t,attrs:r}=n,{sparseIndices:s,sparseValues:o,defaultValue:i}=e,{outputShape:a}=r,{sliceRank:l,numUpdates:c,sliceSize:d,strides:p,outputSize:m}=ch(o,s,a),y=!1;if(o.dtype==="string"){const k=t.bufferSync(s),I=t.bufferSync(o),N=au(t.readSync(i.dataId)[0]),T=Ute(k,I,a,m,d,c,l,p,N,y);return t.makeTensorInfo(a,T.dtype,T.values)}const v=new XI(c,l,s.shape.length,o.shape.length,p,[m,1],y),b=t.runWebGLProgram(v,[o,s,i],o.dtype),w=Ue({inputs:{x:b},backend:t,attrs:{shape:a}});return t.disposeIntermediateTensorInfo(b),w}const mce={kernelName:UE,backendName:"webgl",kernelFunc:pce};function gce(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{numOrSizeSplits:o,axis:i}=r,a=Tt(i,s.shape)[0],l=lI(s,o,a),c=s.shape.length,d=new Array(c).fill(0),p=s.shape.slice();return l.map(m=>{const y=[...p];y[a]=m;const v=Lf({inputs:{x:s},backend:t,attrs:{begin:d,size:y}});return d[a]+=m,v})}const xce={kernelName:pv,backendName:"webgl",kernelFunc:gce};const uT="return sqrt(x);",yce=zt({opSnippet:uT,packedOpSnippet:uT,cpuKernelImpl:Hte}),vce={kernelName:Gg,backendName:"webgl",kernelFunc:yce};const wce="return x * x;",bce=zt({opSnippet:wce}),Cce={kernelName:JS,backendName:"webgl",kernelFunc:bce};const cT="return (a - b) * (a - b);",Sce=Or({opSnippet:cT,packedOpSnippet:cT}),kce={kernelName:jg,backendName:"webgl",kernelFunc:Sce};function Ice(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e;if(s.dtype!=="string")throw new Error("Input must be of datatype string");const o=t.readSync(s.dataId),i=il(o),a=qte(i,"string",r);return t.makeTensorInfo(s.shape,"string",a)}const $ce={kernelName:ZS,backendName:"webgl",kernelFunc:Ice};function Nce({inputs:n,attrs:e,backend:t}){const{x:r}=n,s=Qo+`
return x > 0.0 ? 1.0 : float(${e.alpha});
`,o=new la(r.shape,s);return t.runWebGLProgram(o,[r],r.dtype)}const Tce={kernelName:Yg,backendName:"webgl",kernelFunc:Nce};class Ece{constructor(e,t,r){this.variableNames=["x"],this.outputShape=r;const s=r.length,o=on(r.length),i=on(r.length);let a="";if(s===1)a="coords * strides + begin";else{let l=0;a=r.map((c,d)=>(l++,r.length===1?`coords * strides[${d}] + begin[${d}]`:`coords[${l-1}] * strides[${d}] + begin[${d}]`)).join(",")}this.userCode=`
${o} begin = ${o}(${e});
${o} strides = ${o}(${t});
void main() {
${i} coords = getOutputCoords();
setOutput(getX(${a}));
}
`}}function Rce(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{begin:o,end:i,strides:a,beginMask:l,endMask:c,ellipsisMask:d,newAxisMask:p,shrinkAxisMask:m}=r,{finalShapeSparse:y,finalShape:v,isIdentity:b,sliceDim0:w,isSimpleSlice:k,begin:I,end:N,strides:T}=Gk(s.shape,o,i,a,l,c,d,p,m);let A;if(b)A=Ue({inputs:{x:s},backend:t,attrs:{shape:v}});else if(w||k){U(s.shape.length>=1,()=>`Input must have rank at least 1, got: ${s.shape.length}`);const P=Uk(I,N,T),B=Lf({inputs:{x:s},backend:t,attrs:{begin:I,size:P}});A=Ue({inputs:{x:B},backend:t,attrs:{shape:v}}),t.disposeIntermediateTensorInfo(B)}else if(t.shouldExecuteOnCPU([s])){const B=t.readSync(s.dataId),z=Nt(s.shape,s.dtype,B),L=Kte(y,z,T,I);A=t.makeTensorInfo(v,s.dtype,L.values)}else{const B=new Ece(I,T,y);A=t.runWebGLProgram(B,[s],s.dtype)}const O=Ue({inputs:{x:A},backend:t,attrs:{shape:v}});return t.disposeIntermediateTensorInfo(A),O}const Ace={kernelName:ek,backendName:"webgl",kernelFunc:Rce};function _ce(n){const{inputs:e,backend:t,attrs:r}=n,{separator:s,nGramWidths:o,leftPad:i,rightPad:a,padWidth:l,preserveShortSequences:c}=r,{data:d,dataSplits:p}=e,m=t.readSync(d.dataId),y=t.readSync(p.dataId),[v,b]=Xte(m,y,s,o,i,a,l,c);return[t.makeTensorInfo([v.length],"string",v),t.makeTensorInfo(p.shape,"int32",b)]}const Dce={kernelName:WE,backendName:"webgl",kernelFunc:_ce};function Oce(n){const{inputs:e,backend:t,attrs:r}=n,{skipEmpty:s}=r,{input:o,delimiter:i}=e;if(o.dtype!=="string")throw new Error("Input must be of datatype string");if(o.shape.length!==1)throw new Error(`Input must be a vector, got shape: ${o.shape}`);if(i.shape.length!==0)throw new Error(`Delimiter must be a scalar, got shape: ${i.shape}`);const a=t.readSync(o.dataId),l=t.readSync(i.dataId)[0],[c,d,p]=Yte(a,l,s),m=d.length;return[t.makeTensorInfo([m,2],"int32",c),t.makeTensorInfo([m],"string",d),t.makeTensorInfo([2],"int32",new Int32Array(p))]}const Fce={kernelName:VE,backendName:"webgl",kernelFunc:Oce};function Pce(n){const{inputs:e,backend:t,attrs:r}=n,{numBuckets:s}=r,{input:o}=e;if(o.dtype!=="string")throw new Error("Input must be of datatype string");if(s<=0)throw new Error("Number of buckets must be at least 1");const i=t.readSync(o.dataId),a=Qte(i,s);return t.makeTensorInfo(o.shape,"int32",a)}const Lce={kernelName:GE,backendName:"webgl",kernelFunc:Pce};const Mce="return tan(x);",zce=zt({opSnippet:Mce}),Bce={kernelName:qg,backendName:"webgl",kernelFunc:zce};const Uce=`
float e2x = exp(-2.0 * abs(x));
return sign(x) * (1.0 - e2x) / (1.0 + e2x);
`,Wce=zt({opSnippet:Uce}),Vce={kernelName:Kg,backendName:"webgl",kernelFunc:Wce};function Gce(n){const{inputs:e,backend:t,attrs:r}=n,{tensor:s,indices:o,updates:i}=e,{sliceRank:a,numUpdates:l,sliceSize:c,strides:d,outputSize:p}=ch(i,o,s.shape),m=[p/c,c];if(p===0)return t.makeTensorInfo(s.shape,o.dtype);const y=Ue({inputs:{x:o},backend:t,attrs:{shape:[l,a]}}),v=Ue({inputs:{x:i},backend:t,attrs:{shape:[l,c]}}),b=Ue({inputs:{x:s},backend:t,attrs:{shape:m}}),w=new XI(l,a,y.shape.length,v.shape.length,d,m,!1,!0),k=t.runWebGLProgram(w,[v,y,b],b.dtype),I=Ue({inputs:{x:k},backend:t,attrs:{shape:s.shape}});return t.disposeIntermediateTensorInfo(y),t.disposeIntermediateTensorInfo(v),t.disposeIntermediateTensorInfo(b),t.disposeIntermediateTensorInfo(k),I}const jce={kernelName:FE,backendName:"webgl",kernelFunc:Gce};class Hce{constructor(e,t){this.variableNames=["A"];const r=new Array(e.length);for(let i=0;i<r.length;i++)r[i]=e[i]*t[i];this.outputShape=r,this.rank=r.length;const s=on(this.rank),o=qce(e);this.userCode=`
void main() {
${s} resRC = getOutputCoords();
setOutput(getA(${o}));
}
`}}function qce(n){const e=n.length;if(e>5)throw Error(`Tile for rank ${e} is not yet supported`);if(e===1)return`imod(resRC, ${n[0]})`;const t=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[];for(let s=0;s<n.length;s++)r.push(`imod(${t[s]}, ${n[s]})`);return r.join()}function JF(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{reps:o}=r;if(s.dtype==="string"||s.shape.length>5){const l=t.readSync(s.dataId),c=s.dtype==="string"?l.map(m=>au(m)):l,d=Nt(s.shape,s.dtype,c),p=Zte(d,o);return t.makeTensorInfo(p.shape,p.dtype,p.values)}const i=new Hce(s.shape,o);return t.runWebGLProgram(i,[s],s.dtype)}const Kce={kernelName:Xg,backendName:"webgl",kernelFunc:JF};class Xce{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"negativeInf",type:"float"},{name:"dir",type:"int"},{name:"inc",type:"int"}],this.outputShape=e,this.userCode=`
void main() {
ivec2 coords = getOutputCoords();
int batch = coords[0];
int elemIdx = coords[1];
// We compare elements pair-wise within a group of size 2 * inc.
// The comparing rule for each group alternates between ascending
// and descending. Within each group, we compare each pair at
// positions i and i+inc. To decide whether an element at position i
// is x0 or x1, we mod it by 2 * inc, if the result is smaller than
// inc, it is in the first half of the group, we denote it as x0,
// otherwise we denote it as x1.
// For example, as shown in the Bitonic top K paper referenced above,
// Figure5(a) shows that element[1] is in the
// second half of the group when group size is 2, but it is in the
// first half of the group when group size is 4.
bool isFirstInPair = imod(elemIdx, 2 * inc) < inc;
int i = isFirstInPair ? elemIdx : elemIdx - inc;
int i0 = firstPass == 1 ? i : int(getIndices(batch, i));
int i1 = firstPass == 1 ? i + inc : int(getIndices(batch, i + inc));
float x0 = i0 < n ? getX(batch, i0) : negativeInf;
float x1 = i1 < n ? getX(batch, i1) : negativeInf;
// Denotes which direction indices are in (ascending or descending).
bool reverse = imod(elemIdx, 2 * dir) >= dir;
bool isGreater = x0 > x1 || (x0 == x1 && i1 > i0);
if (reverse == isGreater) { // Elements in opposite order of direction
int iTemp = i0;
i0 = i1;
i1 = iTemp;
}
if (isFirstInPair) {
setOutput(float(i0));
} else {
setOutput(float(i1));
}
}
`}}class Yce{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"k",type:"int"}],this.outputShape=e,this.userCode=`
void main() {
// Takes max of indices (0, k), (1, k + 1), (2, k + 2) ...
ivec2 coords = getOutputCoords();
int batch = coords[0];
int elemIdx = coords[1];
// The output size is half of the previous size.
// If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _ (k=4),
// we only need to output the indices at positions |, the indices at
// positions _ can be thrown away, see Figure5(b) After Phase 2
// (Merge phase) in the Bitonic Top K paper referenced above.
// For example, the paper shows we only need to output the orange bars.
// The output sequence should look like this | | | | | | | |.
// Because the sequence is halved, to map the output index back
// to the previous sequence to find the corresponding value,
// we need to double the index. When we double the index,
// we basically interpolate a position, so 2i looks like
// | _ | _ | _ | _ | _ | _ | _. We move the | to the first k position
// of each 2k positions by - elemIdx % k. E.g. for output at
// index 4,5,6,7, we want to get the corresponding element at
// original index 8,9,10,11, for output at index 8,9,10,11,
// we want to get the corresponding element at original index
// 16,17,18,19, so on and so forth.
int i = elemIdx < k ? elemIdx : (elemIdx * 2 - imod(elemIdx, k));
int i0 = firstPass == 1 ? i : int(getIndices(batch, i));
int i1 = firstPass == 1 ? i + k : int(getIndices(batch, i + k));
float x0 = getX(batch, i0);
float x1 = i1 < n ? getX(batch, i1) : x0;
setOutput(x0 >= x1 ? float(i0) : float(i1));
}
`}}function Nc(n,e){e!==null&&n.disposeIntermediateTensorInfo(e)}function hT(n){let e=1;for(;e<n;)e*=2;return e}function Qce(n){const{inputs:e,backend:t,attrs:r}=n,{x:s}=e,{k:o,sorted:i}=r,a=ye().getNumber("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD"),l=ye().getNumber("TOPK_K_CPU_HANDOFF_THRESHOLD"),c=s.shape,d=c[c.length-1];if(t.shouldExecuteOnCPU([s])||d<a||o>l){const L=t.readSync(s.dataId),[_,H]=ene(L,c,s.dtype,o,i);return[t.makeTensorInfo(_.shape,_.dtype,_.values),t.makeTensorInfo(H.shape,H.dtype,H.values)]}if(o===0)return c[c.length-1]=0,[t.makeTensorInfo(c,s.dtype,[]),t.makeTensorInfo(c,"int32",[])];if(d===1)return[s,wx({attrs:{shape:c,dtype:"int32",value:0},backend:t})];const p=t.texData.get(s.dataId),m=p!==null&&p.isPacked,y=m?t.unpackTensor(s):s,b=Se(c)/d,w=Ue({inputs:{x:y},attrs:{shape:[b,d]},backend:t});m&&Nc(t,y);const k=hT(o),I=hT(d);let N=null;const T=()=>N===null?[w,w]:[w,N],A=(L,_,H)=>{const Y=T(),re=new Xce(H),le=[[d],[N===null?1:0],[Number.NEGATIVE_INFINITY],[L],[_]],de=N;N=t.runWebGLProgram(re,Y,"int32",le),Nc(t,de)};for(let L=1;L<k;L*=2){const _=L*2;for(let H=L;H>=1;H/=2)A(_,H,[b,I])}for(let L=I;L>k;L/=2){const _=T(),H=new Yce([b,L/2]),re=[[d],[N===null?1:0],[k]],te=N;N=t.runWebGLProgram(H,_,"int32",re),Nc(t,te);const le=k/2,de=le*2;for(let j=le;j>=1;j/=2)A(de,j,N.shape)}let O=N;N=Lf({inputs:{x:N},backend:t,attrs:{begin:0,size:[b,o]}}),Nc(t,O);let P=GF({inputs:{x:w,indices:N},backend:t,attrs:{axis:1,batchDims:1}});Nc(t,w);const B=c.slice(0,-1);B.push(o),O=N,N=Ue({inputs:{x:N},attrs:{shape:B},backend:t}),Nc(t,O);const z=P;return P=Ue({inputs:{x:P},attrs:{shape:B},backend:t}),Nc(t,z),[P,N]}const Jce={kernelName:tk,backendName:"webgl",kernelFunc:Qce};class Zce{constructor(e,t,r,s,o,i){this.variableNames=["Image","Transforms"],this.outputShape=i;const a=r==="nearest"?1:2;let l;switch(s){case"constant":l=1;break;case"reflect":l=2;break;case"wrap":l=3;break;case"nearest":l=4;break;default:l=1;break}this.userCode=`
float mapCoord(float outCoord, float len) {
float inCoord = outCoord;
if(${l} == 2) {
if (inCoord < 0.0) {
if (len <= 1.0) {
inCoord = 0.0;
} else {
float sz2 = 2.0 * len;
if (inCoord < sz2) {
inCoord = sz2 * float(int(float(-inCoord / sz2))) +
inCoord;
}
inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0;
}
} else if (inCoord > len - 1.0) {
if (len <= 1.0) {
inCoord = 0.0;
} else {
float sz2 = 2.0 * len;
inCoord -= sz2 * float(int(float(inCoord / sz2)));
if (inCoord >= len) {
inCoord = sz2 - inCoord - 1.0;
}
}
}
return clamp(inCoord, 0.0, len - 1.0);
} else if (${l} == 3) {
if (inCoord < 0.0) {
if (len <= 1.0) {
inCoord = 0.0;
} else {
float sz = len - 1.0;
inCoord += len * (float(int(float(-inCoord / sz))) + 1.0);
}
} else if (inCoord > len - 1.0) {
if (len <= 1.0) {
inCoord = 0.0;
} else {
float sz = len - 1.0;
inCoord -= len * float(int(float(inCoord / sz)));
}
}
return clamp(inCoord, 0.0, len - 1.0);
} else if (${l} == 4) {
return clamp(outCoord, 0.0, len - 1.0);
} else {
return outCoord;
}
}
float readWithFillValue(int batch, int coordY, int coordX,
int channel) {
float outputValue;
if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t}) {
outputValue = getImage(batch, coordY, coordX, channel);
} else {
outputValue = float(${o});
}
return outputValue;
}
void main() {
ivec4 coords = getOutputCoords();
float outputValue;
int batch = coords[0];
int x = coords[2];
int y = coords[1];
int channel = coords[3];
float xf = float(x);
float yf = float(y);
float a1 = getTransforms(batch, 0);
float a2 = getTransforms(batch, 1);
float a3 = getTransforms(batch, 2);
float b1 = getTransforms(batch, 3);
float b2 = getTransforms(batch, 4);
float b3 = getTransforms(batch, 5);
float c1 = getTransforms(batch, 6);
float c2 = getTransforms(batch, 7);
float projection = c1 * xf + c2 * yf + 1.0;
if (projection == 0.0) {
outputValue = float(${o});
} else {
float inX = (a1 * xf + a2 * yf + a3) / projection;
float inY = (b1 * xf + b2 * yf + b3) / projection;
float mapX = mapCoord(inX, float(${t}));
float mapY = mapCoord(inY, float(${e}));
if (${a} == 1) {
int coordY = int(round(mapY));
int coordX = int(round(mapX));
outputValue = readWithFillValue(batch, coordY, coordX,
channel);
} else {
float yFloor = floor(mapY);
float xFloor = floor(mapX);
float yCeil = yFloor + 1.0;
float xCeil = xFloor + 1.0;
float valueYFloor = (xCeil - mapX) *
readWithFillValue(batch, int(yFloor), int(xFloor), channel) +
(mapX - xFloor) *
readWithFillValue(batch, int(yFloor), int(xCeil), channel);
float valueYCeil = (xCeil - mapX) *
readWithFillValue(batch, int(yCeil), int(xFloor), channel) +
(mapX - xFloor) *
readWithFillValue(batch, int(yCeil), int(xCeil), channel);
outputValue = (yCeil - mapY) * valueYFloor +
(mapY - yFloor) * valueYCeil;
}
}
setOutput(outputValue);
}
`}}function ehe(n){const{inputs:e,backend:t,attrs:r}=n,{image:s,transforms:o}=e,{interpolation:i,fillMode:a,fillValue:l,outputShape:c}=r,[d,p,m,y]=s.shape,[v,b]=c??[p,m],w=[d,v,b,y],k=new Zce(p,m,i,a,l,w);return t.runWebGLProgram(k,[s,o],"float32")}const the={kernelName:nk,backendName:"webgl",kernelFunc:ehe};function nhe(n){const{inputs:e,attrs:t,backend:r}=n,{axis:s}=t,{x:o}=e;xx(o,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");const i=r.readSync(o.dataId),{outputValues:a,outputShape:l,indices:c}=tne(i,s,o.shape,o.dtype);return[r.makeTensorInfo(l,o.dtype,a),r.makeTensorInfo([c.length],"int32",c)]}const rhe={kernelName:rk,backendName:"webgl",kernelFunc:nhe};function she(n){const{inputs:e,backend:t,attrs:r}=n,{value:s}=e;let{axis:o}=r;o<0&&(o+=s.shape.length);const i=s,a=i.shape.length,l=s.shape[o],c=new Array(a-1);let d=0;for(let b=0;b<a;b++)b!==o&&(c[d++]=i.shape[b]);const p=[],m=new Array(a).fill(0),y=i.shape.slice();y[o]=1;const v=new Array(l);for(let b=0;b<v.length;b++){m[o]=b;const w=Lf({inputs:{x:i},backend:t,attrs:{begin:m,size:y}}),k=Ue({inputs:{x:w},backend:t,attrs:{shape:c}});v[b]=k,p.push(w)}return p.forEach(b=>t.disposeIntermediateTensorInfo(b)),v}const ohe={kernelName:gv,backendName:"webgl",kernelFunc:she};class ihe{constructor(e,t){this.variableNames=["x","segmentIds"];const r=e.windowSize,s=e.batchSize,o=e.inSize,i=e.numSegments,a=i*Math.ceil(o/r);this.outputShape=[s,a];const l="0.0",c="sumValue",d=Math.floor(r/4)*4,p=r%4,m=`
sumValue += dot(values, segFilter);
`;let y="";o%r>0&&(y=`
if (inIdx < 0 || inIdx >= ${o}) {
return initializationValue;
}
`);let v="";o%r>0&&(v=`
if (inIdx < 0 || inIdx >= ${o}) {
return -1.0;
}
`),this.userCode=`
const float initializationValue = ${l};
float getValue(int batch, int inIdx) {
${y}
return getX(batch, inIdx);
}
float getSegmentIdAtIndex(int inIdx) {
${v}
return getSegmentIds(inIdx);
}
void main() {
ivec2 coords = getOutputCoords();
int batch = coords[0];
int outIdx = coords[1];
int inOffset = int(floor(float(outIdx) / float(
${i})) * float(${r}));
int currentSeg = int(mod(float(outIdx), float(${i})));
float sumValue = 0.0;
for (int i = 0; i < ${d}; i += 4) {
int inIdx = inOffset + i;
vec4 values = vec4(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2),
getValue(batch, inIdx + 3)
);
vec4 segFilter = vec4(
int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,
int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,
int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0
);
${m}
}
int inIdx = inOffset + ${d};
if (${p===1}) {
vec4 values = vec4(
getValue(batch, inIdx),
initializationValue,
initializationValue,
initializationValue
);
int inIdxSeg = int(getSegmentIdAtIndex(inIdx));
vec4 segFilter = vec4(
int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
0,
0,
0
);
${m}
} else if (${p===2}) {
vec4 values = vec4(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
initializationValue,
initializationValue
);
vec4 segFilter = vec4(
int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,
0,
0
);
${m}
} else if (${p===3}) {
vec4 values = vec4(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2),
initializationValue
);
vec4 segFilter = vec4(
int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,
int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,
0
);
${m}
}
setOutput(${c});
}
`}}function ahe(n){const{inputs:e,backend:t,attrs:r}=n,{x:s,segmentIds:o}=e,{numSegments:i}=r,a=s.shape.length,l=[];let c=0;const d=En([c],a);let p=s;d!=null&&(p=cs({inputs:{x:s},backend:t,attrs:{perm:d}}),l.push(p),c=Wn(1,a)[0]);const m=DA(p.shape,c,i),y=Se([p.shape[c]]),v=Ue({inputs:{x:p},backend:t,attrs:{shape:[-1,y]}});l.push(v);const b=ok(s.dtype),w=(T,A,O,P,B)=>{const z=T.shape[0],L=T.shape[1],_=_A(L,B),H={windowSize:_,inSize:L,batchSize:z,numSegments:B},Y=new ihe(H,A),re=t.compileAndRun(Y,[T,O],P);if(l.push(re),re.shape[1]===B)return re;const te=QF({backend:t,attrs:{start:0,stop:B,step:1,dtype:"float32"}}),le=JF({inputs:{x:te},backend:t,attrs:{reps:[L/_]}});return l.push(te),l.push(le),w(re,A,le,P,B)},k=w(v,"unsortedSegmentSum",o,b,i),I=Ue({inputs:{x:k},backend:t,attrs:{shape:m}});let N=I;if(d!=null){l.push(I);const T=yu(d);N=cs({inputs:{x:N},backend:t,attrs:{perm:T}})}return l.forEach(T=>t.disposeIntermediateTensorInfo(T)),N}const lhe={kernelName:xv,backendName:"webgl",kernelFunc:ahe};const uhe=[Hne,Kne,Qne,ere,nre,ore,are,ure,fre,mre,yre,bre,kre,Tre,Are,Dre,Fre,zre,Ure,Vre,qre,ese,nse,ise,lse,pse,gse,wse,Ene,Sse,Tse,_se,Mse,Use,Vse,jse,qse,Qse,eoe,roe,ooe,aoe,uoe,doe,poe,yoe,woe,Soe,$oe,Toe,_oe,Poe,Boe,Voe,Hoe,qoe,Xoe,Qoe,Zoe,tie,rie,aie,cie,fie,mie,yie,bie,Iie,Eie,Tne,Aie,$se,Oie,Lie,Bie,Ane,Gie,Kie,Yie,eae,rae,aae,cae,pae,yae,bae,Sae,Nae,Eae,Aae,Fae,Lae,zae,Uae,Vae,qae,Qae,tle,ule,One,fle,gle,vle,Cle,cse,Ile,Nle,Ele,_le,Ple,Dne,Mle,Ble,Wle,Gle,jle,hse,ole,Kle,Jle,nue,Pne,iue,uue,fue,gue,wue,Cue,Iue,Tue,Aue,Oue,Lue,Bue,Gue,que,Que,ece,Jre,ale,rce,oce,ace,uce,hce,fce,mce,xce,vce,Cce,kce,$ce,Tce,Ace,Dce,Fce,Lce,ile,Vne,Bce,Vce,jce,Kce,Jce,the,Gne,rhe,ohe,lhe,$le];for(const n of uhe)HE(n);var Im={exports:{}};var che=Im.exports,dT;function hhe(){return dT||(dT=1,(function(n,e){(function(){var t,r="4.17.21",s=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",i="Expected a function",a="Invalid `variable` option passed into `_.template`",l="__lodash_hash_undefined__",c=500,d="__lodash_placeholder__",p=1,m=2,y=4,v=1,b=2,w=1,k=2,I=4,N=8,T=16,A=32,O=64,P=128,B=256,z=512,L=30,_="...",H=800,Y=16,re=1,te=2,le=3,de=1/0,j=9007199254740991,ie=17976931348623157e292,se=NaN,V=4294967295,X=V-1,xe=V>>>1,Ie=[["ary",P],["bind",w],["bindKey",k],["curry",N],["curryRight",T],["flip",z],["partial",A],["partialRight",O],["rearg",B]],ke="[object Arguments]",Ee="[object Array]",Me="[object AsyncFunction]",ze="[object Boolean]",Be="[object Date]",Je="[object DOMException]",lt="[object Error]",pt="[object Function]",bt="[object GeneratorFunction]",Rt="[object Map]",Ot="[object Number]",Bt="[object Null]",At="[object Object]",Yt="[object Promise]",ds="[object Proxy]",Jt="[object RegExp]",cn="[object Set]",Rn="[object String]",fs="[object Symbol]",Xr="[object Undefined]",vr="[object WeakMap]",Zs="[object WeakSet]",wr="[object ArrayBuffer]",Qn="[object DataView]",So="[object Float32Array]",eo="[object Float64Array]",to="[object Int8Array]",Iu="[object Int16Array]",Jo="[object Int32Array]",hl="[object Uint8Array]",$u="[object Uint8ClampedArray]",Nu="[object Uint16Array]",Tu="[object Uint32Array]",Mf=/\b__p \+= '';/g,zf=/\b(__p \+=) '' \+/g,Bf=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ca=/&(?:amp|lt|gt|quot|#39);/g,Sa=/[&<>"']/g,bx=RegExp(Ca.source),Cx=RegExp(Sa.source),Sx=/<%-([\s\S]+?)%>/g,kx=/<%([\s\S]+?)%>/g,Uf=/<%=([\s\S]+?)%>/g,Wf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ix=/^\w*$/,Eu=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ru=/[\\^$.*+?()[\]{}|]/g,Au=RegExp(Ru.source),Vf=/^\s+/,_u=/\s/,xh=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,yh=/\{\n\/\* \[wrapped with (.+)\] \*/,Gf=/,? & /,qv=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Kv=/[()=,{}\[\]\/\s]/,Xv=/\\(\\)?/g,ka=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,jf=/\w*$/,$x=/^[-+]0x[0-9a-f]+$/i,Yv=/^0b[01]+$/i,Nx=/^\[object .+?Constructor\]$/,Tx=/^0o[0-7]+$/i,Ex=/^(?:0|[1-9]\d*)$/,Rx=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,vh=/($^)/,Qv=/['\n\r\u2028\u2029\\]/g,xn="\\ud800-\\udfff",Jv="\\u0300-\\u036f",Hf="\\ufe20-\\ufe2f",Ax="\\u20d0-\\u20ff",Du=Jv+Hf+Ax,_x="\\u2700-\\u27bf",qf="a-z\\xdf-\\xf6\\xf8-\\xff",wh="\\xac\\xb1\\xd7\\xf7",ko="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Zv="\\u2000-\\u206f",no=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Dx="A-Z\\xc0-\\xd6\\xd8-\\xde",Ox="\\ufe0e\\ufe0f",Fx=wh+ko+Zv+no,dl="[']",bh="["+xn+"]",fl="["+Fx+"]",Ia="["+Du+"]",Px="\\d+",ew="["+_x+"]",Ch="["+qf+"]",Kf="[^"+xn+Fx+Px+_x+qf+Dx+"]",Ou="\\ud83c[\\udffb-\\udfff]",Fu="(?:"+Ia+"|"+Ou+")",Lx="[^"+xn+"]",Pu="(?:\\ud83c[\\udde6-\\uddff]){2}",jt="[\\ud800-\\udbff][\\udc00-\\udfff]",$a="["+Dx+"]",Xf="\\u200d",Sh="(?:"+Ch+"|"+Kf+")",Mx="(?:"+$a+"|"+Kf+")",Yf="(?:"+dl+"(?:d|ll|m|re|s|t|ve))?",Qf="(?:"+dl+"(?:D|LL|M|RE|S|T|VE))?",kh=Fu+"?",Lu="["+Ox+"]?",Ri="(?:"+Xf+"(?:"+[Lx,Pu,jt].join("|")+")"+Lu+kh+")*",Ai="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",_i="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",pl=Lu+kh+Ri,Mu="(?:"+[ew,Pu,jt].join("|")+")"+pl,Di="(?:"+[Lx+Ia+"?",Ia,Pu,jt,bh].join("|")+")",tw=RegExp(dl,"g"),zx=RegExp(Ia,"g"),Na=RegExp(Ou+"(?="+Ou+")|"+Di+pl,"g"),nw=RegExp([$a+"?"+Ch+"+"+Yf+"(?="+[fl,$a,"$"].join("|")+")",Mx+"+"+Qf+"(?="+[fl,$a+Sh,"$"].join("|")+")",$a+"?"+Sh+"+"+Yf,$a+"+"+Qf,_i,Ai,Px,Mu].join("|"),"g"),Bx=RegExp("["+Xf+xn+Du+Ox+"]"),Ih=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Ux=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],rw=-1,Qt={};Qt[So]=Qt[eo]=Qt[to]=Qt[Iu]=Qt[Jo]=Qt[hl]=Qt[$u]=Qt[Nu]=Qt[Tu]=!0,Qt[ke]=Qt[Ee]=Qt[wr]=Qt[ze]=Qt[Qn]=Qt[Be]=Qt[lt]=Qt[pt]=Qt[Rt]=Qt[Ot]=Qt[At]=Qt[Jt]=Qt[cn]=Qt[Rn]=Qt[vr]=!1;var Ht={};Ht[ke]=Ht[Ee]=Ht[wr]=Ht[Qn]=Ht[ze]=Ht[Be]=Ht[So]=Ht[eo]=Ht[to]=Ht[Iu]=Ht[Jo]=Ht[Rt]=Ht[Ot]=Ht[At]=Ht[Jt]=Ht[cn]=Ht[Rn]=Ht[fs]=Ht[hl]=Ht[$u]=Ht[Nu]=Ht[Tu]=!0,Ht[lt]=Ht[pt]=Ht[vr]=!1;var ml={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},$h={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},sw={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},ow={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Jf=parseFloat,Nh=parseInt,Th=typeof ey=="object"&&ey&&ey.Object===Object&&ey,Wx=typeof self=="object"&&self&&self.Object===Object&&self,yn=Th||Wx||Function("return this")(),zu=e&&!e.nodeType&&e,Io=zu&&!0&&n&&!n.nodeType&&n,Zf=Io&&Io.exports===zu,gl=Zf&&Th.process,Fr=(function(){try{var ue=Io&&Io.require&&Io.require("util").types;return ue||gl&&gl.binding&&gl.binding("util")}catch{}})(),ep=Fr&&Fr.isArrayBuffer,Yr=Fr&&Fr.isDate,Ta=Fr&&Fr.isMap,Eh=Fr&&Fr.isRegExp,xl=Fr&&Fr.isSet,Vx=Fr&&Fr.isTypedArray;function Pr(ue,$e,ve){switch(ve.length){case 0:return ue.call($e);case 1:return ue.call($e,ve[0]);case 2:return ue.call($e,ve[0],ve[1]);case 3:return ue.call($e,ve[0],ve[1],ve[2])}return ue.apply($e,ve)}function tp(ue,$e,ve,je){for(var mt=-1,Ut=ue==null?0:ue.length;++mt<Ut;){var On=ue[mt];$e(je,On,ve(On),ue)}return je}function br(ue,$e){for(var ve=-1,je=ue==null?0:ue.length;++ve<je&&$e(ue[ve],ve,ue)!==!1;);return ue}function Rh(ue,$e){for(var ve=ue==null?0:ue.length;ve--&&$e(ue[ve],ve,ue)!==!1;);return ue}function np(ue,$e){for(var ve=-1,je=ue==null?0:ue.length;++ve<je;)if(!$e(ue[ve],ve,ue))return!1;return!0}function Oi(ue,$e){for(var ve=-1,je=ue==null?0:ue.length,mt=0,Ut=[];++ve<je;){var On=ue[ve];$e(On,ve,ue)&&(Ut[mt++]=On)}return Ut}function Ah(ue,$e){var ve=ue==null?0:ue.length;return!!ve&&yl(ue,$e,0)>-1}function rp(ue,$e,ve){for(var je=-1,mt=ue==null?0:ue.length;++je<mt;)if(ve($e,ue[je]))return!0;return!1}function an(ue,$e){for(var ve=-1,je=ue==null?0:ue.length,mt=Array(je);++ve<je;)mt[ve]=$e(ue[ve],ve,ue);return mt}function Fi(ue,$e){for(var ve=-1,je=$e.length,mt=ue.length;++ve<je;)ue[mt+ve]=$e[ve];return ue}function sp(ue,$e,ve,je){var mt=-1,Ut=ue==null?0:ue.length;for(je&&Ut&&(ve=ue[++mt]);++mt<Ut;)ve=$e(ve,ue[mt],mt,ue);return ve}function iw(ue,$e,ve,je){var mt=ue==null?0:ue.length;for(je&&mt&&(ve=ue[--mt]);mt--;)ve=$e(ve,ue[mt],mt,ue);return ve}function op(ue,$e){for(var ve=-1,je=ue==null?0:ue.length;++ve<je;)if($e(ue[ve],ve,ue))return!0;return!1}var aw=ap("length");function Gx(ue){return ue.split("")}function lw(ue){return ue.match(qv)||[]}function jx(ue,$e,ve){var je;return ve(ue,function(mt,Ut,On){if($e(mt,Ut,On))return je=Ut,!1}),je}function _h(ue,$e,ve,je){for(var mt=ue.length,Ut=ve+(je?1:-1);je?Ut--:++Ut<mt;)if($e(ue[Ut],Ut,ue))return Ut;return-1}function yl(ue,$e,ve){return $e===$e?Fh(ue,$e,ve):_h(ue,Hx,ve)}function ip(ue,$e,ve,je){for(var mt=ve-1,Ut=ue.length;++mt<Ut;)if(je(ue[mt],$e))return mt;return-1}function Hx(ue){return ue!==ue}function qx(ue,$e){var ve=ue==null?0:ue.length;return ve?lp(ue,$e)/ve:se}function ap(ue){return function($e){return $e==null?t:$e[ue]}}function Dh(ue){return function($e){return ue==null?t:ue[$e]}}function Kx(ue,$e,ve,je,mt){return mt(ue,function(Ut,On,Zt){ve=je?(je=!1,Ut):$e(ve,Ut,On,Zt)}),ve}function uw(ue,$e){var ve=ue.length;for(ue.sort($e);ve--;)ue[ve]=ue[ve].value;return ue}function lp(ue,$e){for(var ve,je=-1,mt=ue.length;++je<mt;){var Ut=$e(ue[je]);Ut!==t&&(ve=ve===t?Ut:ve+Ut)}return ve}function up(ue,$e){for(var ve=-1,je=Array(ue);++ve<ue;)je[ve]=$e(ve);return je}function cw(ue,$e){return an($e,function(ve){return[ve,ue[ve]]})}function Xx(ue){return ue&&ue.slice(0,Ph(ue)+1).replace(Vf,"")}function ps(ue){return function($e){return ue($e)}}function Bu(ue,$e){return an($e,function(ve){return ue[ve]})}function Zo(ue,$e){return ue.has($e)}function Yx(ue,$e){for(var ve=-1,je=ue.length;++ve<je&&yl($e,ue[ve],0)>-1;);return ve}function cp(ue,$e){for(var ve=ue.length;ve--&&yl($e,ue[ve],0)>-1;);return ve}function Qx(ue,$e){for(var ve=ue.length,je=0;ve--;)ue[ve]===$e&&++je;return je}var Jx=Dh(ml),Zx=Dh($h);function e0(ue){return"\\"+ow[ue]}function vl(ue,$e){return ue==null?t:ue[$e]}function wl(ue){return Bx.test(ue)}function hw(ue){return Ih.test(ue)}function dw(ue){for(var $e,ve=[];!($e=ue.next()).done;)ve.push($e.value);return ve}function Oh(ue){var $e=-1,ve=Array(ue.size);return ue.forEach(function(je,mt){ve[++$e]=[mt,je]}),ve}function hp(ue,$e){return function(ve){return ue($e(ve))}}function Es(ue,$e){for(var ve=-1,je=ue.length,mt=0,Ut=[];++ve<je;){var On=ue[ve];(On===$e||On===d)&&(ue[ve]=d,Ut[mt++]=ve)}return Ut}function Pi(ue){var $e=-1,ve=Array(ue.size);return ue.forEach(function(je){ve[++$e]=je}),ve}function fw(ue){var $e=-1,ve=Array(ue.size);return ue.forEach(function(je){ve[++$e]=[je,je]}),ve}function Fh(ue,$e,ve){for(var je=ve-1,mt=ue.length;++je<mt;)if(ue[je]===$e)return je;return-1}function pw(ue,$e,ve){for(var je=ve+1;je--;)if(ue[je]===$e)return je;return je}function Ea(ue){return wl(ue)?n0(ue):aw(ue)}function ms(ue){return wl(ue)?r0(ue):Gx(ue)}function Ph(ue){for(var $e=ue.length;$e--&&_u.test(ue.charAt($e)););return $e}var t0=Dh(sw);function n0(ue){for(var $e=Na.lastIndex=0;Na.test(ue);)++$e;return $e}function r0(ue){return ue.match(Na)||[]}function mw(ue){return ue.match(nw)||[]}var gw=(function ue($e){$e=$e==null?yn:bl.defaults(yn.Object(),$e,bl.pick(yn,Ux));var ve=$e.Array,je=$e.Date,mt=$e.Error,Ut=$e.Function,On=$e.Math,Zt=$e.Object,Uu=$e.RegExp,xw=$e.String,Rs=$e.TypeError,ei=ve.prototype,dp=Ut.prototype,$o=Zt.prototype,Cl=$e["__core-js_shared__"],Wu=dp.toString,Wt=$o.hasOwnProperty,Sl=0,Lh=(function(){var f=/[^.]+$/.exec(Cl&&Cl.keys&&Cl.keys.IE_PROTO||"");return f?"Symbol(src)_1."+f:""})(),Vu=$o.toString,Mh=Wu.call(Zt),s0=yn._,o0=Uu("^"+Wu.call(Wt).replace(Ru,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Gu=Zf?$e.Buffer:t,ti=$e.Symbol,ju=$e.Uint8Array,fp=Gu?Gu.allocUnsafe:t,ro=hp(Zt.getPrototypeOf,Zt),zh=Zt.create,Bh=$o.propertyIsEnumerable,Uh=ei.splice,i0=ti?ti.isConcatSpreadable:t,ni=ti?ti.iterator:t,Ra=ti?ti.toStringTag:t,Hu=(function(){try{var f=qi(Zt,"defineProperty");return f({},"",{}),f}catch{}})(),a0=$e.clearTimeout!==yn.clearTimeout&&$e.clearTimeout,hn=je&&je.now!==yn.Date.now&&je.now,pp=$e.setTimeout!==yn.setTimeout&&$e.setTimeout,Aa=On.ceil,Li=On.floor,Wh=Zt.getOwnPropertySymbols,mp=Gu?Gu.isBuffer:t,kl=$e.isFinite,Vh=ei.join,Il=hp(Zt.keys,Zt),Fn=On.max,Cr=On.min,yw=je.now,l0=$e.parseInt,qu=On.random,Gh=ei.reverse,Ku=qi($e,"DataView"),_a=qi($e,"Map"),Xu=qi($e,"Promise"),Mi=qi($e,"Set"),Yu=qi($e,"WeakMap"),$l=qi(Zt,"create"),jh=Yu&&new Yu,Nl={},gp=Ki(Ku),zi=Ki(_a),u0=Ki(Xu),Tl=Ki(Mi),No=Ki(Yu),Bi=ti?ti.prototype:t,gs=Bi?Bi.valueOf:t,Hh=Bi?Bi.toString:t;function M(f){if(Ln(f)&&!yt(f)&&!(f instanceof xt)){if(f instanceof Sr)return f;if(Wt.call(f,"__wrapped__"))return L0(f)}return new Sr(f)}var El=(function(){function f(){}return function(g){if(!Dn(g))return{};if(zh)return zh(g);f.prototype=g;var S=new f;return f.prototype=t,S}})();function To(){}function Sr(f,g){this.__wrapped__=f,this.__actions__=[],this.__chain__=!!g,this.__index__=0,this.__values__=t}M.templateSettings={escape:Sx,evaluate:kx,interpolate:Uf,variable:"",imports:{_:M}},M.prototype=To.prototype,M.prototype.constructor=M,Sr.prototype=El(To.prototype),Sr.prototype.constructor=Sr;function xt(f){this.__wrapped__=f,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=V,this.__views__=[]}function qh(){var f=new xt(this.__wrapped__);return f.__actions__=Mr(this.__actions__),f.__dir__=this.__dir__,f.__filtered__=this.__filtered__,f.__iteratees__=Mr(this.__iteratees__),f.__takeCount__=this.__takeCount__,f.__views__=Mr(this.__views__),f}function xp(){if(this.__filtered__){var f=new xt(this);f.__dir__=-1,f.__filtered__=!0}else f=this.clone(),f.__dir__*=-1;return f}function Rl(){var f=this.__wrapped__.value(),g=this.__dir__,S=yt(f),R=g<0,D=S?f.length:0,W=jp(0,D,this.__views__),q=W.start,J=W.end,fe=J-q,Ne=R?J:q-1,Te=this.__iteratees__,Oe=Te.length,We=0,et=Cr(fe,this.__takeCount__);if(!S||!R&&D==fe&&et==fe)return Ml(f,this.__actions__);var ht=[];e:for(;fe--&&We<et;){Ne+=g;for(var It=-1,dt=f[Ne];++It<Oe;){var Dt=Te[It],Pt=Dt.iteratee,po=Dt.type,bs=Pt(dt);if(po==te)dt=bs;else if(!bs){if(po==re)continue e;break e}}ht[We++]=dt}return ht}xt.prototype=El(To.prototype),xt.prototype.constructor=xt;function Qr(f){var g=-1,S=f==null?0:f.length;for(this.clear();++g<S;){var R=f[g];this.set(R[0],R[1])}}function dn(){this.__data__=$l?$l(null):{},this.size=0}function ln(f){var g=this.has(f)&&delete this.__data__[f];return this.size-=g?1:0,g}function Ui(f){var g=this.__data__;if($l){var S=g[f];return S===l?t:S}return Wt.call(g,f)?g[f]:t}function kr(f){var g=this.__data__;return $l?g[f]!==t:Wt.call(g,f)}function Jr(f,g){var S=this.__data__;return this.size+=this.has(f)?0:1,S[f]=$l&&g===t?l:g,this}Qr.prototype.clear=dn,Qr.prototype.delete=ln,Qr.prototype.get=Ui,Qr.prototype.has=kr,Qr.prototype.set=Jr;function Lr(f){var g=-1,S=f==null?0:f.length;for(this.clear();++g<S;){var R=f[g];this.set(R[0],R[1])}}function Al(){this.__data__=[],this.size=0}function Zr(f){var g=this.__data__,S=$r(g,f);if(S<0)return!1;var R=g.length-1;return S==R?g.pop():Uh.call(g,S,1),--this.size,!0}function Kh(f){var g=this.__data__,S=$r(g,f);return S<0?t:g[S][1]}function c0(f){return $r(this.__data__,f)>-1}function h0(f,g){var S=this.__data__,R=$r(S,f);return R<0?(++this.size,S.push([f,g])):S[R][1]=g,this}Lr.prototype.clear=Al,Lr.prototype.delete=Zr,Lr.prototype.get=Kh,Lr.prototype.has=c0,Lr.prototype.set=h0;function As(f){var g=-1,S=f==null?0:f.length;for(this.clear();++g<S;){var R=f[g];this.set(R[0],R[1])}}function d0(){this.size=0,this.__data__={hash:new Qr,map:new(_a||Lr),string:new Qr}}function ri(f){var g=dc(this,f).delete(f);return this.size-=g?1:0,g}function Xh(f){return dc(this,f).get(f)}function yp(f){return dc(this,f).has(f)}function f0(f,g){var S=dc(this,f),R=S.size;return S.set(f,g),this.size+=S.size==R?0:1,this}As.prototype.clear=d0,As.prototype.delete=ri,As.prototype.get=Xh,As.prototype.has=yp,As.prototype.set=f0;function Da(f){var g=-1,S=f==null?0:f.length;for(this.__data__=new As;++g<S;)this.add(f[g])}function Wi(f){return this.__data__.set(f,l),this}function _l(f){return this.__data__.has(f)}Da.prototype.add=Da.prototype.push=Wi,Da.prototype.has=_l;function Ir(f){var g=this.__data__=new Lr(f);this.size=g.size}function Yh(){this.__data__=new Lr,this.size=0}function Qh(f){var g=this.__data__,S=g.delete(f);return this.size=g.size,S}function _s(f){return this.__data__.get(f)}function Ds(f){return this.__data__.has(f)}function Oa(f,g){var S=this.__data__;if(S instanceof Lr){var R=S.__data__;if(!_a||R.length<s-1)return R.push([f,g]),this.size=++S.size,this;S=this.__data__=new As(R)}return S.set(f,g),this.size=S.size,this}Ir.prototype.clear=Yh,Ir.prototype.delete=Qh,Ir.prototype.get=_s,Ir.prototype.has=Ds,Ir.prototype.set=Oa;function Eo(f,g){var S=yt(f),R=!S&&kc(f),D=!S&&!R&&Kl(f),W=!S&&!R&&!D&&Bd(f),q=S||R||D||W,J=q?up(f.length,xw):[],fe=J.length;for(var Ne in f)(g||Wt.call(f,Ne))&&!(q&&(Ne=="length"||D&&(Ne=="offset"||Ne=="parent")||W&&(Ne=="buffer"||Ne=="byteLength"||Ne=="byteOffset")||wn(Ne,fe)))&&J.push(Ne);return J}function Ro(f){var g=f.length;return g?f[Pl(0,g-1)]:t}function Fa(f,g){return Sd(Mr(f),si(g,0,f.length))}function p0(f){return Sd(Mr(f))}function Qu(f,g,S){(S!==t&&!pi(f[g],S)||S===t&&!(g in f))&&Ao(f,g,S)}function Pa(f,g,S){var R=f[g];(!(Wt.call(f,g)&&pi(R,S))||S===t&&!(g in f))&&Ao(f,g,S)}function $r(f,g){for(var S=f.length;S--;)if(pi(f[S][0],g))return S;return-1}function xs(f,g,S,R){return Do(f,function(D,W,q){g(R,D,S(D),q)}),R}function fn(f,g){return f&&oo(g,Er(g),f)}function so(f,g){return f&&oo(g,Ws(g),f)}function Ao(f,g,S){g=="__proto__"&&Hu?Hu(f,g,{configurable:!0,enumerable:!0,value:S,writable:!0}):f[g]=S}function Jh(f,g){for(var S=-1,R=g.length,D=ve(R),W=f==null;++S<R;)D[S]=W?t:Ww(f,g[S]);return D}function si(f,g,S){return f===f&&(S!==t&&(f=f<=S?f:S),g!==t&&(f=f>=g?f:g)),f}function es(f,g,S,R,D,W){var q,J=g&p,fe=g&m,Ne=g&y;if(S&&(q=D?S(f,R,D,W):S(f)),q!==t)return q;if(!Dn(f))return f;var Te=yt(f);if(Te){if(q=pc(f),!J)return Mr(f,q)}else{var Oe=hr(f),We=Oe==pt||Oe==bt;if(Kl(f))return Dp(f,J);if(Oe==At||Oe==ke||We&&!D){if(q=fe||We?{}:dr(f),!J)return fe?ww(f,so(q,f)):hd(f,fn(q,f))}else{if(!Ht[Oe])return D?f:{};q=bw(f,Oe,J)}}W||(W=new Ir);var et=W.get(f);if(et)return et;W.set(f,q),e$(f)?f.forEach(function(dt){q.add(es(dt,g,S,dt,f,W))}):JI(f)&&f.forEach(function(dt,Dt){q.set(Dt,es(dt,g,S,Dt,f,W))});var ht=Ne?fe?hc:cc:fe?Ws:Er,It=Te?t:ht(f);return br(It||f,function(dt,Dt){It&&(Dt=dt,dt=f[Dt]),Pa(q,Dt,es(dt,g,S,Dt,f,W))}),q}function m0(f){var g=Er(f);return function(S){return Ju(S,f,g)}}function Ju(f,g,S){var R=S.length;if(f==null)return!R;for(f=Zt(f);R--;){var D=S[R],W=g[D],q=f[D];if(q===t&&!(D in f)||!W(q))return!1}return!0}function vp(f,g,S){if(typeof f!="function")throw new Rs(i);return jl(function(){f.apply(t,S)},g)}function _o(f,g,S,R){var D=-1,W=Ah,q=!0,J=f.length,fe=[],Ne=g.length;if(!J)return fe;S&&(g=an(g,ps(S))),R?(W=rp,q=!1):g.length>=s&&(W=Zo,q=!1,g=new Da(g));e:for(;++D<J;){var Te=f[D],Oe=S==null?Te:S(Te);if(Te=R||Te!==0?Te:0,q&&Oe===Oe){for(var We=Ne;We--;)if(g[We]===Oe)continue e;fe.push(Te)}else W(g,Oe,R)||fe.push(Te)}return fe}var Do=Ms(ys),g0=Ms(Vi,!0);function Zu(f,g){var S=!0;return Do(f,function(R,D,W){return S=!!g(R,D,W),S}),S}function La(f,g,S){for(var R=-1,D=f.length;++R<D;){var W=f[R],q=g(W);if(q!=null&&(J===t?q===q&&!fo(q):S(q,J)))var J=q,fe=W}return fe}function x0(f,g,S,R){var D=f.length;for(S=St(S),S<0&&(S=-S>D?0:D+S),R=R===t||R>D?D:St(R),R<0&&(R+=D),R=S>R?0:n$(R);S<R;)f[S++]=g;return f}function wp(f,g){var S=[];return Do(f,function(R,D,W){g(R,D,W)&&S.push(R)}),S}function $n(f,g,S,R,D){var W=-1,q=f.length;for(S||(S=wd),D||(D=[]);++W<q;){var J=f[W];g>0&&S(J)?g>1?$n(J,g-1,S,R,D):Fi(D,J):R||(D[D.length]=J)}return D}var Zh=fd(),ec=fd(!0);function ys(f,g){return f&&Zh(f,g,Er)}function Vi(f,g){return f&&ec(f,g,Er)}function Dl(f,g){return Oi(g,function(S){return Ya(f[S])})}function oi(f,g){g=Po(g,f);for(var S=0,R=g.length;f!=null&&S<R;)f=f[uo(g[S++])];return S&&S==R?f:t}function ed(f,g,S){var R=g(f);return yt(f)?R:Fi(R,S(f))}function ur(f){return f==null?f===t?Xr:Bt:Ra&&Ra in Zt(f)?vd(f):qp(f)}function Gi(f,g){return f>g}function Os(f,g){return f!=null&&Wt.call(f,g)}function Ma(f,g){return f!=null&&g in Zt(f)}function bp(f,g,S){return f>=Cr(g,S)&&f<Fn(g,S)}function td(f,g,S){for(var R=S?rp:Ah,D=f[0].length,W=f.length,q=W,J=ve(W),fe=1/0,Ne=[];q--;){var Te=f[q];q&&g&&(Te=an(Te,ps(g))),fe=Cr(Te.length,fe),J[q]=!S&&(g||D>=120&&Te.length>=120)?new Da(q&&Te):t}Te=f[0];var Oe=-1,We=J[0];e:for(;++Oe<D&&Ne.length<fe;){var et=Te[Oe],ht=g?g(et):et;if(et=S||et!==0?et:0,!(We?Zo(We,ht):R(Ne,ht,S))){for(q=W;--q;){var It=J[q];if(!(It?Zo(It,ht):R(f[q],ht,S)))continue e}We&&We.push(ht),Ne.push(et)}}return Ne}function ii(f,g,S,R){return ys(f,function(D,W,q){g(R,S(D),W,q)}),R}function Fs(f,g,S){g=Po(g,f),f=Jn(f,g);var R=f==null?f:f[uo(Ur(g))];return R==null?t:Pr(R,f,S)}function nd(f){return Ln(f)&&ur(f)==ke}function y0(f){return Ln(f)&&ur(f)==wr}function ai(f){return Ln(f)&&ur(f)==Be}function Ps(f,g,S,R,D){return f===g?!0:f==null||g==null||!Ln(f)&&!Ln(g)?f!==f&&g!==g:rd(f,g,S,R,Ps,D)}function rd(f,g,S,R,D,W){var q=yt(f),J=yt(g),fe=q?Ee:hr(f),Ne=J?Ee:hr(g);fe=fe==ke?At:fe,Ne=Ne==ke?At:Ne;var Te=fe==At,Oe=Ne==At,We=fe==Ne;if(We&&Kl(f)){if(!Kl(g))return!1;q=!0,Te=!1}if(We&&!Te)return W||(W=new Ir),q||Bd(f)?Vp(f,g,S,R,D,W):Gp(f,g,fe,S,R,D,W);if(!(S&v)){var et=Te&&Wt.call(f,"__wrapped__"),ht=Oe&&Wt.call(g,"__wrapped__");if(et||ht){var It=et?f.value():f,dt=ht?g.value():g;return W||(W=new Ir),D(It,dt,S,R,W)}}return We?(W||(W=new Ir),E0(f,g,S,R,D,W)):!1}function v0(f){return Ln(f)&&hr(f)==Rt}function Ol(f,g,S,R){var D=S.length,W=D,q=!R;if(f==null)return!W;for(f=Zt(f);D--;){var J=S[D];if(q&&J[2]?J[1]!==f[J[0]]:!(J[0]in f))return!1}for(;++D<W;){J=S[D];var fe=J[0],Ne=f[fe],Te=J[1];if(q&&J[2]){if(Ne===t&&!(fe in f))return!1}else{var Oe=new Ir;if(R)var We=R(Ne,Te,fe,f,g,Oe);if(!(We===t?Ps(Te,Ne,v|b,R,Oe):We))return!1}}return!0}function Cp(f){if(!Dn(f)||_0(f))return!1;var g=Ya(f)?o0:Nx;return g.test(Ki(f))}function tc(f){return Ln(f)&&ur(f)==Jt}function Oo(f){return Ln(f)&&hr(f)==cn}function nc(f){return Ln(f)&&Q0(f.length)&&!!Qt[ur(f)]}function Fl(f){return typeof f=="function"?f:f==null?Vs:typeof f=="object"?yt(f)?vn(f[0],f[1]):sd(f):f$(f)}function li(f){if(!di(f))return Il(f);var g=[];for(var S in Zt(f))Wt.call(f,S)&&S!="constructor"&&g.push(S);return g}function Sp(f){if(!Dn(f))return F0(f);var g=di(f),S=[];for(var R in f)R=="constructor"&&(g||!Wt.call(f,R))||S.push(R);return S}function ji(f,g){return f<g}function kp(f,g){var S=-1,R=Us(f)?ve(f.length):[];return Do(f,function(D,W,q){R[++S]=g(D,W,q)}),R}function sd(f){var g=fc(f);return g.length==1&&g[0][2]?bd(g[0][0],g[0][1]):function(S){return S===f||Ol(S,f,g)}}function vn(f,g){return qe(f)&&gc(g)?bd(uo(f),g):function(S){var R=Ww(S,f);return R===t&&R===g?Vw(S,f):Ps(g,R,v|b)}}function za(f,g,S,R,D){f!==g&&Zh(g,function(W,q){if(D||(D=new Ir),Dn(W))Ip(f,g,q,S,za,R,D);else{var J=R?R(zo(f,q),W,q+"",f,g,D):t;J===t&&(J=W),Qu(f,q,J)}},Ws)}function Ip(f,g,S,R,D,W,q){var J=zo(f,S),fe=zo(g,S),Ne=q.get(fe);if(Ne){Qu(f,S,Ne);return}var Te=W?W(J,fe,S+"",f,g,q):t,Oe=Te===t;if(Oe){var We=yt(fe),et=!We&&Kl(fe),ht=!We&&!et&&Bd(fe);Te=fe,We||et||ht?yt(J)?Te=J:qn(J)?Te=Mr(J):et?(Oe=!1,Te=Dp(fe,!0)):ht?(Oe=!1,Te=k0(fe,!0)):Te=[]:hm(fe)||kc(fe)?(Te=J,kc(J)?Te=r$(J):(!Dn(J)||Ya(J))&&(Te=dr(fe))):Oe=!1}Oe&&(q.set(fe,Te),D(Te,fe,R,W,q),q.delete(fe)),Qu(f,S,Te)}function od(f,g){var S=f.length;if(S)return g+=g<0?S:0,wn(g,S)?f[g]:t}function rc(f,g,S){g.length?g=an(g,function(W){return yt(W)?function(q){return oi(q,W.length===1?W[0]:W)}:W}):g=[Vs];var R=-1;g=an(g,ps(at()));var D=kp(f,function(W,q,J){var fe=an(g,function(Ne){return Ne(W)});return{criteria:fe,index:++R,value:W}});return uw(D,function(W,q){return vw(W,q,S)})}function $p(f,g){return Hi(f,g,function(S,R){return Vw(f,R)})}function Hi(f,g,S){for(var R=-1,D=g.length,W={};++R<D;){var q=g[R],J=oi(f,q);S(J,q)&&Ua(W,Po(q,f),J)}return W}function Cn(f){return function(g){return oi(g,f)}}function An(f,g,S,R){var D=R?ip:yl,W=-1,q=g.length,J=f;for(f===g&&(g=Mr(g)),S&&(J=an(f,ps(S)));++W<q;)for(var fe=0,Ne=g[W],Te=S?S(Ne):Ne;(fe=D(J,Te,fe,R))>-1;)J!==f&&Uh.call(J,fe,1),Uh.call(f,fe,1);return f}function jn(f,g){for(var S=f?g.length:0,R=S-1;S--;){var D=g[S];if(S==R||D!==W){var W=D;wn(D)?Uh.call(f,D,1):ld(f,D)}}return f}function Pl(f,g){return f+Li(qu()*(g-f+1))}function sc(f,g,S,R){for(var D=-1,W=Fn(Aa((g-f)/(S||1)),0),q=ve(W);W--;)q[R?W:++D]=f,f+=S;return q}function Ba(f,g){var S="";if(!f||g<1||g>j)return S;do g%2&&(S+=f),g=Li(g/2),g&&(f+=f);while(g);return S}function Ct(f,g){return vs(Cd(f,g,Vs),f+"")}function Nr(f){return Ro(Ud(f))}function Np(f,g){var S=Ud(f);return Sd(S,si(g,0,S.length))}function Ua(f,g,S,R){if(!Dn(f))return f;g=Po(g,f);for(var D=-1,W=g.length,q=W-1,J=f;J!=null&&++D<W;){var fe=uo(g[D]),Ne=S;if(fe==="__proto__"||fe==="constructor"||fe==="prototype")return f;if(D!=q){var Te=J[fe];Ne=R?R(Te,fe,J):t,Ne===t&&(Ne=Dn(Te)?Te:wn(g[D+1])?[]:{})}Pa(J,fe,Ne),J=J[fe]}return f}var id=jh?function(f,g){return jh.set(f,g),f}:Vs,Fo=Hu?function(f,g){return Hu(f,"toString",{configurable:!0,enumerable:!1,value:jw(g),writable:!0})}:Vs;function Ls(f){return Sd(Ud(f))}function Tr(f,g,S){var R=-1,D=f.length;g<0&&(g=-g>D?0:D+g),S=S>D?D:S,S<0&&(S+=D),D=g>S?0:S-g>>>0,g>>>=0;for(var W=ve(D);++R<D;)W[R]=f[R+g];return W}function Tp(f,g){var S;return Do(f,function(R,D,W){return S=g(R,D,W),!S}),!!S}function Ll(f,g,S){var R=0,D=f==null?R:f.length;if(typeof g=="number"&&g===g&&D<=xe){for(;R<D;){var W=R+D>>>1,q=f[W];q!==null&&!fo(q)&&(S?q<=g:q<g)?R=W+1:D=W}return D}return ad(f,g,Vs,S)}function ad(f,g,S,R){var D=0,W=f==null?0:f.length;if(W===0)return 0;g=S(g);for(var q=g!==g,J=g===null,fe=fo(g),Ne=g===t;D<W;){var Te=Li((D+W)/2),Oe=S(f[Te]),We=Oe!==t,et=Oe===null,ht=Oe===Oe,It=fo(Oe);if(q)var dt=R||ht;else Ne?dt=ht&&(R||We):J?dt=ht&&We&&(R||!et):fe?dt=ht&&We&&!et&&(R||!It):et||It?dt=!1:dt=R?Oe<=g:Oe<g;dt?D=Te+1:W=Te}return Cr(W,X)}function Ep(f,g){for(var S=-1,R=f.length,D=0,W=[];++S<R;){var q=f[S],J=g?g(q):q;if(!S||!pi(J,fe)){var fe=J;W[D++]=q===0?0:q}}return W}function Rp(f){return typeof f=="number"?f:fo(f)?se:+f}function ts(f){if(typeof f=="string")return f;if(yt(f))return an(f,ts)+"";if(fo(f))return Hh?Hh.call(f):"";var g=f+"";return g=="0"&&1/f==-de?"-0":g}function ui(f,g,S){var R=-1,D=Ah,W=f.length,q=!0,J=[],fe=J;if(S)q=!1,D=rp;else if(W>=s){var Ne=g?null:T0(f);if(Ne)return Pi(Ne);q=!1,D=Zo,fe=new Da}else fe=g?[]:J;e:for(;++R<W;){var Te=f[R],Oe=g?g(Te):Te;if(Te=S||Te!==0?Te:0,q&&Oe===Oe){for(var We=fe.length;We--;)if(fe[We]===Oe)continue e;g&&fe.push(Oe),J.push(Te)}else D(fe,Oe,S)||(fe!==J&&fe.push(Oe),J.push(Te))}return J}function ld(f,g){return g=Po(g,f),f=Jn(f,g),f==null||delete f[uo(Ur(g))]}function Ap(f,g,S,R){return Ua(f,g,S(oi(f,g)),R)}function oc(f,g,S,R){for(var D=f.length,W=R?D:-1;(R?W--:++W<D)&&g(f[W],W,f););return S?Tr(f,R?0:W,R?W+1:D):Tr(f,R?W+1:0,R?D:W)}function Ml(f,g){var S=f;return S instanceof xt&&(S=S.value()),sp(g,function(R,D){return D.func.apply(D.thisArg,Fi([R],D.args))},S)}function ud(f,g,S){var R=f.length;if(R<2)return R?ui(f[0]):[];for(var D=-1,W=ve(R);++D<R;)for(var q=f[D],J=-1;++J<R;)J!=D&&(W[D]=_o(W[D]||q,f[J],g,S));return ui($n(W,1),g,S)}function ic(f,g,S){for(var R=-1,D=f.length,W=g.length,q={};++R<D;){var J=R<W?g[R]:t;S(q,f[R],J)}return q}function zl(f){return qn(f)?f:[]}function cd(f){return typeof f=="function"?f:Vs}function Po(f,g){return yt(f)?f:qe(f,g)?[f]:Yp(en(f))}var w0=Ct;function ci(f,g,S){var R=f.length;return S=S===t?R:S,!g&&S>=R?f:Tr(f,g,S)}var _p=a0||function(f){return yn.clearTimeout(f)};function Dp(f,g){if(g)return f.slice();var S=f.length,R=fp?fp(S):new f.constructor(S);return f.copy(R),R}function ac(f){var g=new f.constructor(f.byteLength);return new ju(g).set(new ju(f)),g}function b0(f,g){var S=g?ac(f.buffer):f.buffer;return new f.constructor(S,f.byteOffset,f.byteLength)}function C0(f){var g=new f.constructor(f.source,jf.exec(f));return g.lastIndex=f.lastIndex,g}function S0(f){return gs?Zt(gs.call(f)):{}}function k0(f,g){var S=g?ac(f.buffer):f.buffer;return new f.constructor(S,f.byteOffset,f.length)}function Op(f,g){if(f!==g){var S=f!==t,R=f===null,D=f===f,W=fo(f),q=g!==t,J=g===null,fe=g===g,Ne=fo(g);if(!J&&!Ne&&!W&&f>g||W&&q&&fe&&!J&&!Ne||R&&q&&fe||!S&&fe||!D)return 1;if(!R&&!W&&!Ne&&f<g||Ne&&S&&D&&!R&&!W||J&&S&&D||!q&&D||!fe)return-1}return 0}function vw(f,g,S){for(var R=-1,D=f.criteria,W=g.criteria,q=D.length,J=S.length;++R<q;){var fe=Op(D[R],W[R]);if(fe){if(R>=J)return fe;var Ne=S[R];return fe*(Ne=="desc"?-1:1)}}return f.index-g.index}function I0(f,g,S,R){for(var D=-1,W=f.length,q=S.length,J=-1,fe=g.length,Ne=Fn(W-q,0),Te=ve(fe+Ne),Oe=!R;++J<fe;)Te[J]=g[J];for(;++D<q;)(Oe||D<W)&&(Te[S[D]]=f[D]);for(;Ne--;)Te[J++]=f[D++];return Te}function Fp(f,g,S,R){for(var D=-1,W=f.length,q=-1,J=S.length,fe=-1,Ne=g.length,Te=Fn(W-J,0),Oe=ve(Te+Ne),We=!R;++D<Te;)Oe[D]=f[D];for(var et=D;++fe<Ne;)Oe[et+fe]=g[fe];for(;++q<J;)(We||D<W)&&(Oe[et+S[q]]=f[D++]);return Oe}function Mr(f,g){var S=-1,R=f.length;for(g||(g=ve(R));++S<R;)g[S]=f[S];return g}function oo(f,g,S,R){var D=!S;S||(S={});for(var W=-1,q=g.length;++W<q;){var J=g[W],fe=R?R(S[J],f[J],J,S,f):t;fe===t&&(fe=f[J]),D?Ao(S,J,fe):Pa(S,J,fe)}return S}function hd(f,g){return oo(f,io(f),g)}function ww(f,g){return oo(f,R0(f),g)}function dd(f,g){return function(S,R){var D=yt(S)?tp:xs,W=g?g():{};return D(S,f,at(R,2),W)}}function Bl(f){return Ct(function(g,S){var R=-1,D=S.length,W=D>1?S[D-1]:t,q=D>2?S[2]:t;for(W=f.length>3&&typeof W=="function"?(D--,W):t,q&&Br(S[0],S[1],q)&&(W=D<3?t:W,D=1),g=Zt(g);++R<D;){var J=S[R];J&&f(g,J,R,W)}return g})}function Ms(f,g){return function(S,R){if(S==null)return S;if(!Us(S))return f(S,R);for(var D=S.length,W=g?D:-1,q=Zt(S);(g?W--:++W<D)&&R(q[W],W,q)!==!1;);return S}}function fd(f){return function(g,S,R){for(var D=-1,W=Zt(g),q=R(g),J=q.length;J--;){var fe=q[f?J:++D];if(S(W[fe],fe,W)===!1)break}return g}}function pd(f,g,S){var R=g&w,D=Ul(f);function W(){var q=this&&this!==yn&&this instanceof W?D:f;return q.apply(R?S:this,arguments)}return W}function Pp(f){return function(g){g=en(g);var S=wl(g)?ms(g):t,R=S?S[0]:g.charAt(0),D=S?ci(S,1).join(""):g.slice(1);return R[f]()+D}}function Wa(f){return function(g){return sp(h$(c$(g).replace(tw,"")),f,"")}}function Ul(f){return function(){var g=arguments;switch(g.length){case 0:return new f;case 1:return new f(g[0]);case 2:return new f(g[0],g[1]);case 3:return new f(g[0],g[1],g[2]);case 4:return new f(g[0],g[1],g[2],g[3]);case 5:return new f(g[0],g[1],g[2],g[3],g[4]);case 6:return new f(g[0],g[1],g[2],g[3],g[4],g[5]);case 7:return new f(g[0],g[1],g[2],g[3],g[4],g[5],g[6])}var S=El(f.prototype),R=f.apply(S,g);return Dn(R)?R:S}}function Lp(f,g,S){var R=Ul(f);function D(){for(var W=arguments.length,q=ve(W),J=W,fe=hi(D);J--;)q[J]=arguments[J];var Ne=W<3&&q[0]!==fe&&q[W-1]!==fe?[]:Es(q,fe);if(W-=Ne.length,W<S)return zr(f,g,Wl,D.placeholder,t,q,Ne,t,t,S-W);var Te=this&&this!==yn&&this instanceof D?R:f;return Pr(Te,this,q)}return D}function Va(f){return function(g,S,R){var D=Zt(g);if(!Us(g)){var W=at(S,3);g=Er(g),S=function(J){return W(D[J],J,D)}}var q=f(g,S,R);return q>-1?D[W?g[q]:q]:t}}function md(f){return Mo(function(g){var S=g.length,R=S,D=Sr.prototype.thru;for(f&&g.reverse();R--;){var W=g[R];if(typeof W!="function")throw new Rs(i);if(D&&!q&&Vl(W)=="wrapper")var q=new Sr([],!0)}for(R=q?R:S;++R<S;){W=g[R];var J=Vl(W),fe=J=="wrapper"?yd(W):t;fe&&mc(fe[0])&&fe[1]==(P|N|A|B)&&!fe[4].length&&fe[9]==1?q=q[Vl(fe[0])].apply(q,fe[3]):q=W.length==1&&mc(W)?q[J]():q.thru(W)}return function(){var Ne=arguments,Te=Ne[0];if(q&&Ne.length==1&&yt(Te))return q.plant(Te).value();for(var Oe=0,We=S?g[Oe].apply(this,Ne):Te;++Oe<S;)We=g[Oe].call(this,We);return We}})}function Wl(f,g,S,R,D,W,q,J,fe,Ne){var Te=g&P,Oe=g&w,We=g&k,et=g&(N|T),ht=g&z,It=We?t:Ul(f);function dt(){for(var Dt=arguments.length,Pt=ve(Dt),po=Dt;po--;)Pt[po]=arguments[po];if(et)var bs=hi(dt),mo=Qx(Pt,bs);if(R&&(Pt=I0(Pt,R,D,et)),W&&(Pt=Fp(Pt,W,q,et)),Dt-=mo,et&&Dt<Ne){var Kn=Es(Pt,bs);return zr(f,g,Wl,dt.placeholder,S,Pt,Kn,J,fe,Ne-Dt)}var mi=Oe?S:this,Ja=We?mi[f]:f;return Dt=Pt.length,J?Pt=ao(Pt,J):ht&&Dt>1&&Pt.reverse(),Te&&fe<Dt&&(Pt.length=fe),this&&this!==yn&&this instanceof dt&&(Ja=It||Ul(Ja)),Ja.apply(mi,Pt)}return dt}function $0(f,g){return function(S,R){return ii(S,f,g(R),{})}}function lc(f,g){return function(S,R){var D;if(S===t&&R===t)return g;if(S!==t&&(D=S),R!==t){if(D===t)return R;typeof S=="string"||typeof R=="string"?(S=ts(S),R=ts(R)):(S=Rp(S),R=Rp(R)),D=f(S,R)}return D}}function gd(f){return Mo(function(g){return g=an(g,ps(at())),Ct(function(S){var R=this;return f(g,function(D){return Pr(D,R,S)})})})}function uc(f,g){g=g===t?" ":ts(g);var S=g.length;if(S<2)return S?Ba(g,f):g;var R=Ba(g,Aa(f/Ea(g)));return wl(g)?ci(ms(R),0,f).join(""):R.slice(0,f)}function N0(f,g,S,R){var D=g&w,W=Ul(f);function q(){for(var J=-1,fe=arguments.length,Ne=-1,Te=R.length,Oe=ve(Te+fe),We=this&&this!==yn&&this instanceof q?W:f;++Ne<Te;)Oe[Ne]=R[Ne];for(;fe--;)Oe[Ne++]=arguments[++J];return Pr(We,D?S:this,Oe)}return q}function Mp(f){return function(g,S,R){return R&&typeof R!="number"&&Br(g,S,R)&&(S=R=t),g=Qa(g),S===t?(S=g,g=0):S=Qa(S),R=R===t?g<S?1:-1:Qa(R),sc(g,S,R,f)}}function xd(f){return function(g,S){return typeof g=="string"&&typeof S=="string"||(g=Bo(g),S=Bo(S)),f(g,S)}}function zr(f,g,S,R,D,W,q,J,fe,Ne){var Te=g&N,Oe=Te?q:t,We=Te?t:q,et=Te?W:t,ht=Te?t:W;g|=Te?A:O,g&=~(Te?O:A),g&I||(g&=-4);var It=[f,g,D,et,Oe,ht,We,J,fe,Ne],dt=S.apply(t,It);return mc(f)&&Kp(dt,It),dt.placeholder=R,Xp(dt,f,g)}function cr(f){var g=On[f];return function(S,R){if(S=Bo(S),R=R==null?0:Cr(St(R),292),R&&kl(S)){var D=(en(S)+"e").split("e"),W=g(D[0]+"e"+(+D[1]+R));return D=(en(W)+"e").split("e"),+(D[0]+"e"+(+D[1]-R))}return g(S)}}var T0=Mi&&1/Pi(new Mi([,-0]))[1]==de?function(f){return new Mi(f)}:Kw;function zp(f){return function(g){var S=hr(g);return S==Rt?Oh(g):S==cn?fw(g):cw(g,f(g))}}function Lo(f,g,S,R,D,W,q,J){var fe=g&k;if(!fe&&typeof f!="function")throw new Rs(i);var Ne=R?R.length:0;if(Ne||(g&=-97,R=D=t),q=q===t?q:Fn(St(q),0),J=J===t?J:St(J),Ne-=D?D.length:0,g&O){var Te=R,Oe=D;R=D=t}var We=fe?t:yd(f),et=[f,g,S,R,D,Te,Oe,W,q,J];if(We&&O0(et,We),f=et[0],g=et[1],S=et[2],R=et[3],D=et[4],J=et[9]=et[9]===t?fe?0:f.length:Fn(et[9]-Ne,0),!J&&g&(N|T)&&(g&=-25),!g||g==w)var ht=pd(f,g,S);else g==N||g==T?ht=Lp(f,g,J):(g==A||g==(w|A))&&!D.length?ht=N0(f,g,S,R):ht=Wl.apply(t,et);var It=We?id:Kp;return Xp(It(ht,et),f,g)}function Bp(f,g,S,R){return f===t||pi(f,$o[S])&&!Wt.call(R,S)?g:f}function Up(f,g,S,R,D,W){return Dn(f)&&Dn(g)&&(W.set(g,f),za(f,g,t,Up,W),W.delete(g)),f}function Wp(f){return hm(f)?t:f}function Vp(f,g,S,R,D,W){var q=S&v,J=f.length,fe=g.length;if(J!=fe&&!(q&&fe>J))return!1;var Ne=W.get(f),Te=W.get(g);if(Ne&&Te)return Ne==g&&Te==f;var Oe=-1,We=!0,et=S&b?new Da:t;for(W.set(f,g),W.set(g,f);++Oe<J;){var ht=f[Oe],It=g[Oe];if(R)var dt=q?R(It,ht,Oe,g,f,W):R(ht,It,Oe,f,g,W);if(dt!==t){if(dt)continue;We=!1;break}if(et){if(!op(g,function(Dt,Pt){if(!Zo(et,Pt)&&(ht===Dt||D(ht,Dt,S,R,W)))return et.push(Pt)})){We=!1;break}}else if(!(ht===It||D(ht,It,S,R,W))){We=!1;break}}return W.delete(f),W.delete(g),We}function Gp(f,g,S,R,D,W,q){switch(S){case Qn:if(f.byteLength!=g.byteLength||f.byteOffset!=g.byteOffset)return!1;f=f.buffer,g=g.buffer;case wr:return!(f.byteLength!=g.byteLength||!W(new ju(f),new ju(g)));case ze:case Be:case Ot:return pi(+f,+g);case lt:return f.name==g.name&&f.message==g.message;case Jt:case Rn:return f==g+"";case Rt:var J=Oh;case cn:var fe=R&v;if(J||(J=Pi),f.size!=g.size&&!fe)return!1;var Ne=q.get(f);if(Ne)return Ne==g;R|=b,q.set(f,g);var Te=Vp(J(f),J(g),R,D,W,q);return q.delete(f),Te;case fs:if(gs)return gs.call(f)==gs.call(g)}return!1}function E0(f,g,S,R,D,W){var q=S&v,J=cc(f),fe=J.length,Ne=cc(g),Te=Ne.length;if(fe!=Te&&!q)return!1;for(var Oe=fe;Oe--;){var We=J[Oe];if(!(q?We in g:Wt.call(g,We)))return!1}var et=W.get(f),ht=W.get(g);if(et&&ht)return et==g&&ht==f;var It=!0;W.set(f,g),W.set(g,f);for(var dt=q;++Oe<fe;){We=J[Oe];var Dt=f[We],Pt=g[We];if(R)var po=q?R(Pt,Dt,We,g,f,W):R(Dt,Pt,We,f,g,W);if(!(po===t?Dt===Pt||D(Dt,Pt,S,R,W):po)){It=!1;break}dt||(dt=We=="constructor")}if(It&&!dt){var bs=f.constructor,mo=g.constructor;bs!=mo&&"constructor"in f&&"constructor"in g&&!(typeof bs=="function"&&bs instanceof bs&&typeof mo=="function"&&mo instanceof mo)&&(It=!1)}return W.delete(f),W.delete(g),It}function Mo(f){return vs(Cd(f,t,Id),f+"")}function cc(f){return ed(f,Er,io)}function hc(f){return ed(f,Ws,R0)}var yd=jh?function(f){return jh.get(f)}:Kw;function Vl(f){for(var g=f.name+"",S=Nl[g],R=Wt.call(Nl,g)?S.length:0;R--;){var D=S[R],W=D.func;if(W==null||W==f)return D.name}return g}function hi(f){var g=Wt.call(M,"placeholder")?M:f;return g.placeholder}function at(){var f=M.iteratee||Hw;return f=f===Hw?Fl:f,arguments.length?f(arguments[0],arguments[1]):f}function dc(f,g){var S=f.__data__;return Gl(g)?S[typeof g=="string"?"string":"hash"]:S.map}function fc(f){for(var g=Er(f),S=g.length;S--;){var R=g[S],D=f[R];g[S]=[R,D,gc(D)]}return g}function qi(f,g){var S=vl(f,g);return Cp(S)?S:t}function vd(f){var g=Wt.call(f,Ra),S=f[Ra];try{f[Ra]=t;var R=!0}catch{}var D=Vu.call(f);return R&&(g?f[Ra]=S:delete f[Ra]),D}var io=Wh?function(f){return f==null?[]:(f=Zt(f),Oi(Wh(f),function(g){return Bh.call(f,g)}))}:Xw,R0=Wh?function(f){for(var g=[];f;)Fi(g,io(f)),f=ro(f);return g}:Xw,hr=ur;(Ku&&hr(new Ku(new ArrayBuffer(1)))!=Qn||_a&&hr(new _a)!=Rt||Xu&&hr(Xu.resolve())!=Yt||Mi&&hr(new Mi)!=cn||Yu&&hr(new Yu)!=vr)&&(hr=function(f){var g=ur(f),S=g==At?f.constructor:t,R=S?Ki(S):"";if(R)switch(R){case gp:return Qn;case zi:return Rt;case u0:return Yt;case Tl:return cn;case No:return vr}return g});function jp(f,g,S){for(var R=-1,D=S.length;++R<D;){var W=S[R],q=W.size;switch(W.type){case"drop":f+=q;break;case"dropRight":g-=q;break;case"take":g=Cr(g,f+q);break;case"takeRight":f=Fn(f,g-q);break}}return{start:f,end:g}}function A0(f){var g=f.match(yh);return g?g[1].split(Gf):[]}function Hp(f,g,S){g=Po(g,f);for(var R=-1,D=g.length,W=!1;++R<D;){var q=uo(g[R]);if(!(W=f!=null&&S(f,q)))break;f=f[q]}return W||++R!=D?W:(D=f==null?0:f.length,!!D&&Q0(D)&&wn(q,D)&&(yt(f)||kc(f)))}function pc(f){var g=f.length,S=new f.constructor(g);return g&&typeof f[0]=="string"&&Wt.call(f,"index")&&(S.index=f.index,S.input=f.input),S}function dr(f){return typeof f.constructor=="function"&&!di(f)?El(ro(f)):{}}function bw(f,g,S){var R=f.constructor;switch(g){case wr:return ac(f);case ze:case Be:return new R(+f);case Qn:return b0(f,S);case So:case eo:case to:case Iu:case Jo:case hl:case $u:case Nu:case Tu:return k0(f,S);case Rt:return new R;case Ot:case Rn:return new R(f);case Jt:return C0(f);case cn:return new R;case fs:return S0(f)}}function Cw(f,g){var S=g.length;if(!S)return f;var R=S-1;return g[R]=(S>1?"& ":"")+g[R],g=g.join(S>2?", ":" "),f.replace(xh,`{
/* [wrapped with `+g+`] */
`)}function wd(f){return yt(f)||kc(f)||!!(i0&&f&&f[i0])}function wn(f,g){var S=typeof f;return g=g??j,!!g&&(S=="number"||S!="symbol"&&Ex.test(f))&&f>-1&&f%1==0&&f<g}function Br(f,g,S){if(!Dn(S))return!1;var R=typeof g;return(R=="number"?Us(S)&&wn(g,S.length):R=="string"&&g in S)?pi(S[g],f):!1}function qe(f,g){if(yt(f))return!1;var S=typeof f;return S=="number"||S=="symbol"||S=="boolean"||f==null||fo(f)?!0:Ix.test(f)||!Wf.test(f)||g!=null&&f in Zt(g)}function Gl(f){var g=typeof f;return g=="string"||g=="number"||g=="symbol"||g=="boolean"?f!=="__proto__":f===null}function mc(f){var g=Vl(f),S=M[g];if(typeof S!="function"||!(g in xt.prototype))return!1;if(f===S)return!0;var R=yd(S);return!!R&&f===R[0]}function _0(f){return!!Lh&&Lh in f}var Sw=Cl?Ya:Yw;function di(f){var g=f&&f.constructor,S=typeof g=="function"&&g.prototype||$o;return f===S}function gc(f){return f===f&&!Dn(f)}function bd(f,g){return function(S){return S==null?!1:S[f]===g&&(g!==t||f in Zt(S))}}function D0(f){var g=ge(f,function(R){return S.size===c&&S.clear(),R}),S=g.cache;return g}function O0(f,g){var S=f[1],R=g[1],D=S|R,W=D<(w|k|P),q=R==P&&S==N||R==P&&S==B&&f[7].length<=g[8]||R==(P|B)&&g[7].length<=g[8]&&S==N;if(!(W||q))return f;R&w&&(f[2]=g[2],D|=S&w?0:I);var J=g[3];if(J){var fe=f[3];f[3]=fe?I0(fe,J,g[4]):J,f[4]=fe?Es(f[3],d):g[4]}return J=g[5],J&&(fe=f[5],f[5]=fe?Fp(fe,J,g[6]):J,f[6]=fe?Es(f[5],d):g[6]),J=g[7],J&&(f[7]=J),R&P&&(f[8]=f[8]==null?g[8]:Cr(f[8],g[8])),f[9]==null&&(f[9]=g[9]),f[0]=g[0],f[1]=D,f}function F0(f){var g=[];if(f!=null)for(var S in Zt(f))g.push(S);return g}function qp(f){return Vu.call(f)}function Cd(f,g,S){return g=Fn(g===t?f.length-1:g,0),function(){for(var R=arguments,D=-1,W=Fn(R.length-g,0),q=ve(W);++D<W;)q[D]=R[g+D];D=-1;for(var J=ve(g+1);++D<g;)J[D]=R[D];return J[g]=S(q),Pr(f,this,J)}}function Jn(f,g){return g.length<2?f:oi(f,Tr(g,0,-1))}function ao(f,g){for(var S=f.length,R=Cr(g.length,S),D=Mr(f);R--;){var W=g[R];f[R]=wn(W,S)?D[W]:t}return f}function zo(f,g){if(!(g==="constructor"&&typeof f[g]=="function")&&g!="__proto__")return f[g]}var Kp=lo(id),jl=pp||function(f,g){return yn.setTimeout(f,g)},vs=lo(Fo);function Xp(f,g,S){var R=g+"";return vs(f,Cw(R,P0(A0(R),S)))}function lo(f){var g=0,S=0;return function(){var R=yw(),D=Y-(R-S);if(S=R,D>0){if(++g>=H)return arguments[0]}else g=0;return f.apply(t,arguments)}}function Sd(f,g){var S=-1,R=f.length,D=R-1;for(g=g===t?R:g;++S<g;){var W=Pl(S,D),q=f[W];f[W]=f[S],f[S]=q}return f.length=g,f}var Yp=D0(function(f){var g=[];return f.charCodeAt(0)===46&&g.push(""),f.replace(Eu,function(S,R,D,W){g.push(D?W.replace(Xv,"$1"):R||S)}),g});function uo(f){if(typeof f=="string"||fo(f))return f;var g=f+"";return g=="0"&&1/f==-de?"-0":g}function Ki(f){if(f!=null){try{return Wu.call(f)}catch{}try{return f+""}catch{}}return""}function P0(f,g){return br(Ie,function(S){var R="_."+S[0];g&S[1]&&!Ah(f,R)&&f.push(R)}),f.sort()}function L0(f){if(f instanceof xt)return f.clone();var g=new Sr(f.__wrapped__,f.__chain__);return g.__actions__=Mr(f.__actions__),g.__index__=f.__index__,g.__values__=f.__values__,g}function kd(f,g,S){(S?Br(f,g,S):g===t)?g=1:g=Fn(St(g),0);var R=f==null?0:f.length;if(!R||g<1)return[];for(var D=0,W=0,q=ve(Aa(R/g));D<R;)q[W++]=Tr(f,D,D+=g);return q}function Qp(f){for(var g=-1,S=f==null?0:f.length,R=0,D=[];++g<S;){var W=f[g];W&&(D[R++]=W)}return D}function zs(){var f=arguments.length;if(!f)return[];for(var g=ve(f-1),S=arguments[0],R=f;R--;)g[R-1]=arguments[R];return Fi(yt(S)?Mr(S):[S],$n(g,1))}var Ft=Ct(function(f,g){return qn(f)?_o(f,$n(g,1,qn,!0)):[]}),Zn=Ct(function(f,g){var S=Ur(g);return qn(S)&&(S=t),qn(f)?_o(f,$n(g,1,qn,!0),at(S,2)):[]}),Pn=Ct(function(f,g){var S=Ur(g);return qn(S)&&(S=t),qn(f)?_o(f,$n(g,1,qn,!0),t,S):[]});function fr(f,g,S){var R=f==null?0:f.length;return R?(g=S||g===t?1:St(g),Tr(f,g<0?0:g,R)):[]}function ws(f,g,S){var R=f==null?0:f.length;return R?(g=S||g===t?1:St(g),g=R-g,Tr(f,0,g<0?0:g)):[]}function Hl(f,g){return f&&f.length?oc(f,at(g,3),!0,!0):[]}function Hn(f,g){return f&&f.length?oc(f,at(g,3),!0):[]}function xc(f,g,S,R){var D=f==null?0:f.length;return D?(S&&typeof S!="number"&&Br(f,g,S)&&(S=0,R=D),x0(f,g,S,R)):[]}function Xi(f,g,S){var R=f==null?0:f.length;if(!R)return-1;var D=S==null?0:St(S);return D<0&&(D=Fn(R+D,0)),_h(f,at(g,3),D)}function yc(f,g,S){var R=f==null?0:f.length;if(!R)return-1;var D=R-1;return S!==t&&(D=St(S),D=S<0?Fn(R+D,0):Cr(D,R-1)),_h(f,at(g,3),D,!0)}function Id(f){var g=f==null?0:f.length;return g?$n(f,1):[]}function vc(f){var g=f==null?0:f.length;return g?$n(f,de):[]}function ns(f,g){var S=f==null?0:f.length;return S?(g=g===t?1:St(g),$n(f,g)):[]}function Jp(f){for(var g=-1,S=f==null?0:f.length,R={};++g<S;){var D=f[g];R[D[0]]=D[1]}return R}function Ga(f){return f&&f.length?f[0]:t}function fi(f,g,S){var R=f==null?0:f.length;if(!R)return-1;var D=S==null?0:St(S);return D<0&&(D=Fn(R+D,0)),yl(f,g,D)}function $d(f){var g=f==null?0:f.length;return g?Tr(f,0,-1):[]}var Zp=Ct(function(f){var g=an(f,zl);return g.length&&g[0]===f[0]?td(g):[]}),Yi=Ct(function(f){var g=Ur(f),S=an(f,zl);return g===Ur(S)?g=t:S.pop(),S.length&&S[0]===f[0]?td(S,at(g,2)):[]}),Nd=Ct(function(f){var g=Ur(f),S=an(f,zl);return g=typeof g=="function"?g:t,g&&S.pop(),S.length&&S[0]===f[0]?td(S,t,g):[]});function Qi(f,g){return f==null?"":Vh.call(f,g)}function Ur(f){var g=f==null?0:f.length;return g?f[g-1]:t}function wc(f,g,S){var R=f==null?0:f.length;if(!R)return-1;var D=R;return S!==t&&(D=St(S),D=D<0?Fn(R+D,0):Cr(D,R-1)),g===g?pw(f,g,D):_h(f,Hx,D,!0)}function em(f,g){return f&&f.length?od(f,St(g)):t}var Td=Ct(bc);function bc(f,g){return f&&f.length&&g&&g.length?An(f,g):f}function Wr(f,g,S){return f&&f.length&&g&&g.length?An(f,g,at(S,2)):f}function Ji(f,g,S){return f&&f.length&&g&&g.length?An(f,g,t,S):f}var co=Mo(function(f,g){var S=f==null?0:f.length,R=Jh(f,g);return jn(f,an(g,function(D){return wn(D,S)?+D:D}).sort(Op)),R});function rs(f,g){var S=[];if(!(f&&f.length))return S;var R=-1,D=[],W=f.length;for(g=at(g,3);++R<W;){var q=f[R];g(q,R,f)&&(S.push(q),D.push(R))}return jn(f,D),S}function Ed(f){return f==null?f:Gh.call(f)}function tm(f,g,S){var R=f==null?0:f.length;return R?(S&&typeof S!="number"&&Br(f,g,S)?(g=0,S=R):(g=g==null?0:St(g),S=S===t?R:St(S)),Tr(f,g,S)):[]}function nm(f,g){return Ll(f,g)}function kw(f,g,S){return ad(f,g,at(S,2))}function Zi(f,g){var S=f==null?0:f.length;if(S){var R=Ll(f,g);if(R<S&&pi(f[R],g))return R}return-1}function M0(f,g){return Ll(f,g,!0)}function rm(f,g,S){return ad(f,g,at(S,2),!0)}function ja(f,g){var S=f==null?0:f.length;if(S){var R=Ll(f,g,!0)-1;if(pi(f[R],g))return R}return-1}function sm(f){return f&&f.length?Ep(f):[]}function Ha(f,g){return f&&f.length?Ep(f,at(g,2)):[]}function z0(f){var g=f==null?0:f.length;return g?Tr(f,1,g):[]}function B0(f,g,S){return f&&f.length?(g=S||g===t?1:St(g),Tr(f,0,g<0?0:g)):[]}function om(f,g,S){var R=f==null?0:f.length;return R?(g=S||g===t?1:St(g),g=R-g,Tr(f,g<0?0:g,R)):[]}function Rd(f,g){return f&&f.length?oc(f,at(g,3),!1,!0):[]}function Iw(f,g){return f&&f.length?oc(f,at(g,3)):[]}var $w=Ct(function(f){return ui($n(f,1,qn,!0))}),U0=Ct(function(f){var g=Ur(f);return qn(g)&&(g=t),ui($n(f,1,qn,!0),at(g,2))}),W0=Ct(function(f){var g=Ur(f);return g=typeof g=="function"?g:t,ui($n(f,1,qn,!0),t,g)});function qa(f){return f&&f.length?ui(f):[]}function Nw(f,g){return f&&f.length?ui(f,at(g,2)):[]}function ql(f,g){return g=typeof g=="function"?g:t,f&&f.length?ui(f,t,g):[]}function Ad(f){if(!(f&&f.length))return[];var g=0;return f=Oi(f,function(S){if(qn(S))return g=Fn(S.length,g),!0}),up(g,function(S){return an(f,ap(S))})}function Sn(f,g){if(!(f&&f.length))return[];var S=Ad(f);return g==null?S:an(S,function(R){return Pr(g,t,R)})}var Tw=Ct(function(f,g){return qn(f)?_o(f,g):[]}),V0=Ct(function(f){return ud(Oi(f,qn))}),Ew=Ct(function(f){var g=Ur(f);return qn(g)&&(g=t),ud(Oi(f,qn),at(g,2))}),Rw=Ct(function(f){var g=Ur(f);return g=typeof g=="function"?g:t,ud(Oi(f,qn),t,g)}),G0=Ct(Ad);function j0(f,g){return ic(f||[],g||[],Pa)}function Aw(f,g){return ic(f||[],g||[],Ua)}var Bs=Ct(function(f){var g=f.length,S=g>1?f[g-1]:t;return S=typeof S=="function"?(f.pop(),S):t,Sn(f,S)});function _d(f){var g=M(f);return g.__chain__=!0,g}function _w(f,g){return g(f),f}function ho(f,g){return g(f)}var Dd=Mo(function(f){var g=f.length,S=g?f[0]:0,R=this.__wrapped__,D=function(W){return Jh(W,f)};return g>1||this.__actions__.length||!(R instanceof xt)||!wn(S)?this.thru(D):(R=R.slice(S,+S+(g?1:0)),R.__actions__.push({func:ho,args:[D],thisArg:t}),new Sr(R,this.__chain__).thru(function(W){return g&&!W.length&&W.push(t),W}))});function Ka(){return _d(this)}function Od(){return new Sr(this.value(),this.__chain__)}function im(){this.__values__===t&&(this.__values__=t$(this.value()));var f=this.__index__>=this.__values__.length,g=f?t:this.__values__[this.__index__++];return{done:f,value:g}}function am(){return this}function Dw(f){for(var g,S=this;S instanceof To;){var R=L0(S);R.__index__=0,R.__values__=t,g?D.__wrapped__=R:g=R;var D=R;S=S.__wrapped__}return D.__wrapped__=f,g}function lm(){var f=this.__wrapped__;if(f instanceof xt){var g=f;return this.__actions__.length&&(g=new xt(this)),g=g.reverse(),g.__actions__.push({func:ho,args:[Ed],thisArg:t}),new Sr(g,this.__chain__)}return this.thru(Ed)}function Ow(){return Ml(this.__wrapped__,this.__actions__)}var H0=dd(function(f,g,S){Wt.call(f,S)?++f[S]:Ao(f,S,1)});function q0(f,g,S){var R=yt(f)?np:Zu;return S&&Br(f,g,S)&&(g=t),R(f,at(g,3))}function Fd(f,g){var S=yt(f)?Oi:wp;return S(f,at(g,3))}var Pd=Va(Xi),K0=Va(yc);function um(f,g){return $n(Xa(f,g),1)}function Fw(f,g){return $n(Xa(f,g),de)}function X0(f,g,S){return S=S===t?1:St(S),$n(Xa(f,g),S)}function Ld(f,g){var S=yt(f)?br:Do;return S(f,at(g,3))}function Cc(f,g){var S=yt(f)?Rh:g0;return S(f,at(g,3))}var cm=dd(function(f,g,S){Wt.call(f,S)?f[S].push(g):Ao(f,S,[g])});function Md(f,g,S,R){f=Us(f)?f:Ud(f),S=S&&!R?St(S):0;var D=f.length;return S<0&&(S=Fn(D+S,0)),J0(f)?S<=D&&f.indexOf(g,S)>-1:!!D&&yl(f,g,S)>-1}var Y0=Ct(function(f,g,S){var R=-1,D=typeof g=="function",W=Us(f)?ve(f.length):[];return Do(f,function(q){W[++R]=D?Pr(g,q,S):Fs(q,g,S)}),W}),Pw=dd(function(f,g,S){Ao(f,S,g)});function Xa(f,g){var S=yt(f)?an:kp;return S(f,at(g,3))}function Lw(f,g,S,R){return f==null?[]:(yt(g)||(g=g==null?[]:[g]),S=R?t:S,yt(S)||(S=S==null?[]:[S]),rc(f,g,S))}var Sc=dd(function(f,g,S){f[S?0:1].push(g)},function(){return[[],[]]});function Mw(f,g,S){var R=yt(f)?sp:Kx,D=arguments.length<3;return R(f,at(g,4),S,D,Do)}function zd(f,g,S){var R=yt(f)?iw:Kx,D=arguments.length<3;return R(f,at(g,4),S,D,g0)}function u(f,g){var S=yt(f)?Oi:wp;return S(f,Le(at(g,3)))}function h(f){var g=yt(f)?Ro:Nr;return g(f)}function x(f,g,S){(S?Br(f,g,S):g===t)?g=1:g=St(g);var R=yt(f)?Fa:Np;return R(f,g)}function C(f){var g=yt(f)?p0:Ls;return g(f)}function $(f){if(f==null)return 0;if(Us(f))return J0(f)?Ea(f):f.length;var g=hr(f);return g==Rt||g==cn?f.size:li(f).length}function E(f,g,S){var R=yt(f)?op:Tp;return S&&Br(f,g,S)&&(g=t),R(f,at(g,3))}var F=Ct(function(f,g){if(f==null)return[];var S=g.length;return S>1&&Br(f,g[0],g[1])?g=[]:S>2&&Br(g[0],g[1],g[2])&&(g=[g[0]]),rc(f,$n(g,1),[])}),G=hn||function(){return yn.Date.now()};function Q(f,g){if(typeof g!="function")throw new Rs(i);return f=St(f),function(){if(--f<1)return g.apply(this,arguments)}}function we(f,g,S){return g=S?t:g,g=f&&g==null?f.length:g,Lo(f,P,t,t,t,t,g)}function De(f,g){var S;if(typeof g!="function")throw new Rs(i);return f=St(f),function(){return--f>0&&(S=g.apply(this,arguments)),f<=1&&(g=t),S}}var Fe=Ct(function(f,g,S){var R=w;if(S.length){var D=Es(S,hi(Fe));R|=A}return Lo(f,R,g,S,D)}),Ae=Ct(function(f,g,S){var R=w|k;if(S.length){var D=Es(S,hi(Ae));R|=A}return Lo(g,R,f,S,D)});function He(f,g,S){g=S?t:g;var R=Lo(f,N,t,t,t,t,t,g);return R.placeholder=He.placeholder,R}function Ke(f,g,S){g=S?t:g;var R=Lo(f,T,t,t,t,t,t,g);return R.placeholder=Ke.placeholder,R}function Xe(f,g,S){var R,D,W,q,J,fe,Ne=0,Te=!1,Oe=!1,We=!0;if(typeof f!="function")throw new Rs(i);g=Bo(g)||0,Dn(S)&&(Te=!!S.leading,Oe="maxWait"in S,W=Oe?Fn(Bo(S.maxWait)||0,g):W,We="trailing"in S?!!S.trailing:We);function et(Kn){var mi=R,Ja=D;return R=D=t,Ne=Kn,q=f.apply(Ja,mi),q}function ht(Kn){return Ne=Kn,J=jl(Dt,g),Te?et(Kn):q}function It(Kn){var mi=Kn-fe,Ja=Kn-Ne,p$=g-mi;return Oe?Cr(p$,W-Ja):p$}function dt(Kn){var mi=Kn-fe,Ja=Kn-Ne;return fe===t||mi>=g||mi<0||Oe&&Ja>=W}function Dt(){var Kn=G();if(dt(Kn))return Pt(Kn);J=jl(Dt,It(Kn))}function Pt(Kn){return J=t,We&&R?et(Kn):(R=D=t,q)}function po(){J!==t&&_p(J),Ne=0,R=fe=D=J=t}function bs(){return J===t?q:Pt(G())}function mo(){var Kn=G(),mi=dt(Kn);if(R=arguments,D=this,fe=Kn,mi){if(J===t)return ht(fe);if(Oe)return _p(J),J=jl(Dt,g),et(fe)}return J===t&&(J=jl(Dt,g)),q}return mo.cancel=po,mo.flush=bs,mo}var _n=Ct(function(f,g){return vp(f,1,g)}),pe=Ct(function(f,g,S){return vp(f,Bo(g)||0,S)});function oe(f){return Lo(f,z)}function ge(f,g){if(typeof f!="function"||g!=null&&typeof g!="function")throw new Rs(i);var S=function(){var R=arguments,D=g?g.apply(this,R):R[0],W=S.cache;if(W.has(D))return W.get(D);var q=f.apply(this,R);return S.cache=W.set(D,q)||W,q};return S.cache=new(ge.Cache||As),S}ge.Cache=As;function Le(f){if(typeof f!="function")throw new Rs(i);return function(){var g=arguments;switch(g.length){case 0:return!f.call(this);case 1:return!f.call(this,g[0]);case 2:return!f.call(this,g[0],g[1]);case 3:return!f.call(this,g[0],g[1],g[2])}return!f.apply(this,g)}}function Ze(f){return De(2,f)}var ot=w0(function(f,g){g=g.length==1&&yt(g[0])?an(g[0],ps(at())):an($n(g,1),ps(at()));var S=g.length;return Ct(function(R){for(var D=-1,W=Cr(R.length,S);++D<W;)R[D]=g[D].call(this,R[D]);return Pr(f,this,R)})}),nt=Ct(function(f,g){var S=Es(g,hi(nt));return Lo(f,A,t,g,S)}),ct=Ct(function(f,g){var S=Es(g,hi(ct));return Lo(f,O,t,g,S)}),er=Mo(function(f,g){return Lo(f,B,t,t,t,g)});function Vt(f,g){if(typeof f!="function")throw new Rs(i);return g=g===t?g:St(g),Ct(f,g)}function ea(f,g){if(typeof f!="function")throw new Rs(i);return g=g==null?0:Fn(St(g),0),Ct(function(S){var R=S[g],D=ci(S,0,g);return R&&Fi(D,R),Pr(f,this,D)})}function zw(f,g,S){var R=!0,D=!0;if(typeof f!="function")throw new Rs(i);return Dn(S)&&(R="leading"in S?!!S.leading:R,D="trailing"in S?!!S.trailing:D),Xe(f,g,{leading:R,maxWait:g,trailing:D})}function cP(f){return we(f,1)}function hP(f,g){return nt(cd(g),f)}function dP(){if(!arguments.length)return[];var f=arguments[0];return yt(f)?f:[f]}function fP(f){return es(f,y)}function pP(f,g){return g=typeof g=="function"?g:t,es(f,y,g)}function mP(f){return es(f,p|y)}function gP(f,g){return g=typeof g=="function"?g:t,es(f,p|y,g)}function xP(f,g){return g==null||Ju(f,g,Er(g))}function pi(f,g){return f===g||f!==f&&g!==g}var yP=xd(Gi),vP=xd(function(f,g){return f>=g}),kc=nd((function(){return arguments})())?nd:function(f){return Ln(f)&&Wt.call(f,"callee")&&!Bh.call(f,"callee")},yt=ve.isArray,wP=ep?ps(ep):y0;function Us(f){return f!=null&&Q0(f.length)&&!Ya(f)}function qn(f){return Ln(f)&&Us(f)}function bP(f){return f===!0||f===!1||Ln(f)&&ur(f)==ze}var Kl=mp||Yw,CP=Yr?ps(Yr):ai;function SP(f){return Ln(f)&&f.nodeType===1&&!hm(f)}function kP(f){if(f==null)return!0;if(Us(f)&&(yt(f)||typeof f=="string"||typeof f.splice=="function"||Kl(f)||Bd(f)||kc(f)))return!f.length;var g=hr(f);if(g==Rt||g==cn)return!f.size;if(di(f))return!li(f).length;for(var S in f)if(Wt.call(f,S))return!1;return!0}function IP(f,g){return Ps(f,g)}function $P(f,g,S){S=typeof S=="function"?S:t;var R=S?S(f,g):t;return R===t?Ps(f,g,t,S):!!R}function Bw(f){if(!Ln(f))return!1;var g=ur(f);return g==lt||g==Je||typeof f.message=="string"&&typeof f.name=="string"&&!hm(f)}function NP(f){return typeof f=="number"&&kl(f)}function Ya(f){if(!Dn(f))return!1;var g=ur(f);return g==pt||g==bt||g==Me||g==ds}function QI(f){return typeof f=="number"&&f==St(f)}function Q0(f){return typeof f=="number"&&f>-1&&f%1==0&&f<=j}function Dn(f){var g=typeof f;return f!=null&&(g=="object"||g=="function")}function Ln(f){return f!=null&&typeof f=="object"}var JI=Ta?ps(Ta):v0;function TP(f,g){return f===g||Ol(f,g,fc(g))}function EP(f,g,S){return S=typeof S=="function"?S:t,Ol(f,g,fc(g),S)}function RP(f){return ZI(f)&&f!=+f}function AP(f){if(Sw(f))throw new mt(o);return Cp(f)}function _P(f){return f===null}function DP(f){return f==null}function ZI(f){return typeof f=="number"||Ln(f)&&ur(f)==Ot}function hm(f){if(!Ln(f)||ur(f)!=At)return!1;var g=ro(f);if(g===null)return!0;var S=Wt.call(g,"constructor")&&g.constructor;return typeof S=="function"&&S instanceof S&&Wu.call(S)==Mh}var Uw=Eh?ps(Eh):tc;function OP(f){return QI(f)&&f>=-j&&f<=j}var e$=xl?ps(xl):Oo;function J0(f){return typeof f=="string"||!yt(f)&&Ln(f)&&ur(f)==Rn}function fo(f){return typeof f=="symbol"||Ln(f)&&ur(f)==fs}var Bd=Vx?ps(Vx):nc;function FP(f){return f===t}function PP(f){return Ln(f)&&hr(f)==vr}function LP(f){return Ln(f)&&ur(f)==Zs}var MP=xd(ji),zP=xd(function(f,g){return f<=g});function t$(f){if(!f)return[];if(Us(f))return J0(f)?ms(f):Mr(f);if(ni&&f[ni])return dw(f[ni]());var g=hr(f),S=g==Rt?Oh:g==cn?Pi:Ud;return S(f)}function Qa(f){if(!f)return f===0?f:0;if(f=Bo(f),f===de||f===-de){var g=f<0?-1:1;return g*ie}return f===f?f:0}function St(f){var g=Qa(f),S=g%1;return g===g?S?g-S:g:0}function n$(f){return f?si(St(f),0,V):0}function Bo(f){if(typeof f=="number")return f;if(fo(f))return se;if(Dn(f)){var g=typeof f.valueOf=="function"?f.valueOf():f;f=Dn(g)?g+"":g}if(typeof f!="string")return f===0?f:+f;f=Xx(f);var S=Yv.test(f);return S||Tx.test(f)?Nh(f.slice(2),S?2:8):$x.test(f)?se:+f}function r$(f){return oo(f,Ws(f))}function BP(f){return f?si(St(f),-j,j):f===0?f:0}function en(f){return f==null?"":ts(f)}var UP=Bl(function(f,g){if(di(g)||Us(g)){oo(g,Er(g),f);return}for(var S in g)Wt.call(g,S)&&Pa(f,S,g[S])}),s$=Bl(function(f,g){oo(g,Ws(g),f)}),Z0=Bl(function(f,g,S,R){oo(g,Ws(g),f,R)}),WP=Bl(function(f,g,S,R){oo(g,Er(g),f,R)}),VP=Mo(Jh);function GP(f,g){var S=El(f);return g==null?S:fn(S,g)}var jP=Ct(function(f,g){f=Zt(f);var S=-1,R=g.length,D=R>2?g[2]:t;for(D&&Br(g[0],g[1],D)&&(R=1);++S<R;)for(var W=g[S],q=Ws(W),J=-1,fe=q.length;++J<fe;){var Ne=q[J],Te=f[Ne];(Te===t||pi(Te,$o[Ne])&&!Wt.call(f,Ne))&&(f[Ne]=W[Ne])}return f}),HP=Ct(function(f){return f.push(t,Up),Pr(o$,t,f)});function qP(f,g){return jx(f,at(g,3),ys)}function KP(f,g){return jx(f,at(g,3),Vi)}function XP(f,g){return f==null?f:Zh(f,at(g,3),Ws)}function YP(f,g){return f==null?f:ec(f,at(g,3),Ws)}function QP(f,g){return f&&ys(f,at(g,3))}function JP(f,g){return f&&Vi(f,at(g,3))}function ZP(f){return f==null?[]:Dl(f,Er(f))}function eL(f){return f==null?[]:Dl(f,Ws(f))}function Ww(f,g,S){var R=f==null?t:oi(f,g);return R===t?S:R}function tL(f,g){return f!=null&&Hp(f,g,Os)}function Vw(f,g){return f!=null&&Hp(f,g,Ma)}var nL=$0(function(f,g,S){g!=null&&typeof g.toString!="function"&&(g=Vu.call(g)),f[g]=S},jw(Vs)),rL=$0(function(f,g,S){g!=null&&typeof g.toString!="function"&&(g=Vu.call(g)),Wt.call(f,g)?f[g].push(S):f[g]=[S]},at),sL=Ct(Fs);function Er(f){return Us(f)?Eo(f):li(f)}function Ws(f){return Us(f)?Eo(f,!0):Sp(f)}function oL(f,g){var S={};return g=at(g,3),ys(f,function(R,D,W){Ao(S,g(R,D,W),R)}),S}function iL(f,g){var S={};return g=at(g,3),ys(f,function(R,D,W){Ao(S,D,g(R,D,W))}),S}var aL=Bl(function(f,g,S){za(f,g,S)}),o$=Bl(function(f,g,S,R){za(f,g,S,R)}),lL=Mo(function(f,g){var S={};if(f==null)return S;var R=!1;g=an(g,function(W){return W=Po(W,f),R||(R=W.length>1),W}),oo(f,hc(f),S),R&&(S=es(S,p|m|y,Wp));for(var D=g.length;D--;)ld(S,g[D]);return S});function uL(f,g){return i$(f,Le(at(g)))}var cL=Mo(function(f,g){return f==null?{}:$p(f,g)});function i$(f,g){if(f==null)return{};var S=an(hc(f),function(R){return[R]});return g=at(g),Hi(f,S,function(R,D){return g(R,D[0])})}function hL(f,g,S){g=Po(g,f);var R=-1,D=g.length;for(D||(D=1,f=t);++R<D;){var W=f==null?t:f[uo(g[R])];W===t&&(R=D,W=S),f=Ya(W)?W.call(f):W}return f}function dL(f,g,S){return f==null?f:Ua(f,g,S)}function fL(f,g,S,R){return R=typeof R=="function"?R:t,f==null?f:Ua(f,g,S,R)}var a$=zp(Er),l$=zp(Ws);function pL(f,g,S){var R=yt(f),D=R||Kl(f)||Bd(f);if(g=at(g,4),S==null){var W=f&&f.constructor;D?S=R?new W:[]:Dn(f)?S=Ya(W)?El(ro(f)):{}:S={}}return(D?br:ys)(f,function(q,J,fe){return g(S,q,J,fe)}),S}function mL(f,g){return f==null?!0:ld(f,g)}function gL(f,g,S){return f==null?f:Ap(f,g,cd(S))}function xL(f,g,S,R){return R=typeof R=="function"?R:t,f==null?f:Ap(f,g,cd(S),R)}function Ud(f){return f==null?[]:Bu(f,Er(f))}function yL(f){return f==null?[]:Bu(f,Ws(f))}function vL(f,g,S){return S===t&&(S=g,g=t),S!==t&&(S=Bo(S),S=S===S?S:0),g!==t&&(g=Bo(g),g=g===g?g:0),si(Bo(f),g,S)}function wL(f,g,S){return g=Qa(g),S===t?(S=g,g=0):S=Qa(S),f=Bo(f),bp(f,g,S)}function bL(f,g,S){if(S&&typeof S!="boolean"&&Br(f,g,S)&&(g=S=t),S===t&&(typeof g=="boolean"?(S=g,g=t):typeof f=="boolean"&&(S=f,f=t)),f===t&&g===t?(f=0,g=1):(f=Qa(f),g===t?(g=f,f=0):g=Qa(g)),f>g){var R=f;f=g,g=R}if(S||f%1||g%1){var D=qu();return Cr(f+D*(g-f+Jf("1e-"+((D+"").length-1))),g)}return Pl(f,g)}var CL=Wa(function(f,g,S){return g=g.toLowerCase(),f+(S?u$(g):g)});function u$(f){return Gw(en(f).toLowerCase())}function c$(f){return f=en(f),f&&f.replace(Rx,Jx).replace(zx,"")}function SL(f,g,S){f=en(f),g=ts(g);var R=f.length;S=S===t?R:si(St(S),0,R);var D=S;return S-=g.length,S>=0&&f.slice(S,D)==g}function kL(f){return f=en(f),f&&Cx.test(f)?f.replace(Sa,Zx):f}function IL(f){return f=en(f),f&&Au.test(f)?f.replace(Ru,"\\$&"):f}var $L=Wa(function(f,g,S){return f+(S?"-":"")+g.toLowerCase()}),NL=Wa(function(f,g,S){return f+(S?" ":"")+g.toLowerCase()}),TL=Pp("toLowerCase");function EL(f,g,S){f=en(f),g=St(g);var R=g?Ea(f):0;if(!g||R>=g)return f;var D=(g-R)/2;return uc(Li(D),S)+f+uc(Aa(D),S)}function RL(f,g,S){f=en(f),g=St(g);var R=g?Ea(f):0;return g&&R<g?f+uc(g-R,S):f}function AL(f,g,S){f=en(f),g=St(g);var R=g?Ea(f):0;return g&&R<g?uc(g-R,S)+f:f}function _L(f,g,S){return S||g==null?g=0:g&&(g=+g),l0(en(f).replace(Vf,""),g||0)}function DL(f,g,S){return(S?Br(f,g,S):g===t)?g=1:g=St(g),Ba(en(f),g)}function OL(){var f=arguments,g=en(f[0]);return f.length<3?g:g.replace(f[1],f[2])}var FL=Wa(function(f,g,S){return f+(S?"_":"")+g.toLowerCase()});function PL(f,g,S){return S&&typeof S!="number"&&Br(f,g,S)&&(g=S=t),S=S===t?V:S>>>0,S?(f=en(f),f&&(typeof g=="string"||g!=null&&!Uw(g))&&(g=ts(g),!g&&wl(f))?ci(ms(f),0,S):f.split(g,S)):[]}var LL=Wa(function(f,g,S){return f+(S?" ":"")+Gw(g)});function ML(f,g,S){return f=en(f),S=S==null?0:si(St(S),0,f.length),g=ts(g),f.slice(S,S+g.length)==g}function zL(f,g,S){var R=M.templateSettings;S&&Br(f,g,S)&&(g=t),f=en(f),g=Z0({},g,R,Bp);var D=Z0({},g.imports,R.imports,Bp),W=Er(D),q=Bu(D,W),J,fe,Ne=0,Te=g.interpolate||vh,Oe="__p += '",We=Uu((g.escape||vh).source+"|"+Te.source+"|"+(Te===Uf?ka:vh).source+"|"+(g.evaluate||vh).source+"|$","g"),et="//# sourceURL="+(Wt.call(g,"sourceURL")?(g.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++rw+"]")+`
`;f.replace(We,function(dt,Dt,Pt,po,bs,mo){return Pt||(Pt=po),Oe+=f.slice(Ne,mo).replace(Qv,e0),Dt&&(J=!0,Oe+=`' +
__e(`+Dt+`) +
'`),bs&&(fe=!0,Oe+=`';
`+bs+`;
__p += '`),Pt&&(Oe+=`' +
((__t = (`+Pt+`)) == null ? '' : __t) +
'`),Ne=mo+dt.length,dt}),Oe+=`';
`;var ht=Wt.call(g,"variable")&&g.variable;if(!ht)Oe=`with (obj) {
`+Oe+`
}
`;else if(Kv.test(ht))throw new mt(a);Oe=(fe?Oe.replace(Mf,""):Oe).replace(zf,"$1").replace(Bf,"$1;"),Oe="function("+(ht||"obj")+`) {
`+(ht?"":`obj || (obj = {});
`)+"var __t, __p = ''"+(J?", __e = _.escape":"")+(fe?`, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
`:`;
`)+Oe+`return __p
}`;var It=d$(function(){return Ut(W,et+"return "+Oe).apply(t,q)});if(It.source=Oe,Bw(It))throw It;return It}function BL(f){return en(f).toLowerCase()}function UL(f){return en(f).toUpperCase()}function WL(f,g,S){if(f=en(f),f&&(S||g===t))return Xx(f);if(!f||!(g=ts(g)))return f;var R=ms(f),D=ms(g),W=Yx(R,D),q=cp(R,D)+1;return ci(R,W,q).join("")}function VL(f,g,S){if(f=en(f),f&&(S||g===t))return f.slice(0,Ph(f)+1);if(!f||!(g=ts(g)))return f;var R=ms(f),D=cp(R,ms(g))+1;return ci(R,0,D).join("")}function GL(f,g,S){if(f=en(f),f&&(S||g===t))return f.replace(Vf,"");if(!f||!(g=ts(g)))return f;var R=ms(f),D=Yx(R,ms(g));return ci(R,D).join("")}function jL(f,g){var S=L,R=_;if(Dn(g)){var D="separator"in g?g.separator:D;S="length"in g?St(g.length):S,R="omission"in g?ts(g.omission):R}f=en(f);var W=f.length;if(wl(f)){var q=ms(f);W=q.length}if(S>=W)return f;var J=S-Ea(R);if(J<1)return R;var fe=q?ci(q,0,J).join(""):f.slice(0,J);if(D===t)return fe+R;if(q&&(J+=fe.length-J),Uw(D)){if(f.slice(J).search(D)){var Ne,Te=fe;for(D.global||(D=Uu(D.source,en(jf.exec(D))+"g")),D.lastIndex=0;Ne=D.exec(Te);)var Oe=Ne.index;fe=fe.slice(0,Oe===t?J:Oe)}}else if(f.indexOf(ts(D),J)!=J){var We=fe.lastIndexOf(D);We>-1&&(fe=fe.slice(0,We))}return fe+R}function HL(f){return f=en(f),f&&bx.test(f)?f.replace(Ca,t0):f}var qL=Wa(function(f,g,S){return f+(S?" ":"")+g.toUpperCase()}),Gw=Pp("toUpperCase");function h$(f,g,S){return f=en(f),g=S?t:g,g===t?hw(f)?mw(f):lw(f):f.match(g)||[]}var d$=Ct(function(f,g){try{return Pr(f,t,g)}catch(S){return Bw(S)?S:new mt(S)}}),KL=Mo(function(f,g){return br(g,function(S){S=uo(S),Ao(f,S,Fe(f[S],f))}),f});function XL(f){var g=f==null?0:f.length,S=at();return f=g?an(f,function(R){if(typeof R[1]!="function")throw new Rs(i);return[S(R[0]),R[1]]}):[],Ct(function(R){for(var D=-1;++D<g;){var W=f[D];if(Pr(W[0],this,R))return Pr(W[1],this,R)}})}function YL(f){return m0(es(f,p))}function jw(f){return function(){return f}}function QL(f,g){return f==null||f!==f?g:f}var JL=md(),ZL=md(!0);function Vs(f){return f}function Hw(f){return Fl(typeof f=="function"?f:es(f,p))}function e3(f){return sd(es(f,p))}function t3(f,g){return vn(f,es(g,p))}var n3=Ct(function(f,g){return function(S){return Fs(S,f,g)}}),r3=Ct(function(f,g){return function(S){return Fs(f,S,g)}});function qw(f,g,S){var R=Er(g),D=Dl(g,R);S==null&&!(Dn(g)&&(D.length||!R.length))&&(S=g,g=f,f=this,D=Dl(g,Er(g)));var W=!(Dn(S)&&"chain"in S)||!!S.chain,q=Ya(f);return br(D,function(J){var fe=g[J];f[J]=fe,q&&(f.prototype[J]=function(){var Ne=this.__chain__;if(W||Ne){var Te=f(this.__wrapped__),Oe=Te.__actions__=Mr(this.__actions__);return Oe.push({func:fe,args:arguments,thisArg:f}),Te.__chain__=Ne,Te}return fe.apply(f,Fi([this.value()],arguments))})}),f}function s3(){return yn._===this&&(yn._=s0),this}function Kw(){}function o3(f){return f=St(f),Ct(function(g){return od(g,f)})}var i3=gd(an),a3=gd(np),l3=gd(op);function f$(f){return qe(f)?ap(uo(f)):Cn(f)}function u3(f){return function(g){return f==null?t:oi(f,g)}}var c3=Mp(),h3=Mp(!0);function Xw(){return[]}function Yw(){return!1}function d3(){return{}}function f3(){return""}function p3(){return!0}function m3(f,g){if(f=St(f),f<1||f>j)return[];var S=V,R=Cr(f,V);g=at(g),f-=V;for(var D=up(R,g);++S<f;)g(S);return D}function g3(f){return yt(f)?an(f,uo):fo(f)?[f]:Mr(Yp(en(f)))}function x3(f){var g=++Sl;return en(f)+g}var y3=lc(function(f,g){return f+g},0),v3=cr("ceil"),w3=lc(function(f,g){return f/g},1),b3=cr("floor");function C3(f){return f&&f.length?La(f,Vs,Gi):t}function S3(f,g){return f&&f.length?La(f,at(g,2),Gi):t}function k3(f){return qx(f,Vs)}function I3(f,g){return qx(f,at(g,2))}function $3(f){return f&&f.length?La(f,Vs,ji):t}function N3(f,g){return f&&f.length?La(f,at(g,2),ji):t}var T3=lc(function(f,g){return f*g},1),E3=cr("round"),R3=lc(function(f,g){return f-g},0);function A3(f){return f&&f.length?lp(f,Vs):0}function _3(f,g){return f&&f.length?lp(f,at(g,2)):0}return M.after=Q,M.ary=we,M.assign=UP,M.assignIn=s$,M.assignInWith=Z0,M.assignWith=WP,M.at=VP,M.before=De,M.bind=Fe,M.bindAll=KL,M.bindKey=Ae,M.castArray=dP,M.chain=_d,M.chunk=kd,M.compact=Qp,M.concat=zs,M.cond=XL,M.conforms=YL,M.constant=jw,M.countBy=H0,M.create=GP,M.curry=He,M.curryRight=Ke,M.debounce=Xe,M.defaults=jP,M.defaultsDeep=HP,M.defer=_n,M.delay=pe,M.difference=Ft,M.differenceBy=Zn,M.differenceWith=Pn,M.drop=fr,M.dropRight=ws,M.dropRightWhile=Hl,M.dropWhile=Hn,M.fill=xc,M.filter=Fd,M.flatMap=um,M.flatMapDeep=Fw,M.flatMapDepth=X0,M.flatten=Id,M.flattenDeep=vc,M.flattenDepth=ns,M.flip=oe,M.flow=JL,M.flowRight=ZL,M.fromPairs=Jp,M.functions=ZP,M.functionsIn=eL,M.groupBy=cm,M.initial=$d,M.intersection=Zp,M.intersectionBy=Yi,M.intersectionWith=Nd,M.invert=nL,M.invertBy=rL,M.invokeMap=Y0,M.iteratee=Hw,M.keyBy=Pw,M.keys=Er,M.keysIn=Ws,M.map=Xa,M.mapKeys=oL,M.mapValues=iL,M.matches=e3,M.matchesProperty=t3,M.memoize=ge,M.merge=aL,M.mergeWith=o$,M.method=n3,M.methodOf=r3,M.mixin=qw,M.negate=Le,M.nthArg=o3,M.omit=lL,M.omitBy=uL,M.once=Ze,M.orderBy=Lw,M.over=i3,M.overArgs=ot,M.overEvery=a3,M.overSome=l3,M.partial=nt,M.partialRight=ct,M.partition=Sc,M.pick=cL,M.pickBy=i$,M.property=f$,M.propertyOf=u3,M.pull=Td,M.pullAll=bc,M.pullAllBy=Wr,M.pullAllWith=Ji,M.pullAt=co,M.range=c3,M.rangeRight=h3,M.rearg=er,M.reject=u,M.remove=rs,M.rest=Vt,M.reverse=Ed,M.sampleSize=x,M.set=dL,M.setWith=fL,M.shuffle=C,M.slice=tm,M.sortBy=F,M.sortedUniq=sm,M.sortedUniqBy=Ha,M.split=PL,M.spread=ea,M.tail=z0,M.take=B0,M.takeRight=om,M.takeRightWhile=Rd,M.takeWhile=Iw,M.tap=_w,M.throttle=zw,M.thru=ho,M.toArray=t$,M.toPairs=a$,M.toPairsIn=l$,M.toPath=g3,M.toPlainObject=r$,M.transform=pL,M.unary=cP,M.union=$w,M.unionBy=U0,M.unionWith=W0,M.uniq=qa,M.uniqBy=Nw,M.uniqWith=ql,M.unset=mL,M.unzip=Ad,M.unzipWith=Sn,M.update=gL,M.updateWith=xL,M.values=Ud,M.valuesIn=yL,M.without=Tw,M.words=h$,M.wrap=hP,M.xor=V0,M.xorBy=Ew,M.xorWith=Rw,M.zip=G0,M.zipObject=j0,M.zipObjectDeep=Aw,M.zipWith=Bs,M.entries=a$,M.entriesIn=l$,M.extend=s$,M.extendWith=Z0,qw(M,M),M.add=y3,M.attempt=d$,M.camelCase=CL,M.capitalize=u$,M.ceil=v3,M.clamp=vL,M.clone=fP,M.cloneDeep=mP,M.cloneDeepWith=gP,M.cloneWith=pP,M.conformsTo=xP,M.deburr=c$,M.defaultTo=QL,M.divide=w3,M.endsWith=SL,M.eq=pi,M.escape=kL,M.escapeRegExp=IL,M.every=q0,M.find=Pd,M.findIndex=Xi,M.findKey=qP,M.findLast=K0,M.findLastIndex=yc,M.findLastKey=KP,M.floor=b3,M.forEach=Ld,M.forEachRight=Cc,M.forIn=XP,M.forInRight=YP,M.forOwn=QP,M.forOwnRight=JP,M.get=Ww,M.gt=yP,M.gte=vP,M.has=tL,M.hasIn=Vw,M.head=Ga,M.identity=Vs,M.includes=Md,M.indexOf=fi,M.inRange=wL,M.invoke=sL,M.isArguments=kc,M.isArray=yt,M.isArrayBuffer=wP,M.isArrayLike=Us,M.isArrayLikeObject=qn,M.isBoolean=bP,M.isBuffer=Kl,M.isDate=CP,M.isElement=SP,M.isEmpty=kP,M.isEqual=IP,M.isEqualWith=$P,M.isError=Bw,M.isFinite=NP,M.isFunction=Ya,M.isInteger=QI,M.isLength=Q0,M.isMap=JI,M.isMatch=TP,M.isMatchWith=EP,M.isNaN=RP,M.isNative=AP,M.isNil=DP,M.isNull=_P,M.isNumber=ZI,M.isObject=Dn,M.isObjectLike=Ln,M.isPlainObject=hm,M.isRegExp=Uw,M.isSafeInteger=OP,M.isSet=e$,M.isString=J0,M.isSymbol=fo,M.isTypedArray=Bd,M.isUndefined=FP,M.isWeakMap=PP,M.isWeakSet=LP,M.join=Qi,M.kebabCase=$L,M.last=Ur,M.lastIndexOf=wc,M.lowerCase=NL,M.lowerFirst=TL,M.lt=MP,M.lte=zP,M.max=C3,M.maxBy=S3,M.mean=k3,M.meanBy=I3,M.min=$3,M.minBy=N3,M.stubArray=Xw,M.stubFalse=Yw,M.stubObject=d3,M.stubString=f3,M.stubTrue=p3,M.multiply=T3,M.nth=em,M.noConflict=s3,M.noop=Kw,M.now=G,M.pad=EL,M.padEnd=RL,M.padStart=AL,M.parseInt=_L,M.random=bL,M.reduce=Mw,M.reduceRight=zd,M.repeat=DL,M.replace=OL,M.result=hL,M.round=E3,M.runInContext=ue,M.sample=h,M.size=$,M.snakeCase=FL,M.some=E,M.sortedIndex=nm,M.sortedIndexBy=kw,M.sortedIndexOf=Zi,M.sortedLastIndex=M0,M.sortedLastIndexBy=rm,M.sortedLastIndexOf=ja,M.startCase=LL,M.startsWith=ML,M.subtract=R3,M.sum=A3,M.sumBy=_3,M.template=zL,M.times=m3,M.toFinite=Qa,M.toInteger=St,M.toLength=n$,M.toLower=BL,M.toNumber=Bo,M.toSafeInteger=BP,M.toString=en,M.toUpper=UL,M.trim=WL,M.trimEnd=VL,M.trimStart=GL,M.truncate=jL,M.unescape=HL,M.uniqueId=x3,M.upperCase=qL,M.upperFirst=Gw,M.each=Ld,M.eachRight=Cc,M.first=Ga,qw(M,(function(){var f={};return ys(M,function(g,S){Wt.call(M.prototype,S)||(f[S]=g)}),f})(),{chain:!1}),M.VERSION=r,br(["bind","bindKey","curry","curryRight","partial","partialRight"],function(f){M[f].placeholder=M}),br(["drop","take"],function(f,g){xt.prototype[f]=function(S){S=S===t?1:Fn(St(S),0);var R=this.__filtered__&&!g?new xt(this):this.clone();return R.__filtered__?R.__takeCount__=Cr(S,R.__takeCount__):R.__views__.push({size:Cr(S,V),type:f+(R.__dir__<0?"Right":"")}),R},xt.prototype[f+"Right"]=function(S){return this.reverse()[f](S).reverse()}}),br(["filter","map","takeWhile"],function(f,g){var S=g+1,R=S==re||S==le;xt.prototype[f]=function(D){var W=this.clone();return W.__iteratees__.push({iteratee:at(D,3),type:S}),W.__filtered__=W.__filtered__||R,W}}),br(["head","last"],function(f,g){var S="take"+(g?"Right":"");xt.prototype[f]=function(){return this[S](1).value()[0]}}),br(["initial","tail"],function(f,g){var S="drop"+(g?"":"Right");xt.prototype[f]=function(){return this.__filtered__?new xt(this):this[S](1)}}),xt.prototype.compact=function(){return this.filter(Vs)},xt.prototype.find=function(f){return this.filter(f).head()},xt.prototype.findLast=function(f){return this.reverse().find(f)},xt.prototype.invokeMap=Ct(function(f,g){return typeof f=="function"?new xt(this):this.map(function(S){return Fs(S,f,g)})}),xt.prototype.reject=function(f){return this.filter(Le(at(f)))},xt.prototype.slice=function(f,g){f=St(f);var S=this;return S.__filtered__&&(f>0||g<0)?new xt(S):(f<0?S=S.takeRight(-f):f&&(S=S.drop(f)),g!==t&&(g=St(g),S=g<0?S.dropRight(-g):S.take(g-f)),S)},xt.prototype.takeRightWhile=function(f){return this.reverse().takeWhile(f).reverse()},xt.prototype.toArray=function(){return this.take(V)},ys(xt.prototype,function(f,g){var S=/^(?:filter|find|map|reject)|While$/.test(g),R=/^(?:head|last)$/.test(g),D=M[R?"take"+(g=="last"?"Right":""):g],W=R||/^find/.test(g);D&&(M.prototype[g]=function(){var q=this.__wrapped__,J=R?[1]:arguments,fe=q instanceof xt,Ne=J[0],Te=fe||yt(q),Oe=function(Dt){var Pt=D.apply(M,Fi([Dt],J));return R&&We?Pt[0]:Pt};Te&&S&&typeof Ne=="function"&&Ne.length!=1&&(fe=Te=!1);var We=this.__chain__,et=!!this.__actions__.length,ht=W&&!We,It=fe&&!et;if(!W&&Te){q=It?q:new xt(this);var dt=f.apply(q,J);return dt.__actions__.push({func:ho,args:[Oe],thisArg:t}),new Sr(dt,We)}return ht&&It?f.apply(this,J):(dt=this.thru(Oe),ht?R?dt.value()[0]:dt.value():dt)})}),br(["pop","push","shift","sort","splice","unshift"],function(f){var g=ei[f],S=/^(?:push|sort|unshift)$/.test(f)?"tap":"thru",R=/^(?:pop|shift)$/.test(f);M.prototype[f]=function(){var D=arguments;if(R&&!this.__chain__){var W=this.value();return g.apply(yt(W)?W:[],D)}return this[S](function(q){return g.apply(yt(q)?q:[],D)})}}),ys(xt.prototype,function(f,g){var S=M[g];if(S){var R=S.name+"";Wt.call(Nl,R)||(Nl[R]=[]),Nl[R].push({name:g,func:S})}}),Nl[Wl(t,k).name]=[{name:"wrapper",func:t}],xt.prototype.clone=qh,xt.prototype.reverse=xp,xt.prototype.value=Rl,M.prototype.at=Dd,M.prototype.chain=Ka,M.prototype.commit=Od,M.prototype.next=im,M.prototype.plant=Dw,M.prototype.reverse=lm,M.prototype.toJSON=M.prototype.valueOf=M.prototype.value=Ow,M.prototype.first=M.prototype.head,ni&&(M.prototype[ni]=am),M}),bl=gw();Io?((Io.exports=bl)._=bl,zu._=bl):yn._=bl}).call(che)})(Im,Im.exports)),Im.exports}var dhe=hhe();const fhe=xf(dhe),phe=n=>async(e,t)=>{const r=await cS.get(`/users/${n}`);e({type:"GET_USER",payload:r.data})},mhe=n=>async(e,t)=>{const r=await cS.get(`/users/${n}/repos`,{params:{sort:"updated"}});e({type:"GET_REPOS",payload:r.data})},ghe=()=>async(n,e)=>{const{articles:t}=e();if(!t.articles||t.articles.length<=0){const r=await z4.get("/articles.json");n({type:"GET_ARTICLES",payload:r.data.articles})}},xhe=n=>async(e,t)=>{e({type:"UPDATE_EMAIL_BODY",payload:n.target.value})},ZF=()=>async(n,e)=>{n({type:"TOGGLE_CONTACT_MODAL"})},yhe=(n,e)=>async(t,r)=>{if((await r()).github.repoLanguages[e]===void 0){const o=await cS.get(`/repos/${n}/${e}/languages`);let i={};i[e]=o.data,t({type:"GET_LANGUAGES",payload:i})}},vhe=n=>async(e,t)=>{e({type:"SET_SORT_VALUE",payload:n})},whe=()=>async(n,e)=>{const r=await IK("/bai_model/model.json",{onProgress:s=>{n({type:"SET_PROGRESS",payload:fhe.round(s*100)})}});n({type:"SET_MODEL",payload:r})},bhe=()=>async(n,e)=>{n({type:"SET_LOADING",payload:"Loading Model. Please be Patient"})},Che=n=>async(e,t)=>{let r=await t().model.model,s=await _5(n).resizeNearestNeighbor([550,425]).toFloat().expandDims(),o=await r.predict(s).data();return console.log(o),e({type:"SET_LAST_PRED",payload:o}),o},She=n=>async(e,t)=>{console.log(n),e({type:"SET_ERROR",payload:n})},khe=()=>async(n,e)=>{let t=e().github.page;t++,n({type:"SET_PAGE",payload:t})};var Ub={exports:{}},Wb,fT;function Ihe(){if(fT)return Wb;fT=1;var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Wb=n,Wb}var Vb,pT;function $he(){if(pT)return Vb;pT=1;var n=Ihe();function e(){}function t(){}return t.resetWarningCache=e,Vb=function(){function r(i,a,l,c,d,p){if(p!==n){var m=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw m.name="Invariant Violation",m}}r.isRequired=r;function s(){return r}var o={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:s,element:r,elementType:r,instanceOf:s,node:r,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:t,resetWarningCache:e};return o.PropTypes=o,o},Vb}var mT;function Nhe(){return mT||(mT=1,Ub.exports=$he()()),Ub.exports}var The=Nhe();const it=xf(The);var Ehe=["color","size","title","className"];function UC(){return UC=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},UC.apply(null,arguments)}function Rhe(n,e){if(n==null)return{};var t,r,s=Ahe(n,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(r=0;r<o.length;r++)t=o[r],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(n,t)&&(s[t]=n[t])}return s}function Ahe(n,e){if(n==null)return{};var t={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(e.indexOf(r)!==-1)continue;t[r]=n[r]}return t}var eP=Re.forwardRef(function(n,e){var t=n.color,r=t===void 0?"currentColor":t,s=n.size,o=s===void 0?"1em":s,i=n.title,a=i===void 0?null:i,l=n.className,c=l===void 0?"":l,d=Rhe(n,Ehe);return $t.createElement("svg",UC({ref:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:o,height:o,fill:r,className:["bi","bi-arrow-down-short",c].filter(Boolean).join(" ")},d),a?$t.createElement("title",null,a):null,$t.createElement("path",{fillRule:"evenodd",d:"M8 4a.5.5 0 0 1 .5.5v5.793l2.146-2.147a.5.5 0 0 1 .708.708l-3 3a.5.5 0 0 1-.708 0l-3-3a.5.5 0 1 1 .708-.708L7.5 10.293V4.5A.5.5 0 0 1 8 4"}))});eP.propTypes={color:it.string,size:it.oneOfType([it.string,it.number]),title:it.string,className:it.string};var _he=["color","size","title","className"];function WC(){return WC=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},WC.apply(null,arguments)}function Dhe(n,e){if(n==null)return{};var t,r,s=Ohe(n,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(r=0;r<o.length;r++)t=o[r],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(n,t)&&(s[t]=n[t])}return s}function Ohe(n,e){if(n==null)return{};var t={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(e.indexOf(r)!==-1)continue;t[r]=n[r]}return t}var tP=Re.forwardRef(function(n,e){var t=n.color,r=t===void 0?"currentColor":t,s=n.size,o=s===void 0?"1em":s,i=n.title,a=i===void 0?null:i,l=n.className,c=l===void 0?"":l,d=Dhe(n,_he);return $t.createElement("svg",WC({ref:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:o,height:o,fill:r,className:["bi","bi-arrow-up-short",c].filter(Boolean).join(" ")},d),a?$t.createElement("title",null,a):null,$t.createElement("path",{fillRule:"evenodd",d:"M8 12a.5.5 0 0 0 .5-.5V5.707l2.146 2.147a.5.5 0 0 0 .708-.708l-3-3a.5.5 0 0 0-.708 0l-3 3a.5.5 0 1 0 .708.708L7.5 5.707V11.5a.5.5 0 0 0 .5.5"}))});tP.propTypes={color:it.string,size:it.oneOfType([it.string,it.number]),title:it.string,className:it.string};var Fhe=["color","size","title","className"];function VC(){return VC=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},VC.apply(null,arguments)}function Phe(n,e){if(n==null)return{};var t,r,s=Lhe(n,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(r=0;r<o.length;r++)t=o[r],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(n,t)&&(s[t]=n[t])}return s}function Lhe(n,e){if(n==null)return{};var t={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(e.indexOf(r)!==-1)continue;t[r]=n[r]}return t}var nP=Re.forwardRef(function(n,e){var t=n.color,r=t===void 0?"currentColor":t,s=n.size,o=s===void 0?"1em":s,i=n.title,a=i===void 0?null:i,l=n.className,c=l===void 0?"":l,d=Phe(n,Fhe);return $t.createElement("svg",VC({ref:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:o,height:o,fill:r,className:["bi","bi-book",c].filter(Boolean).join(" ")},d),a?$t.createElement("title",null,a):null,$t.createElement("path",{d:"M1 2.828c.885-.37 2.154-.769 3.388-.893 1.33-.134 2.458.063 3.112.752v9.746c-.935-.53-2.12-.603-3.213-.493-1.18.12-2.37.461-3.287.811zm7.5-.141c.654-.689 1.782-.886 3.112-.752 1.234.124 2.503.523 3.388.893v9.923c-.918-.35-2.107-.692-3.287-.81-1.094-.111-2.278-.039-3.213.492zM8 1.783C7.015.936 5.587.81 4.287.94c-1.514.153-3.042.672-3.994 1.105A.5.5 0 0 0 0 2.5v11a.5.5 0 0 0 .707.455c.882-.4 2.303-.881 3.68-1.02 1.409-.142 2.59.087 3.223.877a.5.5 0 0 0 .78 0c.633-.79 1.814-1.019 3.222-.877 1.378.139 2.8.62 3.681 1.02A.5.5 0 0 0 16 13.5v-11a.5.5 0 0 0-.293-.455c-.952-.433-2.48-.952-3.994-1.105C10.413.809 8.985.936 8 1.783"}))});nP.propTypes={color:it.string,size:it.oneOfType([it.string,it.number]),title:it.string,className:it.string};var Mhe=["color","size","title","className"];function GC(){return GC=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},GC.apply(null,arguments)}function zhe(n,e){if(n==null)return{};var t,r,s=Bhe(n,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(r=0;r<o.length;r++)t=o[r],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(n,t)&&(s[t]=n[t])}return s}function Bhe(n,e){if(n==null)return{};var t={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(e.indexOf(r)!==-1)continue;t[r]=n[r]}return t}var rP=Re.forwardRef(function(n,e){var t=n.color,r=t===void 0?"currentColor":t,s=n.size,o=s===void 0?"1em":s,i=n.title,a=i===void 0?null:i,l=n.className,c=l===void 0?"":l,d=zhe(n,Mhe);return $t.createElement("svg",GC({ref:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:o,height:o,fill:r,className:["bi","bi-chevron-double-down",c].filter(Boolean).join(" ")},d),a?$t.createElement("title",null,a):null,$t.createElement("path",{fillRule:"evenodd",d:"M1.646 6.646a.5.5 0 0 1 .708 0L8 12.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708"}),$t.createElement("path",{fillRule:"evenodd",d:"M1.646 2.646a.5.5 0 0 1 .708 0L8 8.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708"}))});rP.propTypes={color:it.string,size:it.oneOfType([it.string,it.number]),title:it.string,className:it.string};var Uhe=["color","size","title","className"];function jC(){return jC=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},jC.apply(null,arguments)}function Whe(n,e){if(n==null)return{};var t,r,s=Vhe(n,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(r=0;r<o.length;r++)t=o[r],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(n,t)&&(s[t]=n[t])}return s}function Vhe(n,e){if(n==null)return{};var t={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(e.indexOf(r)!==-1)continue;t[r]=n[r]}return t}var sP=Re.forwardRef(function(n,e){var t=n.color,r=t===void 0?"currentColor":t,s=n.size,o=s===void 0?"1em":s,i=n.title,a=i===void 0?null:i,l=n.className,c=l===void 0?"":l,d=Whe(n,Uhe);return $t.createElement("svg",jC({ref:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:o,height:o,fill:r,className:["bi","bi-chevron-double-up",c].filter(Boolean).join(" ")},d),a?$t.createElement("title",null,a):null,$t.createElement("path",{fillRule:"evenodd",d:"M7.646 2.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1-.708.708L8 3.707 2.354 9.354a.5.5 0 1 1-.708-.708z"}),$t.createElement("path",{fillRule:"evenodd",d:"M7.646 6.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1-.708.708L8 7.707l-5.646 5.647a.5.5 0 0 1-.708-.708z"}))});sP.propTypes={color:it.string,size:it.oneOfType([it.string,it.number]),title:it.string,className:it.string};var Ghe=["color","size","title","className"];function HC(){return HC=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},HC.apply(null,arguments)}function jhe(n,e){if(n==null)return{};var t,r,s=Hhe(n,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(r=0;r<o.length;r++)t=o[r],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(n,t)&&(s[t]=n[t])}return s}function Hhe(n,e){if(n==null)return{};var t={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(e.indexOf(r)!==-1)continue;t[r]=n[r]}return t}var oP=Re.forwardRef(function(n,e){var t=n.color,r=t===void 0?"currentColor":t,s=n.size,o=s===void 0?"1em":s,i=n.title,a=i===void 0?null:i,l=n.className,c=l===void 0?"":l,d=jhe(n,Ghe);return $t.createElement("svg",HC({ref:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:o,height:o,fill:r,className:["bi","bi-envelope",c].filter(Boolean).join(" ")},d),a?$t.createElement("title",null,a):null,$t.createElement("path",{d:"M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2zm2-1a1 1 0 0 0-1 1v.217l7 4.2 7-4.2V4a1 1 0 0 0-1-1zm13 2.383-4.708 2.825L15 11.105zm-.034 6.876-5.64-3.471L8 9.583l-1.326-.795-5.64 3.47A1 1 0 0 0 2 13h12a1 1 0 0 0 .966-.741M1 11.105l4.708-2.897L1 5.383z"}))});oP.propTypes={color:it.string,size:it.oneOfType([it.string,it.number]),title:it.string,className:it.string};var qhe=["color","size","title","className"];function qC(){return qC=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},qC.apply(null,arguments)}function Khe(n,e){if(n==null)return{};var t,r,s=Xhe(n,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(r=0;r<o.length;r++)t=o[r],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(n,t)&&(s[t]=n[t])}return s}function Xhe(n,e){if(n==null)return{};var t={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(e.indexOf(r)!==-1)continue;t[r]=n[r]}return t}var iP=Re.forwardRef(function(n,e){var t=n.color,r=t===void 0?"currentColor":t,s=n.size,o=s===void 0?"1em":s,i=n.title,a=i===void 0?null:i,l=n.className,c=l===void 0?"":l,d=Khe(n,qhe);return $t.createElement("svg",qC({ref:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:o,height:o,fill:r,className:["bi","bi-file-earmark-person",c].filter(Boolean).join(" ")},d),a?$t.createElement("title",null,a):null,$t.createElement("path",{d:"M11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0"}),$t.createElement("path",{d:"M14 14V4.5L9.5 0H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2M9.5 3A1.5 1.5 0 0 0 11 4.5h2v9.255S12 12 8 12s-5 1.755-5 1.755V2a1 1 0 0 1 1-1h5.5z"}))});iP.propTypes={color:it.string,size:it.oneOfType([it.string,it.number]),title:it.string,className:it.string};var Yhe=["color","size","title","className"];function KC(){return KC=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},KC.apply(null,arguments)}function Qhe(n,e){if(n==null)return{};var t,r,s=Jhe(n,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(r=0;r<o.length;r++)t=o[r],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(n,t)&&(s[t]=n[t])}return s}function Jhe(n,e){if(n==null)return{};var t={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(e.indexOf(r)!==-1)continue;t[r]=n[r]}return t}var aP=Re.forwardRef(function(n,e){var t=n.color,r=t===void 0?"currentColor":t,s=n.size,o=s===void 0?"1em":s,i=n.title,a=i===void 0?null:i,l=n.className,c=l===void 0?"":l,d=Qhe(n,Yhe);return $t.createElement("svg",KC({ref:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:o,height:o,fill:r,className:["bi","bi-house-door",c].filter(Boolean).join(" ")},d),a?$t.createElement("title",null,a):null,$t.createElement("path",{d:"M8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4.5a.5.5 0 0 0 .5-.5v-4h2v4a.5.5 0 0 0 .5.5H14a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293zM2.5 14V7.707l5.5-5.5 5.5 5.5V14H10v-4a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5v4z"}))});aP.propTypes={color:it.string,size:it.oneOfType([it.string,it.number]),title:it.string,className:it.string};var Zhe=["color","size","title","className"];function XC(){return XC=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},XC.apply(null,arguments)}function ede(n,e){if(n==null)return{};var t,r,s=tde(n,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(r=0;r<o.length;r++)t=o[r],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(n,t)&&(s[t]=n[t])}return s}function tde(n,e){if(n==null)return{};var t={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(e.indexOf(r)!==-1)continue;t[r]=n[r]}return t}var lP=Re.forwardRef(function(n,e){var t=n.color,r=t===void 0?"currentColor":t,s=n.size,o=s===void 0?"1em":s,i=n.title,a=i===void 0?null:i,l=n.className,c=l===void 0?"":l,d=ede(n,Zhe);return $t.createElement("svg",XC({ref:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:o,height:o,fill:r,className:["bi","bi-lightbulb",c].filter(Boolean).join(" ")},d),a?$t.createElement("title",null,a):null,$t.createElement("path",{d:"M2 6a6 6 0 1 1 10.174 4.31c-.203.196-.359.4-.453.619l-.762 1.769A.5.5 0 0 1 10.5 13a.5.5 0 0 1 0 1 .5.5 0 0 1 0 1l-.224.447a1 1 0 0 1-.894.553H6.618a1 1 0 0 1-.894-.553L5.5 15a.5.5 0 0 1 0-1 .5.5 0 0 1 0-1 .5.5 0 0 1-.46-.302l-.761-1.77a2 2 0 0 0-.453-.618A5.98 5.98 0 0 1 2 6m6-5a5 5 0 0 0-3.479 8.592c.263.254.514.564.676.941L5.83 12h4.342l.632-1.467c.162-.377.413-.687.676-.941A5 5 0 0 0 8 1"}))});lP.propTypes={color:it.string,size:it.oneOfType([it.string,it.number]),title:it.string,className:it.string};const nde=n=>q3.createPortal(ee.jsx("div",{onClick:n.onDismiss,className:`modal ${n.show?"show":"hide"}`,children:ee.jsxs("div",{onClick:e=>e.stopPropagation(),className:"box",children:[ee.jsx("div",{className:"title",children:n.title}),ee.jsx("div",{className:"content",children:n.content}),ee.jsx("div",{className:"actions",children:n.actions})]})}),document.querySelector("#modal")),rde=n=>{const e=r=>{r.preventDefault(),window.open(`mailto:cam@camscode.com?body=${n.body}`),n.toggleContactModal()},t=()=>ee.jsxs("form",{onSubmit:r=>e(r),children:[ee.jsx("textarea",{className:"large",onKeyUp:r=>{n.updateEmailBody(r)}}),ee.jsx("button",{children:"Open In Email Editor"})]});return ee.jsx(nde,{title:"Contact Me",content:t(),onDismiss:n.toggleContactModal,show:n.show})},sde=n=>({body:n.contactModal.emailBody}),ode=oh(sde,{toggleContactModal:ZF,updateEmailBody:xhe})(rde),ide=n=>ee.jsxs("div",{className:"Navigation",children:[ee.jsxs(aa,{to:"/",children:["Home",ee.jsx(aP,{})]}),ee.jsxs(aa,{to:"/bai",children:["Blank AI",ee.jsx(lP,{})]}),ee.jsxs(aa,{to:"/articles",children:["Articles",ee.jsx(nP,{})]}),ee.jsxs(aa,{to:"/about",children:["About",ee.jsx(iP,{})]}),ee.jsxs("button",{className:"end",onClick:()=>n.toggleContactModal(),children:["Contact Me",ee.jsx(oP,{})]}),ee.jsx(ode,{show:n.modal})]}),ade=n=>({modal:n.contactModal.contactModal}),lde=oh(ade,{toggleContactModal:ZF})(ide),YI=n=>ee.jsxs("div",{className:`theater ${n.extraClasses?n.extraClasses:""}`,children:[ee.jsx("div",{className:"theater-bg",style:n.background?{backgroundImage:`url(${n.background})`}:{}}),ee.jsxs("div",{className:"theater-content",children:[ee.jsx("h1",{children:n.title}),ee.jsx("div",{className:"description",children:n.description})]})]}),ude=({defVal:n=!0,icons:e=[ee.jsx(tP,{}),ee.jsx(eP,{})],text:t="",clickAction:r=()=>{}})=>{const[s,o]=Re.useState(n);return ee.jsxs("div",{className:"btn toggle",onClick:()=>{o(!s),r(s)},children:[ee.jsxs("div",{className:s?"on":"off",children:[" ",e[0]," "]}),ee.jsxs("div",{className:s?"off":"on",children:[" ",e[1]," "]}),t]})},cde=({children:n,onClick:e=()=>{},href:t=null,className:r=""})=>t===null?ee.jsx("button",{onClick:e,className:"btn "+r,children:n}):ee.jsx("a",{onClick:e,href:t,className:"btn "+r,children:n});class hde extends $t.Component{perPage=5;sortOptions=[{text:"Created Date",value:"created_at"},{text:"Last Pushed",value:"pushed_at"},{text:"Name",value:"name"},{text:"Number of Forks",value:"forks"},{text:"Size",value:"size"},{text:"Last Updated",value:"updated_at"}];componentDidMount(){document.title="Github Repos",this.props.repos||(this.props.getUser(this.props.username),this.props.getRepos(this.props.username))}renderLanguages(e){if(this.props.getRepoLanguages(this.props.username,e),this.props.repoLanguages&&this.props.repoLanguages[e])return Object.keys(this.props.repoLanguages[e]).map(t=>ee.jsx("div",{className:"language",children:t},t))}roundUp(e){return e%1===0?e:e-e%1+1}objArrayBubbleSort(e,t){let r,s;do{r=!1;for(let o=0;o<e.length-1;o++)(t.asc&&e[o][t.value]>e[o+1][t.value]||!t.asc&&e[o][t.value]<e[o+1][t.value])&&(s=e[o+1],e[o+1]=e[o],e[o]=s,r=!0)}while(r);return e}renderRepos(){if(this.props.repos)if(this.props.repos.length>0){let e=this.props.single?[this.props.repos[0]]:this.props.repos,t=this.roundUp(e.length/this.perPage);const s=this.objArrayBubbleSort([...e],this.props.sortedValue).slice(0,this.props.page*this.perPage).map(o=>{let i=new Date(o.updated_at).toLocaleString(),a=new Date(o.created_at).toLocaleString();return ee.jsxs("div",{className:"repo",children:[ee.jsx("a",{href:o.html_url,target:"_blank",rel:"noreferrer",className:"title",children:o.name}),ee.jsxs("div",{className:"content",children:[ee.jsx("p",{className:"description",children:o.description?o.description:"No Description"}),o.homepage?ee.jsx("a",{href:o.homepage,target:"_blank",rel:"noreferrer",className:"website",children:" Project Website "}):""]}),ee.jsxs("div",{className:"languages",children:["Languages:",this.renderLanguages(o.name)]}),ee.jsxs("div",{className:"time",children:["Last Updated: ",i]}),ee.jsxs("div",{className:"time",children:["Created: ",a]})]},o.id)});return ee.jsxs("div",{className:"repo-list",children:[ee.jsxs("div",{className:"sort-menu",children:[ee.jsxs("div",{className:"select-menu",children:[ee.jsx("p",{children:"Sort By:"}),ee.jsx("select",{className:"dropdown-list",onChange:o=>{this.props.setSortValue({...this.props.sortedValue,value:o.target.value})},children:this.sortOptions.map(o=>ee.jsx("option",{value:o.value,selected:o.value===this.props.sortedValue.value,children:o.text},o.value))})]}),"",ee.jsx(ude,{defVal:!1,clickAction:o=>{console.warn(o),this.props.setSortValue({...this.props.sortedValue,asc:o})}})]}),s,this.props.page<t?ee.jsxs(cde,{className:"mar-la mar-ra",onClick:()=>this.props.nextPage(),children:["Load More (",this.props.page,"/",t,")"]}):""]})}else return ee.jsx("div",{className:"loading",children:"User doesn't have any repositories"});return ee.jsx("div",{className:"loading",children:" Loading Repositories... "})}render=()=>ee.jsx("div",{children:this.renderRepos()})}const dde=n=>({repos:n.github.repos,repoLanguages:n.github.repoLanguages,page:n.github.page,sortedValue:n.github.sortedValue}),fde=oh(dde,{getRepos:mhe,getRepoLanguages:yhe,getUser:phe,nextPage:khe,setSortValue:vhe})(hde);class pde extends $t.Component{username="RaspberryProgramming";render(){return ee.jsxs("div",{className:"Github",children:[ee.jsx(YI,{title:this.username,description:ee.jsxs("div",{children:[ee.jsx("img",{alt:"avatar_pic",className:"avatar",src:this.props.user?this.props.user.avatar_url:""}),this.props.user?this.props.user.bio:""]}),background:"/img/space.webp",extraClasses:"peak"}),ee.jsx("div",{className:"content",children:ee.jsx(fde,{username:this.username})})]})}}const mde=n=>({user:n.github.user}),gde=oh(mde,{})(pde),uP=({article:n})=>{const[e,t]=Re.useState(""),[r,s]=Re.useState("");Re.useEffect(()=>{r===""?e===""&&(s(n),t("open"),setTimeout(()=>{t("show")},1024)):r!==n&&(s(n),t("close"),setTimeout(()=>{t(""),setTimeout(()=>{t("open"),setTimeout(()=>{t("show")},1024)},1024)},24))},[r,n,e]);let o=l=>{let c=[""],d=0,p,m=0;for(;m<l.length;){if(l.slice(m,m+4)==="http"){let y=m;for(let v=m;![" ",`
`].includes(l[v])&&v<l.length;v++)m=v;c[d]!==""&&d++,p=l.slice(y,m+1),c[d]=ee.jsx("a",{href:p,children:p},m),c[++d]=""}else c[d]+=l[m];m++}return c},i=l=>{let c,d=[""],p=0;for(let m=0;m<l.length;m++){if($t.isValidElement(l[m]))c=l[m];else{c=[""],p=0;for(let y=0;y<l[m].length;y++)l[m].slice(y,y+1)===`
`?(c[p]!==""&&p++,c[p]=ee.jsx("br",{},m+y),c[++p]=""):c[p]+=l[m][y];c[++p]=""}d.push(c)}return d},a=l=>{let c=[""],d=[],p=0,m=!1,y=["","`","*","~"],v;for(let b=0;b<l.length;b++)y.indexOf(l[b])>=0?m?(c[++p]="",m=!1,v=""):(d.push(y.indexOf(l[b])),c.length<p?c[p]="":c.length<d.length&&(c[++p]=""),v="",m=!0):(c.length>d.length?d.push(0):c.length<d.length&&(c[++p]=""),v=l[b]),c[p]+=v;return[...c.keys()].map(b=>{let w=o(c[b]);return w=i(w),d[b]===0?ee.jsx("div",{children:w},b):d[b]===1?ee.jsx("div",{className:"code",children:w},b):d[b]===2?ee.jsx("div",{className:"section-title",children:w},b):d[b]===3?ee.jsx("li",{children:w},b):ee.jsx("div",{},b)})};return ee.jsxs("div",{className:"article "+e,children:[ee.jsx(YI,{title:n.title,description:n.desc,extraClasses:"h-50v"}),ee.jsx("div",{className:"content",children:a(n.contents)})]})},xde=n=>ee.jsx("div",{className:"listing",children:ee.jsxs(aa,{to:n.link,children:[ee.jsx("div",{className:"title",children:n.title}),ee.jsx("div",{className:"content",children:n.children})]})}),yde=n=>()=>ee.jsx(n,{params:Lz()});class vde extends $t.Component{componentDidMount(){document.title="Articles",this.props.getArticles()}renderArticles(){const e=this.props.articles.map(t=>ee.jsx(xde,{title:t.title,link:"/articles/"+t.id,children:ee.jsx("div",{className:"description",children:t.desc})},t.id));return ee.jsx("div",{className:"listings",children:e})}article(e){return this.props.articles.length>0?ee.jsx(uP,{article:this.props.articles[e]}):ee.jsx("div",{})}render(){return ee.jsxs("div",{className:"Articles",children:[this.props.params.id?this.article(this.props.params.id):"",ee.jsx("h1",{children:"Articles"}),this.renderArticles()]})}}const wde=n=>({articles:n.articles.articles}),gT=yde(oh(wde,{getArticles:ghe})(vde)),bde=n=>{const[e,t]=Re.useState("Hello World");let r={id:"0",title:"Article Editor",desc:"This is a place to edit articles",contents:e},s=()=>{navigator.clipboard.writeText(e).then(function(){console.log("Async: Copying to clipboard was successful!")},function(o){console.error("Async: Could not copy text: ",o)})};return ee.jsxs("div",{className:"ArticleEditor",children:[ee.jsx("div",{id:"toolbar",className:"toolbar",children:ee.jsx("div",{className:"btn",onClick:s(),children:"Copy to Clipboard"})}),ee.jsx(uP,{article:r}),ee.jsx("textarea",{onInput:o=>{t(o.target.value)}})]})},Za=n=>{let e=()=>{window.scrollTo(0,0)};return ee.jsxs("div",{className:"card",children:[ee.jsxs("div",{children:[n.link?ee.jsx(aa,{to:n.link,className:"title",onClick:()=>e(),children:n.title}):ee.jsx("div",{className:"title",children:n.title}),ee.jsx("div",{className:"content-box",children:n.children}),n.skills&&ee.jsxs("div",{className:"skill-row",children:[ee.jsx("div",{className:"skills-label",children:"Skills:"}),ee.jsx("div",{className:"skills",children:n.skills?n.skills.map(t=>ee.jsx("div",{className:"skill",children:t},t)):""})]})]}),ee.jsx("img",{className:n.image?"show printHide":"",src:n.image,alt:n.title})]})};class Cde extends $t.Component{printRef=null;constructor(e){super(e),this.printRef=$t.createRef()}componentDidMount(){document.title="About"}printDiv(e){let t=this.printRef.current.innerHTML,r=document.body.innerHTML;document.body.classList=["Print",...document.body.classList],document.body.innerHTML=t,window.print(),document.body.classList.remove("Print"),document.body.innerHTML=r}render(){return ee.jsxs("div",{ref:this.printRef,className:"About",children:[ee.jsxs("div",{className:"printShow center",children:[ee.jsx("h1",{children:"Camerin Figueroa Portfolio"}),ee.jsxs("div",{children:["Contact Me: ",ee.jsx("a",{href:"mailto:cam@camscode.com",children:"cam@camscode.com"})]})]}),ee.jsx(YI,{title:"About",description:"This page has information about me and about this site.",extraClasses:"h-50v printHide",background:"/img/sunset.webp"}),ee.jsxs(Za,{title:"Build with React",image:"/img/react.webp",children:["This website is created with ",ee.jsx("a",{href:"https://reactjs.org/",children:"React"}),", a javascript library for creating user interfaces and webapps. React uses a component based design to help developers create easily re-usable code, and to help streamline the development process. JSX is a part of react which makes it easy to design websites directly in javascript code."]}),ee.jsxs(Za,{title:"Camerin Figueroa",image:"/img/profile.webp",children:["You can find a few of my projects on my",ee.jsx("a",{href:"https://github.com/RaspberryProgramming",target:"_blank",rel:"noreferrer",children:" Github"})," or look through a list of projects on this website at the ",ee.jsx(aa,{to:"/github",children:" Github Page"}),". You can email me at ",ee.jsx("a",{href:"mailto:cam@camscode.com",children:"cam@camscode.com"}),". You can also find more social media below, just click the image and it'll bring you to the selected website."]}),ee.jsxs(Za,{title:"CTECH - Networking",image:"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxQUExYUFBQWFhQXGRcbGhYWGhghIRwiHRgeHRoZGxofICojISAoIRwaJjQlJisuMDAwHCI2OjUvOSkuMS8BCgoKDg0OHBAQHDkfICAuLjksLC4uLi4uLiwuLi4uLi4uLi4uLi4uLi4uLi4uMC4uLi4uLi4uLi4uLi4uLi4uLv/AABEIALQAtAMBIgACEQEDEQH/xAAcAAACAgMBAQAAAAAAAAAAAAAABwUGAwQIAQL/xABHEAACAQMCAwUFBQUFBQgDAAABAgMABBESIQUGMQcTQVFhIjJxgZEUQlJioSNykrHBM4KistEVg7PC0hYlNUNUdOHwFyRT/8QAGgEAAgMBAQAAAAAAAAAAAAAAAAQCAwUBBv/EAC4RAAICAQQBBAECBQUAAAAAAAECAAMRBBIhMUEFEyJRFBVhMjNCUnEjgZGx8P/aAAwDAQACEQMRAD8AeNFFFEIUUUUQnlFFV/mTmu3s1zNJ7R3WNd3b4L5epwK6qljgThYAZMsFRPF+P21sMzzJH6E7n4KNz9KTPMfahdT5WH9hH+U5c/F/D+7iqPLIzEsxLMdySck/E1pU+mO3LnEVfVAcLHTxTtftkyIYpJT5nCKf5n9Krd72wXTf2cMKD82pj9cgfpS3orQT06lfGYs2oc+Zc5e07iJ6TKvwjj/qDWNe0riX/qAf93D/ANFVCirvw6f7RI+6/wBy92/avfr1ML/vJ/0kVOcO7ZW6TWwP5o3/AOVh/WlRRUG9PpbxOi9x5nQvCO0mwnwO97pj92Yaf8W6/rVsjlDAFSCDuCNwfnXJ1S3BOYrm1bMMrIPFM5U/FDtSNvpXmsy9NV/cJ1DRSx5W7V45SI7pRC5/8xclD8fFf1HqKZEEqsoZSCCMgg5B9Qay7aXrOGEbSxWHEz0UUVXJwoooohCiiiiEKKKKITygmgmkz2l9oBcta2rYTcSSqfe80Q/h8z4/DrbTQ1rbVldlgQZMlueu0xYi0FoQ8m4aXqq+i/ib16fGk9dXLyOXkZndjksxyT86w17Xo9PpEpHHczbLS55nlFFFNSqFFFFEIUUVscPs3mkSKNdTuwVR6n+nrXGYKMmdAzNeir9xPsovY94zHMPJW0n6NgfrVU4jwG5gP7a3lQeZU4+TdKoTVVP/AAmTNbDsSMqW4Jy3c3R/YxO48XxhR8XO1Mnsz4Bw6dGkWKWR4yoZrgLpyRnCKp0n577impFEFAAAAHQCs/UepFSVUc/vGKtNkZJnL3HeCy2kpilXDgAgjcMD0ZT4j/Q1Kco86z2TAKe8hJ9qNjt8VP3TTo565VS+h0nCypkxv5HxU/lPj8j4Vzze2rxSNFIpWRCQynwNW6e5NUm1xzI2IamyJ0ty5zDBeRCSFs9NSn3lPkwqZrlvgHG5bSUSxNhh1B6MPFWHiK6F5S5livYRJGcMNnQ9VPl8PI+NZmr0ZpOR1Gqbg/B7lgooopOXwoooohPK8oqB5z5gWztnmOC3uop+8x90fDxPoDXVUsQBOMQBkym9rPORiBtIGxI4/auD7in7o/Mw/T40mazXVy0jtI7FnclmJ8Sdyaw16fSacUpjzMq2wucwqU4DwGe7k7uBCxG7E7BR5s3hWlZ2rSyJGgy7sqqPMscCulOVuAx2cCwxjcbu+N3bxY//AHYVTrdX7AwOzJU07zz1FhF2O3JA1Twg+IAc/rgVgvuymSFC8t3CqjxKt9B5n0FNPm/mKOygaZ/aPuon4mPQeg8SfIUkL/jlxcyxzyTuj94dGFOiPAyNGPHw9fGs+vU3sNxbAjXsITtA5kxZdlNzKciRFi+60iurN6931A/ewfSsPGey28hUumicDqI86v4SN/lvTB5A56S7HdSkLcr5bCQD7yevmvz+F6qLa69G5gNOhHE5KZcbHbFN7sX5bwrXsi7tlYs+A6O/zPs/JvOtntN5B70NdWy/thvJEP8AzPzKPx+n3vj1wdkfM8000kEpGhYlMaKoAQIQulcfvDr5UxqNUb6cr/vK669lnMappW9q/N6LGILedhNr9vu+gXBBVn8DnGw+dWDtLZ1tXf7U0EaghlRAWkJ91A2oEZ9PXO1c91T6fpRYdxPUnqLSPiJO8tc0z2civE5KZJaIk6WzjOR57D2uu1P/AJY5hhvIRLE3oyHqh/C3+vjXMdNPkDl9rWAcSluGgTGopgEPHtgMD1Lfdx5rjrTPqNFZG7pv+5Vp7GBx4ly7TeZPslqQjYnmykeDuPxv/dB6+ZWkLxHiUszBppGkYDGptzjyJ8akObuYHvbhpm2X3Y0/Co6D4+J9TUJTGh0oqTJ7kLrd5/aFTPK3MEllMs0ZyOjpnZ18VP8AQ+BqGopyysWKQepSrEHInU/B+JR3ESTRHUjjIP8AMH1B2qQpGdkPM/cT/ZpD+ymPsZ+6/h/F0+OKedeX1NBpcrNSqzeuZ7RRRVEtnlIPtd5g7+67lT+zgyvxc++flsvyNObmXigtraWc49hCRnxPRB82IHzrmGWQsSzHLMSST4k9TWn6XTucufEU1T4G2fNeVt8O4fJPII4kLu2cKPTqfSpW55NvUkjiaBg8uQg1IQdK6iNQbSNt9zW01yKcExEKT1M3Zs6DiNvr2GpgP3ijBP8AFiujxXM3E+WLy10NLC8ZZgEZSD7XVQChPtbbfCmlw/mviUUcS3FgXdyEVhKiFzpJ9pd9JwpPh0rG9QQWMHQgx3TvtGCJG9u0EhFs4B7od4CR0DHTjPxAOPgao/Br5AkCttpkffP5dj/i/SmVc8/T6W18NcqJRCQZVP7TYhNOjJ6jGPOtHiXEbuMBpba4VZHCKO9szu59lMdwSPnVHJrFbDr9xL0s2OXEW8XDJ3cywRyadQaNxt1lCJpPnrIUY3yD5GnRyjzS5K292U74lljmUjRPobS+np7QbI6YODiqTxaSS0jjeW3u4YxhEK3Nvse7ZQBpiJB0F8H8zHqc1WL2C4u2WeOIrEHjt4VDjCYx3cSljknfOfMk1eU95QG4A8xf3NrEjzOksVRILOC34tcXClEjW1UzHIAV3kyM+RKpnHrnxqlnnXi1vbnvFQqsjQd84BYOucrs2CRg7kHp41D3/BuKSxoZI5GjlkDDLJ7bv0ZxnOcADLdAMbVTXpSM5YAGSe4Hocz57QOb2vpsLlYIyRGvn5u3qf0HzzU6sk/I1+hQNbkF20r7Ue50lse9tspr5fki+EqxGA94ysyjVHuFIDHOrH3h9a2aXprUKrCKsHY5ImLlrhkbN39y2i1jI1nxkPURRjqzHxx7o3JG1bXOXN8l6wXHdwJ/ZxD6am8zj5Dw8cx3HOB3NtoW4jZM50ZII9cEEjxFbl5yTfRRNK9uwjVSzEMhwAMkkBs1HFRcWMwP1OjcBgCV2irAOTL4xd/9nfutOrOUzjGc6M6unpWv/wBmLruPtHcsITpw5KjOpgqkAnOCSN8Vd+RWf6hK9jfUh6KsF/yZew6O8gYd44jTDIcs2cDAY+RrS4zwKe1KrPGYywyuSpz5+6TXVvrY4BgVI7EjlYggg4I3BFdI8icd+12kcpP7QexJ+8vX67N/eFc2UyuxLjGieS3Y+zKupR+ZPL4rn+EUn6lTur3DsS7TPhsR3UUUV5+aUWfbfxLRbRQg7yyZP7qDJ/xMn0pJ0x+3C61XcUfgkQPzZ2z+irS4r0fpybaR+8y9Q2XMs/Z7xaO3usytpjljeJnH3dWMN9QKtfCuI29t9itGuIpQk0s0sobMa/s3VF1Hz1dPA0raKldolsbcTIraVGI5uEX0DtZPG0awJcTiSItk98Vfu5NTbsDnI8tQ8tsScxWjG3bMcLreSNKpl1n+zlBkLn7pOMeG4xSeoqj9OXPcn+QfqNa851jaESO0bywXwOF06pY1yFkxt91sA/lFfVxf2fds63EMhe6hlQsMSopnVpFYnfC7/IUp6Kn+nKOjD3z5jI55ubV5u+Y20sRkOVt3bvnyhwZGwVAB8vStngfELSWK0VJ47dba4aVop23YayVIfozYOPnSuorv4C7Au4yPvHOcRlcUa3ubWeP7XDEwvp5hrb3l9rTpA65ztWtzDdQy8OjaW4iku4wgiMTNqZDjKSjwK77/AJfU5oCrkgDcnoBW3d8IniXVLBLGvTU8bqPqRUPw0XALTvuk84jC/wBtw/7T4fJ3yd1Haqrvq2Vgkmzeu4+tfVrdW8d6ZGksgjwzgdwzYySpUyFvvnPh5GldRUv08fcPeMu/Ps6y21nJAyi27sqsIPtRv9/Vn2m/e/6t7XxbiVr3Vzi5twk1uqDuie91qPdIGxQ5OR6mk7RXToAVCk9Q94g5xGwOP25lHEjcIG+zaDbBjr73GNIT/wDn6/OoLjHEYbqK2n78Ry26RRyW7ZGrS49uPw3zn4AeVUSihfT1BzmBuP1GnzjfxvcpPBPZI3exaZlZjL7mn9r93ux4+gWq92jtbtLFLDJG80ikziEkoH29pSfxb7eg86ptFSq0QrYEHqca3IIhUny5xHuLmCbOAkiE/DOGH8OajKKatUMpBkFOCDOthXlRXK90ZbS3kJ3aKMn46Bn9c0V5MrgzU3xJdrkueJSj8KxD/Ap/rVMq39q6/wDec/r3X/BSqhXp9H/JX/Ezbf4zCiiimZVCiiiiEKKKKIST4DwOa7k7uFNTdSTsqjzY+Fe8e4HNaSd3Mmk+BG4Yeat41dexjjqxzvbvgd9go35lHu/Mfy9ab3FeEQ3K6J41kUEEBh0PpWRfrnpu2kcRuugOmQeYg+zPh5l4hB7JKIxcnGw0qSM/PFO7nSw76yuIwMkxsQPVfaX9QKlrW0SNQsaKijoqgAfQVnrO1GqNtgfGMRqunauJyW6EHBBBHgasfDOR7yeAzxxewBlQThn9UXx/r4U/eJcAt5ypmhjkKkEFlGdvXy9OlZ+IXkcETSOQqIpJ+A8BTbepuQAo5lH4oHJM5YdCCQQQQcEHw9K+a3+OcRM88sxAXvHLYHhnoK0K2qySoJiZ4PEKKKKnIwoooohCiiigwnRfZo+rhtsfysPo7D+lFY+ysf8Adlv/AL3/AIz0V5S3+Y3+TNFRxFl2zQaeIE/jijb+a/8ALVFpr9u1j7VvMB1DoT8MMv8ANqVFb3p7bqRFLxhzAV9BTjODjpmvmnl2YG2uuH9yYl9glZUI94ncPnzI+mPhU9VqPZXdjM5VXvOIqOTuCC7uo4GYqraizDqAqk7fTFSXaHyothLGsbu6SISC+M5Bww2A9PrTRC8K4T+BJcdd3kIP1IH0FYzzfwm+xHKUPgvfJjr+FiPZ+orPOttNgdQdsY9lQuCeYjYbOR1Z1jdkT32VSQv7x8K2eH8EuJwWhglkUHBZFYj4ZroG+hhsLGUwQjRGjMI1GcnzbxI8yfCq52Vcw2otUgMiJMGcsjYXJZyRp8Dtj6VL9QcqWVepH8cAgEyC7MuT3ile6u4zEsIyglGnfxc58FH6n0q7nn22J/ZpPMoODJFC7L/FWHmuP7Td21mx/YsHmlUffCEaEPpq61bYYlVQqgKoGAAMAegFZt1psO5+zGUTaMLI3hfMMFwjSRSagmda4OpceDIRqB61FHtCsshdUuo7gdzNn6aamxwiETfaAgEpXQXGRkZz7QGx6dTUJxH/AMWtv/bz/wCZaqUKSZMlhNy95utoo4pHZws2e7HduSdPX2cZFaE/M1ldKbZhKwm9jBhmA9rpuV238fCsHPV4Ibvh8hV2CvPlY1LMcxY2UdetSNlzhG7pGILpSzBQWgcAZ8WPgKntwAQJzOTgxK8T5GvYpZI1glkVWIV1UkMM7N9KgbmykjfunjdZAQNDKQd+m1dTXd3HEpeR1RR1ZiAPqaTnHuZoG4xbzwDvlUJG2FzkksuU8yAwx6itLT661uCOhFrKFHmLu7tHiYpIjI46q4IP0NX3kfs7jvLUzSSSIxZggXTj2dsnI39rP0pqcxcHs5As10kZEWTrkOAB5N5j0NQUfaNwyHEUbEIuw7uNgo+Ax/SovrrbUwgOZ0UKp+RiHlQqxU9QSD8q8ZSOoI8d66As+XuF3jrcxJFIQxJ0bAk/jTz8dxVL7a72EyxQKg72MZZ8Ywp91PUePp9aZp1xdwm3nzK3o2qWzFjRRWSCEuyooyzEKB6k4FaTnAzFh3Oj+QbfRw+2HnErfx+1/WipmztljjSMdEVVHyGK8rybHJJmmFlZ7VeF9/w+XAy0WJR/d97/AAFq57rrGaMMCpGQQQQfEHqK5j5p4ObW5lhPRG9k+andD9CK0/S7e0Mo1Sf1Sf5A5HF+kjtKY1RgoAUEk4yfHbwpnTwR8I4ZJ3XtFASGYbs7tgFvqPkKRXCuMT27aoJXjPjpOx+I6H507eaonvOD6wCZDFFLjGCSuGfb+Kua1X90bz8SYUkbTgcxFXVy8jtJIxZ2JLMTuTWGiithVAGB1FCTnMcvY5x95o5LWU6+7AKat/YOxU+gOPrRzf2fWEFtNKpMbqrMmqTbI3CgHrnpio3sN4exlnuMYQKIwfMkhj9AB9aOMcCe9408U7PHDjUgJ99VVQQnhucnb1rBsAW9tpwBzHl5rGRzNvl0ytZ2V7Apllte9jkiHV4y3tBfzAaSBV0s+dbGRdX2mND4rIwRh5gq2+ameH2McMaxRIqRqMBV8K8n4XC7anhjZvNkUn6kUk7BjyJcqkCRfBuZVuZWWGN2hUb3HRC2fcXO7fEVp8R/8Wtv/bz/AOZatKIAMAAAeAo0DOSBnzqORniTxxKbztexw3fD5ZXCRq9xqY9BmLH8zUrac4WUjrGlxGzsQqqM7k9B0qblhVveUH4jNfK2qA5CKD54FG4EAeROYIOYne1qVJuI28DPpQLGHYnAXW+5/hwavPAuQrKCRJ4lYsuSpLEjcYzWXnnlSG8iLPhJUUlZfw4GcN5rVR7DjLicMHMJ0aWOdOoE6gvruOnlTe7dT8TjHY+5RjFnIzmVztZ5hee6eEMRFCdIXwLfeY/y+XrVFqzdo/Dmhv5ww2kYyKfMPv8AzyPlVZrb0iqKl2xS0kscya5T4/JZ3CSqTpyBIvgy53B/mPWnZzjyVDxDu3LmNlBAdQDkHcA/D+ppBcPsnmlSKMZeRgoHxNPLtO4tLaWSCB2RyyJrA6AKc7+HQUhrlxcvtnDGXUn4Hd1FDzlwD7FcNBr1jSrBsY2PmPrW/wBmHCu/4hDtlYsyt/d93/GUqs3V08jF5HZ3PVmJJPzNObsV4J3Vu9yww0xwv7i/6tn6CmNVYatPhjz1IVKGs46jLxRXtFeemlPKWPbLy4ZYlu0GXhGHx4oT1/uk/Rj5UzqwzQh1KsAVYEEHoQeoNWU2mtwwkLF3DE5l5VuoYrqF7hNcQb2gd8eTEeIBwcelOb/8n2HerEHYqdjLpwi+Wc749cUqefeV2sbgqATC+Wib08UPqv8AoamOR+RI720lmLuJQzrGBjTkIpGrbfJNa2qFNqi1jE6i6kqBLXzL2XRXDGa2lERf2tOMoc/eXHu5+YqL4Z2OPqBuLhdA6rEDk/Nun0NW204m720dtbLJFcCNE/axuvdAKFZzlcHHhjOTj1qm2XON3Y35gv5u9jGFYqBhdQDK4wAfiPWla7bypVW6/wCZay1ggkS0cf5oteExx28UYZhjESnGF8XZsHc/rVe5z5vkmtYLqCF41SbImfRlWAI0qAckHfORjbFWS8uI3ee6nhxZm2QFpFXVJ7bFdAzkDDeONytUY9pMeO5+wQ/ZM/2XjjPXpjPj0+dRpr3chckdzjtjjMgeMc8X1wMPMyqfux+wPnjc/OmH2Wc6y3DfZZlLuiFll8SFIGH9dxvUfzpwc3S29xbxBrJYTkR6FeMdScE+1jHu/lbzzWnyAYuHXLNcOBFPEO4uADocagev3T0yD0xvTFppek7VwfqRXcr98R00aqXfPHH2uDHY2MqvLMcvIjbIg33Zemf5D1qC4zyhf2cYuY7t5zCQ7IS+wXckAsdQ8xttWetII+RwTGDZ9CN6V8KTjOATgeNc9818+3F1KGRmhjQ+wiMQf3mYdTTdtufLNrdJnmRNQ3QnLA43XSN6T55dORK6kGeQi2t+jSam2ZvwoMj4+nWm9EiKxNglN7EgbTMN7z1fSwNBJNqRhgnSuoj8OoUwU57NjZ2yS2rCRogVAKBCABhsgkjOxIx41qRKvDeGqt/bxSyGVjFDhT82bcefyIFaXDe0GC5mijvbSLuwwCOBnu9xjIP3emf5VZYBZyqfEfXmRUlezzLjJb2fG7ZX3Drtke/ExG6nzH6GqhL2Nz6sLcRlPMqwP03/AJ1cP9rrYG5e4iKI8xZJI1GlxoUIu24f2d9QxnO9VHlTjXFb+aWSG4RI42DGNwMbklYx7OcbYzVNT2qpKHCj7k3CEgMOZaOA8rWnCY2uJpQ0gGDK4xj8sa+Z+ZNas/aRw6eCVZQ2NLfspE9/yCkZGenlitvmkx8RSO1VJgxlQyHu2Ai0g6wzkadWMgYzkkUr+0PlmOyuFiiZ2V0DDXgkZZlxsN+ldoCWt/qk7pywlR8RxIvlrgzXdzHAmQGOWP4VHvN8h+uK6Xs7VYo1jQYRFCqB4ADAFU7sw5T+yQ95KP8A9iUAt+Rfup8fE+vwq9VXrNR7r4HQk6K9oye57RRRScYhRRRRCRvF+FQ3EZjmjWRCc4bwPmD1B9R51Qubue/9nSC1gtQoUAgsNKEH8Cr1HrnqDTOqA5s5ZhvYu7lGGGSjjqh8x5jzHjVtLqGG8ZErsUkfHuUnlrtaWSRY7mNYwxwJEJ0g/mU7geuawc39mc89288MqFJfaJlJyp/CMA5HTFL3mXlyeyl7uZdjnRIPdceYP9Oops3PELleBxSwl++7qPdRk6c4Lfw75rQsVa2V6D/FxF1JYFX8SP4LwW4l4bPaTzIZGcpCrPkgxN7m/hlengN6XH/ZK973uvs02vOPdOPjr93Hrms3LPCrmedJo0aQLMmuQk7HOos7dQMA5arzzDzjxC1uVlliVbYsyLDqQ69K7uHxqxvkHp4VMNZS5VCCTIfFhk+J8818Pa24VHbpcoskG88YfBbvDnTgHpluh6iojs3vI7hH4bcjVHJloT4ow6hT4Hx+R86+uJXbokM0Fosv2vvWkMkZYnXLnuNj0GAQ3UjHSoHmlBa35aHKMjLIBhQFJ9rSunYqM4+VFSFkKee5xmwQfEtXKXCjwziojnI0So6RSnYNkgj4HbGPM0zeauJRw2s0khAXQwwfEkEBR6k1gmtIOJWiGRdUcqBgQd0JHVT4EbioHhfZsiyK9xcS3KIcxxSZ0r5ahk5+GwpB3Dtuc4IjCqQML0ZU+QOTEWM396NMSKXSNvEDfW48vIeP86bzFx6S6uWnLFSSBGM40KD7IB8Mdc+eaZnbXxvu4Y7VDgye0+PwqfZHzb/LVF5StgILmdYRNLEECo6BlGpwdY31Fl0nYbY61oUZKm5/PAi9nB2iXPnHl+W6srdY5Uubi2X9oEcEsHA365J9kdeu9Ubl/ky6nmVDDJGgI1ySKVCjx69T6VZrXj5tY4r97YLPL38ZVV0K+Srd8x6g5GNOMH2iMVvcK4jxO6tJklQSpNC7RS6kXBGQYwEG7HGyn51Wj21oVGMf+zOkKxye5n554Jc31zHFBPG0DRFlXWdI0EAswXOSSwAPx8q3OR+WzwqOe5upVG2CEOV0g7HpksTsB/rStto7uznQIJYpyAVQDJIboCnjn8Jpmds8sn2OAb4aQa9vHQcDH129Ki6MNtW4bTJqQctjkSL4j2xS6z3Nugj8DIWJPr7JAH61feXJvt0Ec9xaojhtUerDHb3ZFyMrn/5qjdnnZuSVuLxcAYKQN4+TSD/l+vlTgAqjVGpTtrHXmWVBzy0+qKKKTjEKKKKIQoooohCiiiiEj+K8LiuIzFNGJEPUH+YPUH1FRnHb6e2RTBa9/Gi4Ko+GUDppTSdQx5b+lWGva6Gx/iRIzEazSXdnMII44riS4LSQo4Dyouo40E59ksNh1xmtR7WS24bLFcd0srsGhhmGXVfddox9xiceXutTh4py1BM3eFTHNggTRnS4ypU+147E9c1ROI9mb4VS73EaAhMSaJEBOdID5jbf1Snqr0PfAzmLPU3iLzli5vdfc2bSamIcqhAzpB3Ynw36Havb/gEiwGYoVeGQxToRupI1I/wOcfIedMblnkae0mE9tKrHBVorhGQ4OMjUurO4HtDarbZcBZxdG5CE3OAyRklVVU0KNRAJbqc48qvfWqr5TqQWgkcyvdifE+8tHhJ3hfb91/aH+LXTHpOdl9u9pxO4tH8UOPXQwKN81Yn501+K3QiikkP3EZv4VJpHUqDaSvmMVH4c+IhebTJxDiskcXtEv3SeQCbFvhszVrz2U8TNNZJIILfUgnVfe2KySZ9cnp7oxV27K+XWNvPdH+2nEiRMfAb5b5v/AJa3uDpf/YPsQs+7cI0RlkdAmDnLYGWJwfL1pw6nZ8B0OJR7WeT5ifuOJSyyrJK/eONAzJvkLgDV57D51debOC3F08MtoFmgCKiiDZI3X3wF20jVvnyIqRs+yTH9pI7t4iNQqj+++5/uoat/AeQIoDGxkmPdkskYkYKpI3O2M/p8KlfqquCniCVN5kJw6WZLyEw28dzJ3CpPcJIN3GFOt9wpXRj8TCmIYNYTvEQspDAYyFPmpI6jPXasttapGoSNFRR0VQAB8hWesx33GNIm2Fe0UVCThRRRRCFFFFEIUUUUQhRRRRCFFFFEIUUUUQhRRRRCRB4NAZxcmMd+o0h8tnG4wd8HYnrW7d2iTRtHIMo4wwyRkEbjavKK6e5ATywtUiQRxqFRAAoHgK26KKDJCe0UUVydhRRRRCFFFFEIUUUUQhRRRRCf/9k=",skills:["CCNA1/2","Cisco IOS","Linux","Python","Cyber Security","IPv4","IPv6","Subnetting","Make Cat5e Cable","Configure Static Routing","Configure Dynamic Routing","Configure DHCP"],children:["During highschool, I had the ability to take classes at CTECH. I took the networking class that not only allowed me to learn about the in class material, but also enabled me to learn outside of what I would normally have. We took the CCNA1 and CCNA2 courses which taught me a lot about cisco networking devices, as well as the Cisco IOS Operating System. I was also able to take part in a few different competitions such as the ",ee.jsx("a",{href:"/pdf/Results_2017_NetRiders_USCAN_CCENT_R2.pdf",children:"Cisco Netriders (Discontinued) competition"}),", AFA run ",ee.jsx("a",{href:"https://www.chroniclenewspaper.com/news/local-news/they-really-get-it-EACN20160330160339989",children:"Cyber Patriot competition"}),", and the ",ee.jsx("a",{href:"https://www.facebook.com/photo.php?fbid=1665025620193621&id=115443158485216&set=a.387319137964282&refid=13",children:"Skills USA compeition"}),". After highschool I had also ",ee.jsx("a",{href:"https://www.recordonline.com/story/news/local/2018/02/15/local-students-finish-strong-in/14794857007/",children:"mentored "}),"for a few separate competitions at CTECH."]}),ee.jsx(Za,{title:"Orange County Community College - Computer Science",image:"https://upload.wikimedia.org/wikipedia/en/3/36/Orange_County_Community_College_seal.jpg",skills:["C++","Java","React","Javascript","Assembly","Data Structors & Algorithms"],children:"Taking classes at OCCC helped shape my career. While at OCCC, I took classes where I learned C++, Java, Data Structors, Assembly and more. I also took part in the Computer Science Club, Outdoors Club, and various other activities."}),ee.jsxs(Za,{title:"Marist College Experience - Computer Science",image:"https://upload.wikimedia.org/wikipedia/en/thumb/4/4b/Marist_College_Seal_-_Vector.svg/1200px-Marist_College_Seal_-_Vector.svg.png",skills:["PHP","Haskell","Git","Data Structors & Algorithms","Arduino","Robotics","Docker","Typescript","6502 Assembly"],children:["Throughout my college experience I've been able to improve my understanding of how computers work and how to design different software. I have completed my A.S. degree from Orange County Community College in Computer Science. I had finished my Bachelors degree in computer science at Marist College in Poughkeepsie in May of 2022. While at Marist I was able to work with others in teams on a few projects. A few notable projects I worked in ",ee.jsx("a",{href:"https://github.com/McDaPick/SpicyArduino-412",children:"CMPT412"}),",",ee.jsx("a",{href:"https://github.com/RaspberryProgramming/gchs-codebase",children:" Capstone Project"}),",",ee.jsx("a",{href:"https://github.com/RaspberryProgramming/422-tsiraM",children:" CMPT422"}),", and ",ee.jsx("a",{href:"https://github.com/RaspberryProgramming/T3-Project",children:"CMPT221L"}),"."]}),ee.jsx(Za,{title:"Tutoring - Computer Science",image:"/img/profile.webp",skills:["C++","Java","Web (HTML/CSS)","Javascript","Data Structors & Algorithms"],children:"While taking classes at OCCC and Marist College, I took the opportunity to tutor fellow students through each schools tutoring centers. While at OCCC, I tutored in basic level courses and had some classes that I had familiarity with. I also took part in seminars for teaching to tutors necessary skills. At Marist College, I had also tutored in relevant classes. Tutoring helped me better understand the topics I was tasked with and better understand how to teach others skills that I have."}),ee.jsx(Za,{title:"TRMI",image:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOAAAADgCAMAAAAt85rTAAAAkFBMVEX///+foaQAbLYAYrGex+Nyq9aanJ8AZLK3uLqhoqX29/amqKsAZrMAarX5/P3HyMqvsbTt7e4xhMLT1dZMlsvo8fgZd7zk5OWUv+DO4/FCjcdens8AWKxrpdPa29yztLeZxeKw0Oi/wcO71+uOu96Ctdrd6/URdLrv9vs2iMV4sNfR5fIAXq/B2+0Ydruy0ug2notqAAAEvElEQVR4nO2baXeyOhRGGRQcCIpTiyNqa21r2///7y5TQiYVffVq1nr2N8kBsw1mIAfLAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKA2nWWrYrXMDkWrYV7S6uURm1UV0Ht5YFWvIhy22hVebhZ5uVmn3cpD+nYV0O9FD6zsFUQrz7Mr9IJchOd1lw+s7sVEXV6vhmCmaJBhR/KrI5gGGWMY9aSq1xTshw+s9CUM5QasJ2hOE7ZsmZqCmwdW+hJW1wquHljpS7hW0O52HljrC4AgBJ8cCNYTDBtJ4zRJnMXFJ8KSdTyurvjDRyZ/mqrvhIitxV8/Wd9YcOwc/NPMF1ncYn48wg2cySymV5zNhaLYUhjxEfOpxV//MKEzrVsJTohzGreZxTXdEyGEBG7wVl5RjHRnit824L/SHQlnBYNnFMwl3bVOkBC5CcNPX7i8KYJOMNlrBFMBaXbfkMtNEXT8tU7Qcdf891nhwBeLzRF037WC/lRowoYvnXVvQcdlHVoQsK8NAqkXZdUmfsD1gdkH+gv5YlWra/FNOJ4EYum9BcM1NybNyl+XfLxyR2O+AmQiDYKvI1pjWZCKB4N99X3vcum9BQUSZqEs+2kF/E/lLGooCZIP5vDGYse/hJY+QvCVCY7lIrUC1c/iawX9xWdpTvtXi79/30t/AwRj/S3qvrMRnTVhTOiR2bdjjOC69JAFm9aU3a27InRGGzCId08rqJz1Re9JRXBL+59iqLG+WQM203Z/VsFQZN+gHaI0DmZSM6EJwxH96OyeVpB8TEUm9I9GZ528IPefS0v+6JDpfllPK5hWIZ0QVLBhnhyaYmR+W7LTgh8rnJbdbd6rPq+gHhI0Q43g+LcaJP/KtiZ+YhknSAZrObLoWOggSUiDDot+vsQ1TdAZvGoF2eKBsMlZseowTDCt2eFNJ6isHuga/2kFiSvAOhkn+B3rBK2RaEg72ysE7XyDennvYWImwoYJx020gj/i+shfWFcKekXNh6Lg5saCympi36Qt5H9pBav5WS7wMb5aML9DrVYp2C0aNGrLhreei+4H+uUSE9yx7sVh053LBb3CK9vYLgVL4aUtZCrQhr6dIPuTHROsFrn84ve8oMdhd1flxu3QY4L9wiTadNt87P8vuK8eU7gNevCsYPTCEbGjbZvdomUTpmOREHsiG+hOguy6/AOos4JawrTTZIK2fWlm070E6bNeks5I/0mw00r/bpWgd6nhG90gcBRBde+AMZ0Luwx0b2K+qELWh/zZ3XxUHYpd9/TehIaXfNDjWtCzh8ejNXzTLZ6G+lxC2f1hbGlRsU9Ed5cS7pl9WD6C4363/bndJVWvZ+fdJSeYpcUsTcmLkRH6jeVm07fL0UAQzPLTNpueEGyIcd+TYAOdIJgpirSN3eE9InjBVO2pgOCxYlMyndRctZqCpuSqqdmGNQVNyTZU80VrCZqTL6pm/NYTNKUBLTVnu4agUTnbStb9WUHTsu7l9ybo6xNUUCkx7r0J6c0X+gJM8ebLRi0x780XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEbzH2yahtDw6DjLAAAAAElFTkSuQmCC",skills:["C#",".Net Framework","Windows Forms","Windows Services","Microsoft IIS","ASP.NET MVC","Entity Framework","MSSQL","Microsoft Message Queuing","Angular","Typescript","Oracle Database","Credit Payment API's","Documentation","Deployments"],children:"Working as a Full Stack Software Developer at a toll collection systems company. Here I work as a Full Stack Software Developer on the company's management software, as well as their payment software. In addition, I help support some of the older systems that are under maintenence. This has exposed me to all sorts of current and legacy software designs. I've worked on a variety of components of the software including our web front end, ASP.NET APIs, Windows Services Written in C#, create and debug Oracle Database Procedures & Packages. I've had to opportunity to train new employees and get them up to speed so they can develop software."}),ee.jsx(Za,{title:"HVCU (Current Employer)",image:"/img/hvcu.webp",skills:["Agile","Python","Pandas","Numpy","PowerOn","JavaScript","Jira"],children:"Working at HVCU, I've taken courses and gained experience with agile methodologies. I've learned to write specfiles in PowerOn and create programs with state of the art technologies provided by Jack Henry. I've been able to work with Python in processing data from the core system and from third party vendors."}),ee.jsxs(Za,{title:"Github",link:"/github",skills:["Tensorflow","Redis","React","Python","Raspberry Pi","Linux"],children:[ee.jsx("p",{children:"You can access a list of github repositories that I've created directly on this site."}),ee.jsx(aa,{className:"btn",to:"/github",children:"Learn More"}),ee.jsx("br",{})]}),ee.jsxs("div",{className:"social",children:[ee.jsx("div",{className:"title",children:"Social Media:"}),ee.jsxs("div",{className:"links",children:[ee.jsx("a",{href:"https://github.com/RaspberryProgramming",target:"_blank",rel:"noreferrer",className:"link bg-white",children:ee.jsx("img",{src:"/img/github.webp",alt:"Github"})}),ee.jsx("a",{href:"https://www.linkedin.com/in/camerin-figueroa-2662bb157/",target:"_blank",rel:"noreferrer",className:"link bg-white",children:ee.jsx("img",{className:"printHide",src:"/img/linkedin.webp",alt:"LinkedIn"})}),ee.jsx("a",{href:"https://www.hackerrank.com/figueroa0609",target:"_blank",rel:"noreferrer",className:"link bg-hackerrank",children:ee.jsx("img",{className:"printHide",src:"/img/hackerrank.webp",alt:"Hacker Rank"})}),ee.jsx("a",{href:"https://app.hackthebox.eu/profile/734741",target:"_blank",rel:"noreferrer",className:"link bg-white",children:ee.jsx("img",{className:"printHide",src:"/img/hackthebox.webp",alt:"Hack The Box"})}),ee.jsx("a",{href:"https://www.udemy.com/user/camerin-figueroa/",target:"_blank",rel:"noreferrer",className:"link bg-white",children:ee.jsx("img",{className:"printHide",src:"/img/udemy.webp",alt:"Udemy"})}),ee.jsx("a",{href:"https://leetcode.com/RaspberryProgramming/",target:"_blank",rel:"noreferrer",className:"link bg-black",children:ee.jsx("img",{className:"printHide",src:"/img/leetcode_logo.webp",alt:"leet code"})})]})]})]})}}const Gb=n=>ee.jsx("div",{className:"topic",style:{backgroundImage:n.background?`url(${n.background})`:""},children:ee.jsxs("div",{className:"content",children:[ee.jsx(aa,{to:n.link,children:ee.jsx("h1",{className:"title",children:n.title})}),ee.jsx("div",{className:"children",children:n.children}),ee.jsx(aa,{className:"btn",to:n.link,children:"Learn More"})]})});class Sde extends $t.Component{constructor(){super(),this.state={start:!1,prev:"previous",curr:"current",next:"next",prevLoc:-1,currLoc:0,nextLoc:1,moving:!1}}topics=[ee.jsx(Gb,{link:"/about",title:"Welcome to My Portfolio",background:"/img/background.webp",children:ee.jsxs("div",{children:["This website helps you access the projects that I've worked on. You can navigate at the top to different locations in the site. Within you can find information about me, my github repositories, and articles I've posted. This website is coded with React/Redux and hosted over Vercel. You can email me at ",ee.jsx("a",{href:"mailto:cam@camscode.com",children:"cam@camscode.com"}),"."]})}),ee.jsx(Gb,{link:"/github",title:"Github",background:"img/space.webp",children:"View a list of projects I've done right on this website. You can easily direct to github where you can see the project code itself."}),ee.jsx(Gb,{link:"/articles",title:"Articles",background:"/img/sunset.webp",children:"Read through some homemade articles that go over interesting topics and may teach you some skills in tech."})];handleKey=e=>{switch(e.key){case"ArrowUp":this.handleInput("up");break;case"ArrowDown":this.handleInput("down");break}};handleInput=e=>{e==="up"&&!this.state.moving&&this.state.currLoc>0?(this.setState({prev:"current top",moving:!0}),setTimeout(()=>{let t=this.state.prevLoc-1,r=this.state.currLoc-1,s=this.state.nextLoc-1;this.setState({prev:"previous notrans",currLoc:r,nextLoc:s}),setTimeout(()=>{this.setState({prev:"previous",prevLoc:t,moving:!1})},75)},900)):e==="down"&&!this.state.moving&&this.state.nextLoc<this.topics.length?(this.setState({next:"current",moving:!0}),setTimeout(()=>{let t=this.state.prevLoc+1,r=this.state.currLoc+1,s=this.state.nextLoc+1;this.setState({next:"next notrans",prevLoc:t,currLoc:r}),setTimeout(()=>{this.setState({next:"next",nextLoc:s,moving:!1})},75)},900)):e==="down"&&this.state.nextLoc>=this.topics.length};onWheel(e){e.deltaY<0&&this.handleInput("up"),e.deltaY>0&&this.handleInput("down")}componentDidMount(){setTimeout(()=>{this.setState({start:!0})},100),document.title="HomePage"}render(){return ee.jsxs("div",{onKeyDown:this.handleKey,tabIndex:"0",className:this.state.start?"intro start":"intro",onWheel:e=>{this.onWheel(e)},children:[ee.jsx("div",{className:"navbutton top"+(this.state.currLoc>0?"":" hidden"),onClick:()=>{this.handleInput("up")},children:ee.jsx(sP,{})}),ee.jsx("div",{id:"previous",className:this.state.prev,children:this.topics[this.state.prevLoc]}),ee.jsx("div",{id:"current",className:this.state.curr,children:this.topics[this.state.currLoc]}),ee.jsx("div",{id:"next",className:this.state.next,children:this.topics[this.state.nextLoc]}),ee.jsx("div",{className:"navbutton bottom"+(this.state.currLoc<this.topics.length-1?"":" hidden"),onClick:()=>{this.handleInput("down")},children:ee.jsx(rP,{})})]})}}const kde=n=>({}),Ide=oh(kde,{})(Sde);class $de extends $t.Component{render(){let e=document.getElementById("ProgressBar"),t=0;return e!==null&&(t=e.offsetWidth*(this.props.progress/100)),ee.jsx("div",{className:"ProgressBar",id:"ProgressBar",children:ee.jsx("div",{style:{width:t+"px"},className:"Bar"})})}}class Nde extends $t.Component{classes={0:"Blank",1:"Not Blank"};componentDidMount(){document.title="Blank AI"}extExtractor(e){let t=e.split(".");return t[t.length-1]}async fileUpload(e,t){const[r]=e.files;let s=document.getElementById("preview"),o=["jpg","png"],i=await this.extExtractor(r.name);if(r&&o.includes(i)){let a=await createImageBitmap(r),l=await t(a);console.log(this.declassify(l[0])),s.src=await URL.createObjectURL(r),s.classList.add("show")}else this.props.error_msg("Please pass JPG or PNG file Only")}declassify(e){return e>.5?this.classes[1]:this.classes[0]}render(){let e=this.props.model===null?ee.jsxs("div",{className:"content",children:[ee.jsx("h1",{children:"Would you like to download the model?"}),ee.jsx("p",{children:"By clicking Accept below, you will download the model which may be between 100 mb in size to 1 gb."}),ee.jsx("button",{className:`btn ${this.props.loading?"hide":""}`,onClick:()=>{this.props.loadingModel(),this.props.downloadModel()},children:"Accept Download"}),ee.jsx("h2",{children:this.props.loading}),ee.jsx($de,{progress:this.props.downloadProgress}),ee.jsx("h2",{children:this.props.loading?this.props.downloadProgress+"%":""})]}):ee.jsxs("div",{className:"content",children:[ee.jsx("h1",{children:"BAI Model Prediction"}),ee.jsx("p",{className:"prediction",children:this.props.last_prediction?this.declassify(this.props.last_prediction[0]):"Waiting for Prediction"}),ee.jsx("div",{className:"error "+(this.props.error?"enable":""),children:this.props.error}),ee.jsx("img",{id:"preview",alt:"preview of predicted file"}),ee.jsx("input",{type:"file",id:"fileSubmit",onChange:({target:t})=>this.fileUpload(t,this.props.predict)}),ee.jsx("button",{className:"btn",onClick:()=>{document.getElementById("fileSubmit").click()},children:"Upload Image"})]});return ee.jsxs("div",{className:"Bai",children:[e,ee.jsxs("div",{className:"about",children:[ee.jsx("h1",{children:"About"}),ee.jsx("p",{children:"You can find the source, dataset and model created for BAI on github at"}),ee.jsx("a",{href:"https://www.github.com/RaspberryProgramming/BAI",children:" https://www.github.com/RaspberryProgramming/BAI"})]})]})}}const Tde=n=>({model:n.model.model,loading:n.model.loading,last_prediction:n.model.last_prediction,downloadProgress:n.model.progress,error:n.model.error}),Ede=oh(Tde,{downloadModel:whe,loadingModel:bhe,predict:Che,error_msg:She})(Nde),Rde=n=>ee.jsx(iB,{children:ee.jsxs("div",{className:"App",children:[ee.jsx(lde,{}),ee.jsx("div",{className:"app-content",children:ee.jsxs(Zz,{children:[ee.jsx(Xl,{path:"/",exact:!0,element:ee.jsx(Ide,{})}),ee.jsx(Xl,{path:"/github",element:ee.jsx(gde,{})}),ee.jsx(Xl,{path:"/about",element:ee.jsx(Cde,{})}),ee.jsx(Xl,{path:"/articles",element:ee.jsx(gT,{})}),ee.jsx(Xl,{path:"/articles/:id",element:ee.jsx(gT,{})}),ee.jsx(Xl,{path:"/bai",element:ee.jsx(Ede,{})}),ee.jsx(Xl,{path:"/articleEditor",element:ee.jsx(bde,{})})]})})]})});let Ade=(n={repoLanguages:{},page:1,sortedValue:{value:"pushed_at",asc:!1}},e)=>{switch(e.type){case"GET_REPOS":return{...n,repos:e.payload};case"GET_LANGUAGES":return{...n,repoLanguages:{...n.repoLanguages,...e.payload}};case"GET_USER":return{...n,user:e.payload};case"SET_PAGE":return{...n,page:e.payload};case"SET_SORT_VALUE":return{...n,sortedValue:e.payload};default:return n}},_de=(n={contactModal:!1,emailBody:""},e)=>{switch(e.type){case"TOGGLE_CONTACT_MODAL":return{...n,contactModal:!n.contactModal};case"UPDATE_EMAIL_BODY":return{...n,emailBody:e.payload};default:return n}},Dde=(n={start:!1},e)=>{switch(e.type){case"SET_INTRO":return{...n,start:e.payload};default:return n}},Ode=(n={articles:[]},e)=>{switch(e.type){case"GET_ARTICLES":return{...n,articles:e.payload};default:return n}},Fde=(n={model:null,loading:"",progress:0},e)=>{switch(e.type){case"SET_MODEL":return{...n,model:e.payload};case"SET_LOADING":return{...n,loading:e.payload};case"SET_LAST_PRED":return{...n,last_prediction:e.payload};case"SET_ERROR":return{...n,error:e.payload};case"SET_PROGRESS":return{...n,progress:e.payload};default:return n}};const Pde=ET({github:Ade,contactModal:_de,intro:Dde,articles:Ode,model:Fde}),Lde=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__||Rm,Mde=ZM({reducer:Pde},Lde(RT(Dy))),zde=document.getElementById("root");W3.createRoot(zde).render(ee.jsx(SM,{store:Mde,children:ee.jsx(Rde,{})}));